diff --git a/CHANGELOG.md b/CHANGELOG.md index 81e720a..dfb83a0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,7 @@ - Bug #40: Refactor tests to use `assertSame()` for rendering with `testRenderWithGlobalDefaultsAreApplied()` and `testRenderWithUserOverridesGlobalDefaults()` (@terabytesoftw) - Enh #41: Add `InputImage` class for HTML `` element with attributes and rendering capabilities (@terabytesoftw) - Bug #42: Fix messages in `assert()` methods and code style (@terabytesoftw) +- Bug #43: Update `ui-awesome/html-helper` to version `^0.7` and `ui-awesome/html-mixin` to version `^0.4` in `composer.json` and apply necessary changes to `src` and `tests` directories (@terabytesoftw) ## 0.3.0 March 31, 2024 diff --git a/composer.json b/composer.json index 4e1f9f3..4622b28 100644 --- a/composer.json +++ b/composer.json @@ -12,10 +12,11 @@ "require": { "php": "^8.1", "ext-mbstring": "*", - "ui-awesome/html-attribute": "dev-main as 0.5.2", + "ui-awesome/html-attribute": "^0.6@dev", "ui-awesome/html-core": "^0.6@dev", - "ui-awesome/html-helper": "^0.6", - "ui-awesome/html-interop": "^0.3" + "ui-awesome/html-helper": "^0.7", + "ui-awesome/html-interop": "^0.3", + "ui-awesome/html-mixin": "^0.4" }, "require-dev": { "infection/infection": "^0.27|^0.32", diff --git a/src/Embedded/Attribute/HasElementtiming.php b/src/Embedded/Attribute/HasElementtiming.php index 6ede488..0ee622c 100644 --- a/src/Embedded/Attribute/HasElementtiming.php +++ b/src/Embedded/Attribute/HasElementtiming.php @@ -9,9 +9,7 @@ /** * Provides an immutable API for the HTML `elementtiming` attribute. * - * @method static addAttribute(string|UnitEnum $key, mixed $value) Adds an attribute and returns a new instance. - * {@see \UIAwesome\Html\Mixin\HasAttributes} for managing the underlying attributes array. - * + * @mixin \UIAwesome\Html\Mixin\HasAttributes * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Attributes/elementtiming * * @copyright Copyright (C) 2026 Terabytesoftw. @@ -35,6 +33,6 @@ trait HasElementtiming */ public function elementtiming(string|UnitEnum|null $value): static { - return $this->addAttribute('elementtiming', $value); + return $this->setAttribute('elementtiming', $value); } } diff --git a/src/Embedded/Attribute/HasIsmap.php b/src/Embedded/Attribute/HasIsmap.php index e69cfcc..c50b7c6 100644 --- a/src/Embedded/Attribute/HasIsmap.php +++ b/src/Embedded/Attribute/HasIsmap.php @@ -7,9 +7,7 @@ /** * Provides an immutable API for the HTML `ismap` attribute. * - * @method static addAttribute(string|\UnitEnum $key, mixed $value) Adds an attribute and returns a new instance. - * {@see \UIAwesome\Html\Mixin\HasAttributes} for managing the underlying attributes array. - * + * @mixin \UIAwesome\Html\Mixin\HasAttributes * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/img#ismap * * @copyright Copyright (C) 2026 Terabytesoftw. @@ -31,6 +29,6 @@ trait HasIsmap */ public function ismap(bool $value): static { - return $this->addAttribute('ismap', $value); + return $this->setAttribute('ismap', $value); } } diff --git a/src/Form/Attribute/HasFormaction.php b/src/Form/Attribute/HasFormaction.php index f32ab33..9dde767 100644 --- a/src/Form/Attribute/HasFormaction.php +++ b/src/Form/Attribute/HasFormaction.php @@ -10,9 +10,7 @@ /** * Provides an immutable API for the HTML `formaction` attribute. * - * @method static addAttribute(string|UnitEnum $key, mixed $value) Adds an attribute and returns a new instance. - * {@see \UIAwesome\Html\Mixin\HasAttributes} for managing the underlying attributes array. - * + * @mixin \UIAwesome\Html\Mixin\HasAttributes * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Attributes/formaction * * @copyright Copyright (C) 2026 Terabytesoftw. @@ -34,6 +32,6 @@ trait HasFormaction */ public function formaction(string|Stringable|UnitEnum|null $value): static { - return $this->addAttribute('formaction', $value); + return $this->setAttribute('formaction', $value); } } diff --git a/src/Form/Attribute/HasFormenctype.php b/src/Form/Attribute/HasFormenctype.php index d450e22..ec5bb9a 100644 --- a/src/Form/Attribute/HasFormenctype.php +++ b/src/Form/Attribute/HasFormenctype.php @@ -10,9 +10,7 @@ /** * Provides an immutable API for the HTML `formenctype` attribute. * - * @method static addAttribute(string|UnitEnum $key, mixed $value) Adds an attribute and returns a new instance. - * {@see \UIAwesome\Html\Mixin\HasAttributes} for managing the underlying attributes array. - * + * @mixin \UIAwesome\Html\Mixin\HasAttributes * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Attributes/formenctype * * @copyright Copyright (C) 2026 Terabytesoftw. @@ -35,6 +33,6 @@ trait HasFormenctype */ public function formenctype(string|Stringable|UnitEnum|null $value): static { - return $this->addAttribute('formenctype', $value); + return $this->setAttribute('formenctype', $value); } } diff --git a/src/Form/Attribute/HasFormmethod.php b/src/Form/Attribute/HasFormmethod.php index ef7840b..701ac54 100644 --- a/src/Form/Attribute/HasFormmethod.php +++ b/src/Form/Attribute/HasFormmethod.php @@ -10,9 +10,7 @@ /** * Provides an immutable API for the HTML `formmethod` attribute. * - * @method static addAttribute(string|UnitEnum $key, mixed $value) Adds an attribute and returns a new instance. - * {@see \UIAwesome\Html\Mixin\HasAttributes} for managing the underlying attributes array. - * + * @mixin \UIAwesome\Html\Mixin\HasAttributes * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Attributes/formmethod * * @copyright Copyright (C) 2026 Terabytesoftw. @@ -34,6 +32,6 @@ trait HasFormmethod */ public function formmethod(string|Stringable|UnitEnum|null $value): static { - return $this->addAttribute('formmethod', $value); + return $this->setAttribute('formmethod', $value); } } diff --git a/src/Form/Attribute/HasFormnovalidate.php b/src/Form/Attribute/HasFormnovalidate.php index d180bb4..ded5421 100644 --- a/src/Form/Attribute/HasFormnovalidate.php +++ b/src/Form/Attribute/HasFormnovalidate.php @@ -7,9 +7,7 @@ /** * Provides an immutable API for the HTML `formnovalidate` attribute. * - * @method static addAttribute(string|\UnitEnum $key, mixed $value) Adds an attribute and returns a new instance. - * {@see \UIAwesome\Html\Mixin\HasAttributes} for managing the underlying attributes array. - * + * @mixin \UIAwesome\Html\Mixin\HasAttributes * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Attributes/formnovalidate * * @copyright Copyright (C) 2026 Terabytesoftw. @@ -31,6 +29,6 @@ trait HasFormnovalidate */ public function formnovalidate(bool|null $value): static { - return $this->addAttribute('formnovalidate', $value); + return $this->setAttribute('formnovalidate', $value); } } diff --git a/src/Form/Attribute/HasFormtarget.php b/src/Form/Attribute/HasFormtarget.php index ccdd462..2fcaf21 100644 --- a/src/Form/Attribute/HasFormtarget.php +++ b/src/Form/Attribute/HasFormtarget.php @@ -10,9 +10,7 @@ /** * Provides an immutable API for the HTML `formtarget` attribute. * - * @method static addAttribute(string|UnitEnum $key, mixed $value) Adds an attribute and returns a new instance. - * {@see \UIAwesome\Html\Mixin\HasAttributes} for managing the underlying attributes array. - * + * @mixin \UIAwesome\Html\Mixin\HasAttributes * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Attributes/formtarget * * @copyright Copyright (C) 2026 Terabytesoftw. @@ -35,6 +33,6 @@ trait HasFormtarget */ public function formtarget(string|Stringable|UnitEnum|null $value): static { - return $this->addAttribute('formtarget', $value); + return $this->setAttribute('formtarget', $value); } } diff --git a/src/Form/Base/BaseChoice.php b/src/Form/Base/BaseChoice.php new file mode 100644 index 0000000..ef92adf --- /dev/null +++ b/src/Form/Base/BaseChoice.php @@ -0,0 +1,115 @@ +buildAttributes(parent::getAttributes()); + } + + /** + * Renders the `` element with its attributes. + * + * @return string Rendered HTML for the `` element. + */ + protected function run(): string + { + /** @var string|null $id */ + $id = $this->getAttribute('id', null); + + $unchecked = ''; + $uncheckedValue = $this->getUncheckedValue(); + + if ($uncheckedValue !== null) { + /** @phpstan-var string $name */ + $name = $this->getAttribute('name', ''); + + $unchecked = InputHidden::tag() + ->id(null) + ->name($name) + ->value($uncheckedValue) + ->render(); + } + + $label = $this->getLabel(); + + if ($this->isLabel() === false) { + return $this->buildElement( + '', + [ + '{label}' => '', + '{unchecked}' => $unchecked, + ], + ); + } + + $labelAttributes = $this->getLabelAttributes(); + $labelTag = Label::tag()->attributes($labelAttributes); + + if ($this->enclosedByLabel === false) { + if (array_key_exists('for', $labelAttributes) === false) { + $labelTag = $labelTag->for($id); + } + + $labelTag = $labelTag->content($label); + + return $this->buildElement( + '', + [ + '{label}' => $labelTag, + '{unchecked}' => $unchecked, + ], + ); + } + + $labelTag = $labelTag + ->html( + "\n", + Html::element($this->getTag(), '', $this->getAttributes()), + "\n", + $label, + "\n", + ); + + return $this->buildElement( + '', + [ + '{tag}' => $labelTag, + '{label}' => '', + '{unchecked}' => $unchecked, + ], + ); + } +} diff --git a/src/Form/InputCheckbox.php b/src/Form/InputCheckbox.php index 7178533..0c8073f 100644 --- a/src/Form/InputCheckbox.php +++ b/src/Form/InputCheckbox.php @@ -4,19 +4,9 @@ namespace UIAwesome\Html\Form; -use Stringable; -use UIAwesome\Html\Attribute\Form\HasRequired; -use UIAwesome\Html\Attribute\Global\{CanBeAutofocus, HasTabindex}; -use UIAwesome\Html\Attribute\HasValue; use UIAwesome\Html\Attribute\Values\Type; -use UIAwesome\Html\Core\Element\BaseInput; -use UIAwesome\Html\Core\Html; -use UIAwesome\Html\Form\Mixin\{CanBeEnclosedByLabel, HasCheckedState, HasLabel}; +use UIAwesome\Html\Form\Base\BaseChoice; use UIAwesome\Html\Interop\{VoidInterface, Voids}; -use UIAwesome\Html\Phrasing\Label; -use UnitEnum; - -use function array_key_exists; /** * Represents the HTML `` element. @@ -38,52 +28,8 @@ * @copyright Copyright (C) 2026 Terabytesoftw. * @license https://opensource.org/license/bsd-3-clause BSD 3-Clause License. */ -final class InputCheckbox extends BaseInput +final class InputCheckbox extends BaseChoice { - use CanBeAutofocus; - use CanBeEnclosedByLabel; - use HasCheckedState; - use HasLabel; - use HasRequired; - use HasTabindex; - use HasValue; - - /** - * Value to be submitted when the checkbox is not checked. - * - * If set, an additional hidden input will be rendered with the same name as the checkbox and this value. - * - * This ensures that a value is always submitted for the checkbox, even when it is unchecked. - */ - private bool|float|int|string|Stringable|UnitEnum|null $uncheckedValue = null; - - /** - * Returns the array of HTML attributes for the element. - * - * @return array Attributes array assigned to the element. - * - * @phpstan-return mixed[] - */ - public function getAttributes(): array - { - return $this->buildAttributes(parent::getAttributes()); - } - - /** - * Set the value that should be submitted when the checkbox is not checked. - * - * @param bool|float|int|string|Stringable|UnitEnum|null $value Value to be submitted. - * - * @return static New instance with the updated `uncheckedValue` value. - */ - public function uncheckedValue(bool|float|int|string|Stringable|UnitEnum|null $value): static - { - $new = clone $this; - $new->uncheckedValue = $value; - - return $new; - } - /** * Returns the tag enumeration for the `` element. * @@ -108,74 +54,4 @@ protected function loadDefault(): array 'type' => [Type::CHECKBOX], ] + parent::loadDefault(); } - - /** - * Renders the `` element with its attributes. - * - * @return string Rendered HTML for the `` element. - */ - protected function run(): string - { - /** @var string|null $id */ - $id = $this->getAttribute('id', null); - - $unchecked = ''; - - if ($this->uncheckedValue !== null) { - /** @phpstan-var string $name */ - $name = $this->getAttribute('name', ''); - - $unchecked = InputHidden::tag() - ->id(null) - ->name($name) - ->value($this->uncheckedValue) - ->render(); - } - - if ($this->notLabel || $this->label === '') { - return $this->buildElement( - '', - [ - '{label}' => '', - '{unchecked}' => $unchecked, - ], - ); - } - - $labelTag = Label::tag()->attributes($this->labelAttributes); - - if ($this->enclosedByLabel === false) { - if (array_key_exists('for', $this->labelAttributes) === false) { - $labelTag = $labelTag->for($id); - } - - $labelTag = $labelTag->content($this->label); - - return $this->buildElement( - '', - [ - '{label}' => $labelTag, - '{unchecked}' => $unchecked, - ], - ); - } - - $labelTag = $labelTag - ->html( - "\n", - Html::element($this->getTag(), '', $this->getAttributes()), - "\n", - $this->label, - "\n", - ); - - return $this->buildElement( - '', - [ - '{tag}' => $labelTag, - '{label}' => '', - '{unchecked}' => $unchecked, - ], - ); - } } diff --git a/src/Form/InputRadio.php b/src/Form/InputRadio.php index 5d3129a..9d56381 100644 --- a/src/Form/InputRadio.php +++ b/src/Form/InputRadio.php @@ -4,19 +4,9 @@ namespace UIAwesome\Html\Form; -use Stringable; -use UIAwesome\Html\Attribute\Form\HasRequired; -use UIAwesome\Html\Attribute\Global\{CanBeAutofocus, HasTabindex}; -use UIAwesome\Html\Attribute\HasValue; use UIAwesome\Html\Attribute\Values\Type; -use UIAwesome\Html\Core\Element\BaseInput; -use UIAwesome\Html\Core\Html; -use UIAwesome\Html\Form\Mixin\{CanBeEnclosedByLabel, HasCheckedState, HasLabel}; +use UIAwesome\Html\Form\Base\BaseChoice; use UIAwesome\Html\Interop\{VoidInterface, Voids}; -use UIAwesome\Html\Phrasing\Label; -use UnitEnum; - -use function array_key_exists; /** * Represents the HTML `` element. @@ -38,52 +28,8 @@ * @copyright Copyright (C) 2026 Terabytesoftw. * @license https://opensource.org/license/bsd-3-clause BSD 3-Clause License. */ -final class InputRadio extends BaseInput +final class InputRadio extends BaseChoice { - use CanBeAutofocus; - use CanBeEnclosedByLabel; - use HasCheckedState; - use HasLabel; - use HasRequired; - use HasTabindex; - use HasValue; - - /** - * Value to be submitted when the radio is not checked. - * - * If set, an additional hidden input will be rendered with the same name as the radio and this value. - * - * This ensures that a value is always submitted for the radio, even when it is unchecked. - */ - private bool|float|int|string|Stringable|UnitEnum|null $uncheckedValue = null; - - /** - * Returns the array of HTML attributes for the element. - * - * @return array Attributes array assigned to the element. - * - * @phpstan-return mixed[] - */ - public function getAttributes(): array - { - return $this->buildAttributes(parent::getAttributes()); - } - - /** - * Set the value that should be submitted when the radio is not checked. - * - * @param bool|float|int|string|Stringable|UnitEnum|null $value Value to be submitted. - * - * @return static New instance with the updated `uncheckedValue` value. - */ - public function uncheckedValue(bool|float|int|string|Stringable|UnitEnum|null $value): static - { - $new = clone $this; - $new->uncheckedValue = $value; - - return $new; - } - /** * Returns the tag enumeration for the `` element. * @@ -108,68 +54,4 @@ protected function loadDefault(): array 'type' => [Type::RADIO], ] + parent::loadDefault(); } - - /** - * Renders the `` element with its attributes. - * - * @return string Rendered HTML for the `` element. - */ - protected function run(): string - { - /** @var string|null $id */ - $id = $this->getAttribute('id', null); - - $unchecked = ''; - - if ($this->uncheckedValue !== null) { - /** @phpstan-var string $name */ - $name = $this->getAttribute('name', ''); - - $unchecked = InputHidden::tag() - ->id(null) - ->name($name) - ->value($this->uncheckedValue) - ->render(); - } - - if ($this->notLabel || $this->label === '') { - return $this->buildElement('', ['{label}' => '', '{unchecked}' => $unchecked]); - } - - $labelTag = Label::tag()->attributes($this->labelAttributes); - - if ($this->enclosedByLabel === false) { - if (array_key_exists('for', $this->labelAttributes) === false) { - $labelTag = $labelTag->for($id); - } - - $labelTag = $labelTag->content($this->label); - - return $this->buildElement( - '', - [ - '{label}' => $labelTag, - '{unchecked}' => $unchecked, - ], - ); - } - - $labelTag = $labelTag - ->html( - "\n", - Html::element($this->getTag(), '', $this->getAttributes()), - "\n", - $this->label, - "\n", - ); - - return $this->buildElement( - '', - [ - '{tag}' => $labelTag, - '{label}' => '', - '{unchecked}' => $unchecked, - ], - ); - } } diff --git a/src/Form/Mixin/CanBeUnchecked.php b/src/Form/Mixin/CanBeUnchecked.php new file mode 100644 index 0000000..312014c --- /dev/null +++ b/src/Form/Mixin/CanBeUnchecked.php @@ -0,0 +1,51 @@ +uncheckedValue = $value; + + return $new; + } + + /** + * Get the value that should be submitted when the element is not checked. + * + * @return bool|float|int|string|Stringable|UnitEnum|null Value to be submitted. + */ + private function getUncheckedValue(): bool|float|int|string|Stringable|UnitEnum|null + { + return $this->uncheckedValue; + } +} diff --git a/src/Form/Mixin/HasLabel.php b/src/Form/Mixin/HasLabel.php deleted file mode 100644 index cd4ba2e..0000000 --- a/src/Form/Mixin/HasLabel.php +++ /dev/null @@ -1,155 +0,0 @@ -label('My Label'); - * ``` - * - * @param string $content The label content. - * - * @return static New instance with the updated `label` value. - */ - public function label(string $content): static - { - $new = clone $this; - $new->label = $content; - - return $new; - } - - /** - * Sets the label attributes. - * - * Usage example: - * ```php - * $element->labelAttributes(['class' => 'form-label']); - * ``` - * - * @param array $attributes The label attributes. - * - * @return static New instance with the updated `labelAttributes` value. - * - * @phpstan-param mixed[] $attributes - */ - public function labelAttributes(array $attributes): static - { - $new = clone $this; - $new->labelAttributes = $attributes; - - return $new; - } - - /** - * Sets the `class` attribute of the label. - * - * Usage example: - * ```php - * $element->labelClass('my-class'); - * $element->labelClass(Theme::PRIMARY); - * $element->labelClass( - * new class implements Stringable { - * public function __toString(): string - * { - * return 'stringable-class'; - * } - * }, - * ); - * $element->labelClass('another-class', true); - * $element->labelClass(null); - * ``` - * - * @param string|Stringable|UnitEnum|null $value CSS class value, or `null` to remove the attribute. - * @param bool $override Whether to override existing classes (`true`) or merge (`false`). - * - * @return static New instance with the updated `labelAttributes['class']` value. - */ - public function labelClass(string|Stringable|UnitEnum|null $value, bool $override = false): static - { - $new = clone $this; - - if ($value === null) { - unset($new->labelAttributes['class']); - } else { - CSSClass::add($new->labelAttributes, $value, $override); - } - - return $new; - } - - /** - * Sets the `for` attribute of the label. - * - * Usage example: - * ```php - * $element->labelFor('input-id'); - * $element->labelFor(null); - * ``` - * - * @param string|null $value The value of the `for` attribute. - * - * @return static New instance with the updated `labelAttributes['for']` value. - */ - public function labelFor(string|null $value): static - { - $new = clone $this; - $new->labelAttributes['for'] = $value; - - return $new; - } - - /** - * Disables the label rendering. - * - * Usage example: - * ```php - * $element->notLabel(); - * ``` - * - * @return static New instance with the updated `notLabel` value. - */ - public function notLabel(): static - { - $new = clone $this; - $new->notLabel = true; - - return $new; - } -} diff --git a/src/List/Attribute/HasReversed.php b/src/List/Attribute/HasReversed.php index 750d3a1..7357a98 100644 --- a/src/List/Attribute/HasReversed.php +++ b/src/List/Attribute/HasReversed.php @@ -7,9 +7,7 @@ /** * Provides an immutable API for the HTML `reversed` attribute. * - * @method static addAttribute(string|\UnitEnum $key, mixed $value) Adds an attribute and returns a new instance. - * {@see \UIAwesome\Html\Mixin\HasAttributes} for managing the underlying attributes array. - * + * @mixin \UIAwesome\Html\Mixin\HasAttributes * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/ol#reversed * * @copyright Copyright (C) 2026 Terabytesoftw. @@ -31,6 +29,6 @@ trait HasReversed */ public function reversed(bool $value): static { - return $this->addAttribute('reversed', $value); + return $this->setAttribute('reversed', $value); } } diff --git a/src/List/Attribute/HasStart.php b/src/List/Attribute/HasStart.php index 0fcb19d..d909b19 100644 --- a/src/List/Attribute/HasStart.php +++ b/src/List/Attribute/HasStart.php @@ -7,9 +7,7 @@ /** * Provides an immutable API for the HTML `start` attribute. * - * @method static addAttribute(string|\UnitEnum $key, mixed $value) Adds an attribute and returns a new instance. - * {@see \UIAwesome\Html\Mixin\HasAttributes} for managing the underlying attributes array. - * + * @mixin \UIAwesome\Html\Mixin\HasAttributes * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/ol#start * * @copyright Copyright (C) 2026 Terabytesoftw. @@ -32,6 +30,6 @@ trait HasStart */ public function start(int|null $value): static { - return $this->addAttribute('start', $value); + return $this->setAttribute('start', $value); } } diff --git a/src/Metadata/Attribute/HasAsync.php b/src/Metadata/Attribute/HasAsync.php index a9a4e0a..24a42ef 100644 --- a/src/Metadata/Attribute/HasAsync.php +++ b/src/Metadata/Attribute/HasAsync.php @@ -7,9 +7,7 @@ /** * Provides an immutable API for the HTML `async` attribute. * - * @method static addAttribute(string|\UnitEnum $key, mixed $value) Adds an attribute and returns a new instance. - * {@see \UIAwesome\Html\Mixin\HasAttributes} for managing the underlying attributes array. - * + * @mixin \UIAwesome\Html\Mixin\HasAttributes * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/script#async * * @copyright Copyright (C) 2026 Terabytesoftw. @@ -34,6 +32,6 @@ trait HasAsync */ public function async(bool $value): static { - return $this->addAttribute('async', $value); + return $this->setAttribute('async', $value); } } diff --git a/src/Metadata/Attribute/HasDefer.php b/src/Metadata/Attribute/HasDefer.php index 4ac5491..c57f6f8 100644 --- a/src/Metadata/Attribute/HasDefer.php +++ b/src/Metadata/Attribute/HasDefer.php @@ -7,9 +7,7 @@ /** * Provides an immutable API for the HTML `defer` attribute. * - * @method static addAttribute(string|\UnitEnum $key, mixed $value) Adds an attribute and returns a new instance. - * {@see \UIAwesome\Html\Mixin\HasAttributes} for managing the underlying attributes array. - * + * @mixin \UIAwesome\Html\Mixin\HasAttributes * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/script#defer * * @copyright Copyright (C) 2026 Terabytesoftw. @@ -34,6 +32,6 @@ trait HasDefer */ public function defer(bool $value): static { - return $this->addAttribute('defer', $value); + return $this->setAttribute('defer', $value); } } diff --git a/src/Metadata/Attribute/HasNomodule.php b/src/Metadata/Attribute/HasNomodule.php index 5b57509..bbc9737 100644 --- a/src/Metadata/Attribute/HasNomodule.php +++ b/src/Metadata/Attribute/HasNomodule.php @@ -7,9 +7,7 @@ /** * Provides an immutable API for the HTML `nomodule` attribute. * - * @method static addAttribute(string|\UnitEnum $key, mixed $value) Adds an attribute and returns a new instance. - * {@see \UIAwesome\Html\Mixin\HasAttributes} for managing the underlying attributes array. - * + * @mixin \UIAwesome\Html\Mixin\HasAttributes * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/script#nomodule * * @copyright Copyright (C) 2026 Terabytesoftw. @@ -34,6 +32,6 @@ trait HasNomodule */ public function nomodule(bool $value): static { - return $this->addAttribute('nomodule', $value); + return $this->setAttribute('nomodule', $value); } } diff --git a/src/Metadata/Attribute/HasShadowRootClonable.php b/src/Metadata/Attribute/HasShadowRootClonable.php index 80b7c01..7bc0124 100644 --- a/src/Metadata/Attribute/HasShadowRootClonable.php +++ b/src/Metadata/Attribute/HasShadowRootClonable.php @@ -7,9 +7,7 @@ /** * Provides an immutable API for the HTML `shadowrootclonable` attribute. * - * @method static addAttribute(string|\UnitEnum $key, mixed $value) Adds an attribute and returns a new instance. - * {@see \UIAwesome\Html\Mixin\HasAttributes} for managing the underlying attributes array. - * + * @mixin \UIAwesome\Html\Mixin\HasAttributes * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/template#shadowrootclonable * * @copyright Copyright (C) 2026 Terabytesoftw. @@ -33,6 +31,6 @@ trait HasShadowRootClonable */ public function shadowRootClonable(bool $value): static { - return $this->addAttribute('shadowrootclonable', $value); + return $this->setAttribute('shadowrootclonable', $value); } } diff --git a/src/Metadata/Attribute/HasShadowRootDelegatesFocus.php b/src/Metadata/Attribute/HasShadowRootDelegatesFocus.php index 851a459..bcc0342 100644 --- a/src/Metadata/Attribute/HasShadowRootDelegatesFocus.php +++ b/src/Metadata/Attribute/HasShadowRootDelegatesFocus.php @@ -7,9 +7,7 @@ /** * Provides an immutable API for the HTML `shadowrootdelegatesfocus` attribute. * - * @method static addAttribute(string|\UnitEnum $key, mixed $value) Adds an attribute and returns a new instance. - * {@see \UIAwesome\Html\Mixin\HasAttributes} for managing the underlying attributes array. - * + * @mixin \UIAwesome\Html\Mixin\HasAttributes * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/template#shadowrootdelegatesfocus * * @copyright Copyright (C) 2026 Terabytesoftw. @@ -33,6 +31,6 @@ trait HasShadowRootDelegatesFocus */ public function shadowRootDelegatesFocus(bool $value): static { - return $this->addAttribute('shadowrootdelegatesfocus', $value); + return $this->setAttribute('shadowrootdelegatesfocus', $value); } } diff --git a/src/Metadata/Attribute/HasShadowRootMode.php b/src/Metadata/Attribute/HasShadowRootMode.php index 3f1349d..33b3ace 100644 --- a/src/Metadata/Attribute/HasShadowRootMode.php +++ b/src/Metadata/Attribute/HasShadowRootMode.php @@ -12,9 +12,7 @@ /** * Provides an immutable API for the HTML `shadowrootmode` attribute. * - * @method static addAttribute(string|UnitEnum $key, mixed $value) Adds an attribute and returns a new instance. - * {@see \UIAwesome\Html\Mixin\HasAttributes} for managing the underlying attributes array. - * + * @mixin \UIAwesome\Html\Mixin\HasAttributes * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/template#shadowrootmode * * @copyright Copyright (C) 2026 Terabytesoftw. @@ -44,6 +42,6 @@ public function shadowRootMode(string|UnitEnum|null $value): static { Validator::oneOf($value, ShadowRootMode::cases(), 'shadowrootmode'); - return $this->addAttribute('shadowrootmode', $value); + return $this->setAttribute('shadowrootmode', $value); } } diff --git a/src/Metadata/Attribute/HasShadowRootReferenceTarget.php b/src/Metadata/Attribute/HasShadowRootReferenceTarget.php index 28c0734..49b5e25 100644 --- a/src/Metadata/Attribute/HasShadowRootReferenceTarget.php +++ b/src/Metadata/Attribute/HasShadowRootReferenceTarget.php @@ -10,9 +10,7 @@ /** * Provides an immutable API for the HTML `shadowrootreferencetarget` attribute. * - * @method static addAttribute(string|UnitEnum $key, mixed $value) Adds an attribute and returns a new instance. - * {@see \UIAwesome\Html\Mixin\HasAttributes} for managing the underlying attributes array. - * + * @mixin \UIAwesome\Html\Mixin\HasAttributes * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/template#shadowrootreferencetarget * * @copyright Copyright (C) 2026 Terabytesoftw. @@ -36,6 +34,6 @@ trait HasShadowRootReferenceTarget */ public function shadowRootReferenceTarget(string|Stringable|UnitEnum|null $value): static { - return $this->addAttribute('shadowrootreferencetarget', $value); + return $this->setAttribute('shadowrootreferencetarget', $value); } } diff --git a/src/Metadata/Attribute/HasShadowRootSerializable.php b/src/Metadata/Attribute/HasShadowRootSerializable.php index 18c98f9..083f094 100644 --- a/src/Metadata/Attribute/HasShadowRootSerializable.php +++ b/src/Metadata/Attribute/HasShadowRootSerializable.php @@ -7,9 +7,7 @@ /** * Provides an immutable API for the HTML `shadowrootserializable` attribute. * - * @method static addAttribute(string|\UnitEnum $key, mixed $value) Adds an attribute and returns a new instance. - * {@see \UIAwesome\Html\Mixin\HasAttributes} for managing the underlying attributes array. - * + * @mixin \UIAwesome\Html\Mixin\HasAttributes * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/template#shadowrootserializable * * @copyright Copyright (C) 2026 Terabytesoftw. @@ -33,6 +31,6 @@ trait HasShadowRootSerializable */ public function shadowRootSerializable(bool $value): static { - return $this->addAttribute('shadowrootserializable', $value); + return $this->setAttribute('shadowrootserializable', $value); } } diff --git a/src/Phrasing/Label.php b/src/Phrasing/Label.php index 1ff91cd..492f986 100644 --- a/src/Phrasing/Label.php +++ b/src/Phrasing/Label.php @@ -41,7 +41,7 @@ final class Label extends BaseInline */ public function for(string|null $value = null): static { - return $this->addAttribute('for', $value); + return $this->setAttribute('for', $value); } /** diff --git a/tests/Embedded/ImgTest.php b/tests/Embedded/ImgTest.php index 1f1e4d8..c9c6853 100644 --- a/tests/Embedded/ImgTest.php +++ b/tests/Embedded/ImgTest.php @@ -60,7 +60,7 @@ public function testGetAttributesReturnsAssignedAttributes(): void self::assertSame( ['data-test' => 'value'], Img::tag() - ->addAttribute('data-test', 'value') + ->setAttribute('data-test', 'value') ->getAttributes(), "Failed asserting that 'getAttributes()' returns the assigned attributes.", ); @@ -105,32 +105,6 @@ public function testRenderWithAddAriaAttributeUsingEnum(): void ); } - public function testRenderWithAddAttribute(): void - { - self::assertSame( - << - HTML, - Img::tag() - ->addAttribute('data-test', 'value') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method.", - ); - } - - public function testRenderWithAddAttributeUsingEnum(): void - { - self::assertSame( - << - HTML, - Img::tag() - ->addAttribute(GlobalAttribute::TITLE, 'value') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", - ); - } - public function testRenderWithAddDataAttribute(): void { self::assertSame( @@ -557,7 +531,7 @@ public function testRenderWithRemoveAttribute(): void HTML, Img::tag() - ->addAttribute('data-test', 'value') + ->setAttribute('data-test', 'value') ->removeAttribute('data-test') ->render(), "Failed asserting that element renders correctly with 'removeAttribute()' method.", @@ -604,6 +578,32 @@ public function testRenderWithRoleUsingEnum(): void ); } + public function testRenderWithSetAttribute(): void + { + self::assertSame( + << + HTML, + Img::tag() + ->setAttribute('data-test', 'value') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method.", + ); + } + + public function testRenderWithSetAttributeUsingEnum(): void + { + self::assertSame( + << + HTML, + Img::tag() + ->setAttribute(GlobalAttribute::TITLE, 'value') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method using enum.", + ); + } + public function testRenderWithSizes(): void { self::assertSame( diff --git a/tests/Flow/DivTest.php b/tests/Flow/DivTest.php index 547b908..bd1c6eb 100644 --- a/tests/Flow/DivTest.php +++ b/tests/Flow/DivTest.php @@ -61,7 +61,7 @@ public function testGetAttributesReturnsAssignedAttributes(): void self::assertSame( ['data-test' => 'value'], Div::tag() - ->addAttribute('data-test', 'value') + ->setAttribute('data-test', 'value') ->getAttributes(), "Failed asserting that 'getAttributes()' returns the assigned attributes.", ); @@ -124,34 +124,6 @@ public function testRenderWithAddAriaAttributeUsingEnum(): void ); } - public function testRenderWithAddAttribute(): void - { - self::assertSame( - << - - HTML, - Div::tag() - ->addAttribute('data-test', 'value') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method.", - ); - } - - public function testRenderWithAddAttributeUsingEnum(): void - { - self::assertSame( - << - - HTML, - Div::tag() - ->addAttribute(GlobalAttribute::TITLE, 'value') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", - ); - } - public function testRenderWithAddDataAttribute(): void { self::assertSame( @@ -507,7 +479,7 @@ public function testRenderWithRemoveAttribute(): void HTML, Div::tag() - ->addAttribute('data-test', 'value') + ->setAttribute('data-test', 'value') ->removeAttribute('data-test') ->render(), "Failed asserting that element renders correctly with 'removeAttribute()' method.", @@ -557,6 +529,34 @@ public function testRenderWithRoleUsingEnum(): void ); } + public function testRenderWithSetAttribute(): void + { + self::assertSame( + << + + HTML, + Div::tag() + ->setAttribute('data-test', 'value') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method.", + ); + } + + public function testRenderWithSetAttributeUsingEnum(): void + { + self::assertSame( + << + + HTML, + Div::tag() + ->setAttribute(GlobalAttribute::TITLE, 'value') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method using enum.", + ); + } + public function testRenderWithSpellcheck(): void { self::assertSame( diff --git a/tests/Flow/HrTest.php b/tests/Flow/HrTest.php index b7fb0f4..ff93253 100644 --- a/tests/Flow/HrTest.php +++ b/tests/Flow/HrTest.php @@ -48,7 +48,7 @@ public function testGetAttributesReturnsAssignedAttributes(): void self::assertSame( ['data-test' => 'value'], Hr::tag() - ->addAttribute('data-test', 'value') + ->setAttribute('data-test', 'value') ->getAttributes(), "Failed asserting that 'getAttributes()' returns the assigned attributes.", ); @@ -93,32 +93,6 @@ public function testRenderWithAddAriaAttributeUsingEnum(): void ); } - public function testRenderWithAddAttribute(): void - { - self::assertSame( - << - HTML, - Hr::tag() - ->addAttribute('data-test', 'value') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method.", - ); - } - - public function testRenderWithAddAttributeUsingEnum(): void - { - self::assertSame( - << - HTML, - Hr::tag() - ->addAttribute(GlobalAttribute::TITLE, 'value') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", - ); - } - public function testRenderWithAddDataAttribute(): void { self::assertSame( @@ -350,7 +324,7 @@ public function testRenderWithRemoveAttribute(): void
HTML, Hr::tag() - ->addAttribute('data-test', 'value') + ->setAttribute('data-test', 'value') ->removeAttribute('data-test') ->render(), "Failed asserting that element renders correctly with 'removeAttribute()' method.", @@ -397,6 +371,32 @@ public function testRenderWithRoleUsingEnum(): void ); } + public function testRenderWithSetAttribute(): void + { + self::assertSame( + << + HTML, + Hr::tag() + ->setAttribute('data-test', 'value') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method.", + ); + } + + public function testRenderWithSetAttributeUsingEnum(): void + { + self::assertSame( + << + HTML, + Hr::tag() + ->setAttribute(GlobalAttribute::TITLE, 'value') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method using enum.", + ); + } + public function testRenderWithStyle(): void { self::assertSame( diff --git a/tests/Flow/MainTest.php b/tests/Flow/MainTest.php index 6556b8a..39ca699 100644 --- a/tests/Flow/MainTest.php +++ b/tests/Flow/MainTest.php @@ -61,7 +61,7 @@ public function testGetAttributesReturnsAssignedAttributes(): void self::assertSame( ['data-test' => 'value'], Main::tag() - ->addAttribute('data-test', 'value') + ->setAttribute('data-test', 'value') ->getAttributes(), "Failed asserting that 'getAttributes()' returns the assigned attributes.", ); @@ -124,34 +124,6 @@ public function testRenderWithAddAriaAttributeUsingEnum(): void ); } - public function testRenderWithAddAttribute(): void - { - self::assertSame( - << - - HTML, - Main::tag() - ->addAttribute('data-test', 'value') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method.", - ); - } - - public function testRenderWithAddAttributeUsingEnum(): void - { - self::assertSame( - << - - HTML, - Main::tag() - ->addAttribute(GlobalAttribute::TITLE, 'value') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", - ); - } - public function testRenderWithAddDataAttribute(): void { self::assertSame( @@ -507,7 +479,7 @@ public function testRenderWithRemoveAttribute(): void HTML, Main::tag() - ->addAttribute('data-test', 'value') + ->setAttribute('data-test', 'value') ->removeAttribute('data-test') ->render(), "Failed asserting that element renders correctly with 'removeAttribute()' method.", @@ -557,6 +529,34 @@ public function testRenderWithRoleUsingEnum(): void ); } + public function testRenderWithSetAttribute(): void + { + self::assertSame( + << + + HTML, + Main::tag() + ->setAttribute('data-test', 'value') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method.", + ); + } + + public function testRenderWithSetAttributeUsingEnum(): void + { + self::assertSame( + << + + HTML, + Main::tag() + ->setAttribute(GlobalAttribute::TITLE, 'value') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method using enum.", + ); + } + public function testRenderWithSpellcheck(): void { self::assertSame( diff --git a/tests/Flow/PTest.php b/tests/Flow/PTest.php index 3b90694..cb5ba85 100644 --- a/tests/Flow/PTest.php +++ b/tests/Flow/PTest.php @@ -61,7 +61,7 @@ public function testGetAttributesReturnsAssignedAttributes(): void self::assertSame( ['data-test' => 'value'], P::tag() - ->addAttribute('data-test', 'value') + ->setAttribute('data-test', 'value') ->getAttributes(), "Failed asserting that 'getAttributes()' returns the assigned attributes.", ); @@ -124,34 +124,6 @@ public function testRenderWithAddAriaAttributeUsingEnum(): void ); } - public function testRenderWithAddAttribute(): void - { - self::assertSame( - << -

- HTML, - P::tag() - ->addAttribute('data-test', 'value') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method.", - ); - } - - public function testRenderWithAddAttributeUsingEnum(): void - { - self::assertSame( - << -

- HTML, - P::tag() - ->addAttribute(GlobalAttribute::TITLE, 'value') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", - ); - } - public function testRenderWithAddDataAttribute(): void { self::assertSame( @@ -507,7 +479,7 @@ public function testRenderWithRemoveAttribute(): void

HTML, P::tag() - ->addAttribute('data-test', 'value') + ->setAttribute('data-test', 'value') ->removeAttribute('data-test') ->render(), "Failed asserting that element renders correctly with 'removeAttribute()' method.", @@ -557,6 +529,34 @@ public function testRenderWithRoleUsingEnum(): void ); } + public function testRenderWithSetAttribute(): void + { + self::assertSame( + << +

+ HTML, + P::tag() + ->setAttribute('data-test', 'value') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method.", + ); + } + + public function testRenderWithSetAttributeUsingEnum(): void + { + self::assertSame( + << +

+ HTML, + P::tag() + ->setAttribute(GlobalAttribute::TITLE, 'value') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method using enum.", + ); + } + public function testRenderWithSpellcheck(): void { self::assertSame( diff --git a/tests/Form/InputCheckboxTest.php b/tests/Form/InputCheckboxTest.php index e87778b..3bfde27 100644 --- a/tests/Form/InputCheckboxTest.php +++ b/tests/Form/InputCheckboxTest.php @@ -187,34 +187,6 @@ public function testRenderWithAddAriaDescribedByTrueStringValueAndPrefixSuffix() ); } - public function testRenderWithAddAttribute(): void - { - self::assertSame( - << - HTML, - InputCheckbox::tag() - ->addAttribute('data-test', 'value') - ->id('inputcheckbox') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method.", - ); - } - - public function testRenderWithAddAttributeUsingEnum(): void - { - self::assertSame( - << - HTML, - InputCheckbox::tag() - ->addAttribute(GlobalAttribute::TITLE, 'Select checkbox') - ->id('inputcheckbox') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", - ); - } - public function testRenderWithAddDataAttribute(): void { self::assertSame( @@ -739,7 +711,7 @@ public function testRenderWithLabelClassNullValue(): void self::assertSame( << - + HTML, InputCheckbox::tag() ->id('inputcheckbox') @@ -912,7 +884,7 @@ public function testRenderWithRemoveAttribute(): void HTML, InputCheckbox::tag() - ->addAttribute('data-test', 'value') + ->setAttribute('data-test', 'value') ->id('inputcheckbox') ->removeAttribute('data-test') ->render(), @@ -977,6 +949,34 @@ public function testRenderWithRoleUsingEnum(): void ); } + public function testRenderWithSetAttribute(): void + { + self::assertSame( + << + HTML, + InputCheckbox::tag() + ->setAttribute('data-test', 'value') + ->id('inputcheckbox') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method.", + ); + } + + public function testRenderWithSetAttributeUsingEnum(): void + { + self::assertSame( + << + HTML, + InputCheckbox::tag() + ->setAttribute(GlobalAttribute::TITLE, 'Select checkbox') + ->id('inputcheckbox') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method using enum.", + ); + } + public function testRenderWithStyle(): void { self::assertSame( diff --git a/tests/Form/InputHiddenTest.php b/tests/Form/InputHiddenTest.php index 6d7ab8a..ebdd652 100644 --- a/tests/Form/InputHiddenTest.php +++ b/tests/Form/InputHiddenTest.php @@ -179,34 +179,6 @@ public function testRenderWithAddAriaDescribedByTrueStringValueAndPrefixSuffix() ); } - public function testRenderWithAddAttribute(): void - { - self::assertSame( - << - HTML, - InputHidden::tag() - ->addAttribute('data-test', 'value') - ->id('inputhidden') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method.", - ); - } - - public function testRenderWithAddAttributeUsingEnum(): void - { - self::assertSame( - << - HTML, - InputHidden::tag() - ->addAttribute(GlobalAttribute::TITLE, 'Hidden input') - ->id('inputhidden') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", - ); - } - public function testRenderWithAddDataAttribute(): void { self::assertSame( @@ -603,7 +575,7 @@ public function testRenderWithRemoveAttribute(): void HTML, InputHidden::tag() ->id('inputhidden') - ->addAttribute('data-test', 'value') + ->setAttribute('data-test', 'value') ->removeAttribute('data-test') ->render(), "Failed asserting that element renders correctly with 'removeAttribute()' method.", @@ -653,6 +625,34 @@ public function testRenderWithRoleUsingEnum(): void ); } + public function testRenderWithSetAttribute(): void + { + self::assertSame( + << + HTML, + InputHidden::tag() + ->setAttribute('data-test', 'value') + ->id('inputhidden') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method.", + ); + } + + public function testRenderWithSetAttributeUsingEnum(): void + { + self::assertSame( + << + HTML, + InputHidden::tag() + ->setAttribute(GlobalAttribute::TITLE, 'Hidden input') + ->id('inputhidden') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method using enum.", + ); + } + public function testRenderWithStyle(): void { self::assertSame( diff --git a/tests/Form/InputImageTest.php b/tests/Form/InputImageTest.php index 2d59a6f..60795bf 100644 --- a/tests/Form/InputImageTest.php +++ b/tests/Form/InputImageTest.php @@ -181,34 +181,6 @@ public function testRenderWithAddAriaDescribedByTrueStringValueAndPrefixSuffix() ); } - public function testRenderWithAddAttribute(): void - { - self::assertSame( - << - HTML, - InputImage::tag() - ->addAttribute('data-test', 'value') - ->id('inputimage') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method.", - ); - } - - public function testRenderWithAddAttributeUsingEnum(): void - { - self::assertSame( - << - HTML, - InputImage::tag() - ->addAttribute(GlobalAttribute::TITLE, 'Select image') - ->id('inputimage') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", - ); - } - public function testRenderWithAddDataAttribute(): void { self::assertSame( @@ -674,7 +646,7 @@ public function testRenderWithRemoveAttribute(): void HTML, InputImage::tag() - ->addAttribute('data-test', 'value') + ->setAttribute('data-test', 'value') ->id('inputimage') ->removeAttribute('data-test') ->render(), @@ -725,6 +697,34 @@ public function testRenderWithRoleUsingEnum(): void ); } + public function testRenderWithSetAttribute(): void + { + self::assertSame( + << + HTML, + InputImage::tag() + ->setAttribute('data-test', 'value') + ->id('inputimage') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method.", + ); + } + + public function testRenderWithSetAttributeUsingEnum(): void + { + self::assertSame( + << + HTML, + InputImage::tag() + ->setAttribute(GlobalAttribute::TITLE, 'Select image') + ->id('inputimage') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method using enum.", + ); + } + public function testRenderWithSrc(): void { self::assertSame( diff --git a/tests/Form/InputMonthTest.php b/tests/Form/InputMonthTest.php index 24e94df..4bee7db 100644 --- a/tests/Form/InputMonthTest.php +++ b/tests/Form/InputMonthTest.php @@ -180,34 +180,6 @@ public function testRenderWithAddAriaDescribedByTrueStringValueAndPrefixSuffix() ); } - public function testRenderWithAddAttribute(): void - { - self::assertSame( - << - HTML, - InputMonth::tag() - ->addAttribute('data-test', 'value') - ->id('inputmonth') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method.", - ); - } - - public function testRenderWithAddAttributeUsingEnum(): void - { - self::assertSame( - << - HTML, - InputMonth::tag() - ->addAttribute(GlobalAttribute::TITLE, 'Select month') - ->id('inputmonth') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", - ); - } - public function testRenderWithAddDataAttribute(): void { self::assertSame( @@ -688,7 +660,7 @@ public function testRenderWithRemoveAttribute(): void HTML, InputMonth::tag() - ->addAttribute('data-test', 'value') + ->setAttribute('data-test', 'value') ->id('inputmonth') ->removeAttribute('data-test') ->render(), @@ -753,6 +725,34 @@ public function testRenderWithRoleUsingEnum(): void ); } + public function testRenderWithSetAttribute(): void + { + self::assertSame( + << + HTML, + InputMonth::tag() + ->setAttribute('data-test', 'value') + ->id('inputmonth') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method.", + ); + } + + public function testRenderWithSetAttributeUsingEnum(): void + { + self::assertSame( + << + HTML, + InputMonth::tag() + ->setAttribute(GlobalAttribute::TITLE, 'Select month') + ->id('inputmonth') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method using enum.", + ); + } + public function testRenderWithStep(): void { self::assertSame( diff --git a/tests/Form/InputNumberTest.php b/tests/Form/InputNumberTest.php index 6742a33..f4ea285 100644 --- a/tests/Form/InputNumberTest.php +++ b/tests/Form/InputNumberTest.php @@ -181,34 +181,6 @@ public function testRenderWithAddAriaDescribedByTrueStringValueAndPrefixSuffix() ); } - public function testRenderWithAddAttribute(): void - { - self::assertSame( - << - HTML, - InputNumber::tag() - ->addAttribute('data-test', 'value') - ->id('inputnumber') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method.", - ); - } - - public function testRenderWithAddAttributeUsingEnum(): void - { - self::assertSame( - << - HTML, - InputNumber::tag() - ->addAttribute(GlobalAttribute::TITLE, 'Select number') - ->id('inputnumber') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", - ); - } - public function testRenderWithAddDataAttribute(): void { self::assertSame( @@ -703,7 +675,7 @@ public function testRenderWithRemoveAttribute(): void HTML, InputNumber::tag() - ->addAttribute('data-test', 'value') + ->setAttribute('data-test', 'value') ->id('inputnumber') ->removeAttribute('data-test') ->render(), @@ -768,6 +740,34 @@ public function testRenderWithRoleUsingEnum(): void ); } + public function testRenderWithSetAttribute(): void + { + self::assertSame( + << + HTML, + InputNumber::tag() + ->setAttribute('data-test', 'value') + ->id('inputnumber') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method.", + ); + } + + public function testRenderWithSetAttributeUsingEnum(): void + { + self::assertSame( + << + HTML, + InputNumber::tag() + ->setAttribute(GlobalAttribute::TITLE, 'Select number') + ->id('inputnumber') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method using enum.", + ); + } + public function testRenderWithStep(): void { self::assertSame( diff --git a/tests/Form/InputPasswordTest.php b/tests/Form/InputPasswordTest.php index 153c9db..27c3d97 100644 --- a/tests/Form/InputPasswordTest.php +++ b/tests/Form/InputPasswordTest.php @@ -191,34 +191,6 @@ public function testRenderWithAddAriaDescribedByTrueStringValueAndPrefixSuffix() ); } - public function testRenderWithAddAttribute(): void - { - self::assertSame( - << - HTML, - InputPassword::tag() - ->addAttribute('data-test', 'value') - ->id('inputpassword') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method.", - ); - } - - public function testRenderWithAddAttributeUsingEnum(): void - { - self::assertSame( - << - HTML, - InputPassword::tag() - ->addAttribute(GlobalAttribute::TITLE, 'Enter password') - ->id('inputpassword') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", - ); - } - public function testRenderWithAddDataAttribute(): void { self::assertSame( @@ -727,7 +699,7 @@ public function testRenderWithRemoveAttribute(): void HTML, InputPassword::tag() ->id('inputpassword') - ->addAttribute('data-test', 'value') + ->setAttribute('data-test', 'value') ->removeAttribute('data-test') ->render(), "Failed asserting that element renders correctly with 'removeAttribute()' method.", @@ -791,6 +763,34 @@ public function testRenderWithRoleUsingEnum(): void ); } + public function testRenderWithSetAttribute(): void + { + self::assertSame( + << + HTML, + InputPassword::tag() + ->setAttribute('data-test', 'value') + ->id('inputpassword') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method.", + ); + } + + public function testRenderWithSetAttributeUsingEnum(): void + { + self::assertSame( + << + HTML, + InputPassword::tag() + ->setAttribute(GlobalAttribute::TITLE, 'Enter password') + ->id('inputpassword') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method using enum.", + ); + } + public function testRenderWithSize(): void { self::assertSame( diff --git a/tests/Form/InputRadioTest.php b/tests/Form/InputRadioTest.php index 5cf0d25..1e91026 100644 --- a/tests/Form/InputRadioTest.php +++ b/tests/Form/InputRadioTest.php @@ -189,34 +189,6 @@ public function testRenderWithAddAriaDescribedByTrueStringValueAndPrefixSuffix() ); } - public function testRenderWithAddAttribute(): void - { - self::assertSame( - << - HTML, - InputRadio::tag() - ->addAttribute('data-test', 'value') - ->id('inputradio') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method.", - ); - } - - public function testRenderWithAddAttributeUsingEnum(): void - { - self::assertSame( - << - HTML, - InputRadio::tag() - ->addAttribute(GlobalAttribute::TITLE, 'Select radio') - ->id('inputradio') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", - ); - } - public function testRenderWithAddDataAttribute(): void { self::assertSame( @@ -748,7 +720,7 @@ public function testRenderWithLabelClassNullValue(): void self::assertSame( << - + HTML, InputRadio::tag() ->id('inputradio') @@ -921,7 +893,7 @@ public function testRenderWithRemoveAttribute(): void HTML, InputRadio::tag() - ->addAttribute('data-test', 'value') + ->setAttribute('data-test', 'value') ->id('inputradio') ->removeAttribute('data-test') ->render(), @@ -986,6 +958,34 @@ public function testRenderWithRoleUsingEnum(): void ); } + public function testRenderWithSetAttribute(): void + { + self::assertSame( + << + HTML, + InputRadio::tag() + ->setAttribute('data-test', 'value') + ->id('inputradio') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method.", + ); + } + + public function testRenderWithSetAttributeUsingEnum(): void + { + self::assertSame( + << + HTML, + InputRadio::tag() + ->setAttribute(GlobalAttribute::TITLE, 'Select radio') + ->id('inputradio') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method using enum.", + ); + } + public function testRenderWithStyle(): void { self::assertSame( diff --git a/tests/Form/InputRangeTest.php b/tests/Form/InputRangeTest.php index 5cd4e9c..f8c91fc 100644 --- a/tests/Form/InputRangeTest.php +++ b/tests/Form/InputRangeTest.php @@ -180,34 +180,6 @@ public function testRenderWithAddAriaDescribedByTrueStringValueAndPrefixSuffix() ); } - public function testRenderWithAddAttribute(): void - { - self::assertSame( - << - HTML, - InputRange::tag() - ->addAttribute('data-test', 'value') - ->id('inputrange') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method.", - ); - } - - public function testRenderWithAddAttributeUsingEnum(): void - { - self::assertSame( - << - HTML, - InputRange::tag() - ->addAttribute(GlobalAttribute::TITLE, 'Select range') - ->id('inputrange') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", - ); - } - public function testRenderWithAddDataAttribute(): void { self::assertSame( @@ -674,7 +646,7 @@ public function testRenderWithRemoveAttribute(): void HTML, InputRange::tag() - ->addAttribute('data-test', 'value') + ->setAttribute('data-test', 'value') ->id('inputrange') ->removeAttribute('data-test') ->render(), @@ -725,6 +697,34 @@ public function testRenderWithRoleUsingEnum(): void ); } + public function testRenderWithSetAttribute(): void + { + self::assertSame( + << + HTML, + InputRange::tag() + ->setAttribute('data-test', 'value') + ->id('inputrange') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method.", + ); + } + + public function testRenderWithSetAttributeUsingEnum(): void + { + self::assertSame( + << + HTML, + InputRange::tag() + ->setAttribute(GlobalAttribute::TITLE, 'Select range') + ->id('inputrange') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method using enum.", + ); + } + public function testRenderWithStep(): void { self::assertSame( diff --git a/tests/Form/InputResetTest.php b/tests/Form/InputResetTest.php index 14c115b..b14f9fe 100644 --- a/tests/Form/InputResetTest.php +++ b/tests/Form/InputResetTest.php @@ -180,34 +180,6 @@ public function testRenderWithAddAriaDescribedByTrueStringValueAndPrefixSuffix() ); } - public function testRenderWithAddAttribute(): void - { - self::assertSame( - << - HTML, - InputReset::tag() - ->addAttribute('data-test', 'value') - ->id('inputreset') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method.", - ); - } - - public function testRenderWithAddAttributeUsingEnum(): void - { - self::assertSame( - << - HTML, - InputReset::tag() - ->addAttribute(GlobalAttribute::TITLE, 'Reset form') - ->id('inputreset') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", - ); - } - public function testRenderWithAddDataAttribute(): void { self::assertSame( @@ -575,7 +547,7 @@ public function testRenderWithRemoveAttribute(): void HTML, InputReset::tag() - ->addAttribute('data-test', 'value') + ->setAttribute('data-test', 'value') ->id('inputreset') ->removeAttribute('data-test') ->render(), @@ -626,6 +598,34 @@ public function testRenderWithRoleUsingEnum(): void ); } + public function testRenderWithSetAttribute(): void + { + self::assertSame( + << + HTML, + InputReset::tag() + ->setAttribute('data-test', 'value') + ->id('inputreset') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method.", + ); + } + + public function testRenderWithSetAttributeUsingEnum(): void + { + self::assertSame( + << + HTML, + InputReset::tag() + ->setAttribute(GlobalAttribute::TITLE, 'Reset form') + ->id('inputreset') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method using enum.", + ); + } + public function testRenderWithStyle(): void { self::assertSame( diff --git a/tests/Form/InputSearchTest.php b/tests/Form/InputSearchTest.php index 0822a8e..4921a86 100644 --- a/tests/Form/InputSearchTest.php +++ b/tests/Form/InputSearchTest.php @@ -181,31 +181,6 @@ public function testRenderWithAddAriaDescribedByTrueStringValueAndPrefixSuffix() ); } - public function testRenderWithAddAttribute(): void - { - self::assertSame( - << - HTML, - InputSearch::tag() - ->addAttribute('data-test', 'value') - ->id('inputsearch') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method.", - ); - } - - public function testRenderWithAddAttributeUsingEnum(): void - { - self::assertSame( - << - HTML, - InputSearch::tag()->id('inputsearch')->addAttribute(GlobalAttribute::TITLE, 'Search here')->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", - ); - } - public function testRenderWithAddDataAttribute(): void { self::assertSame( @@ -634,7 +609,7 @@ public function testRenderWithRemoveAttribute(): void HTML, InputSearch::tag() ->id('inputsearch') - ->addAttribute('data-test', 'value') + ->setAttribute('data-test', 'value') ->removeAttribute('data-test') ->render(), "Failed asserting that element renders correctly with 'removeAttribute()' method.", @@ -689,6 +664,31 @@ public function testRenderWithRoleUsingEnum(): void ); } + public function testRenderWithSetAttribute(): void + { + self::assertSame( + << + HTML, + InputSearch::tag() + ->setAttribute('data-test', 'value') + ->id('inputsearch') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method.", + ); + } + + public function testRenderWithSetAttributeUsingEnum(): void + { + self::assertSame( + << + HTML, + InputSearch::tag()->id('inputsearch')->setAttribute(GlobalAttribute::TITLE, 'Search here')->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method using enum.", + ); + } + public function testRenderWithSize(): void { self::assertSame( diff --git a/tests/Form/InputSubmitTest.php b/tests/Form/InputSubmitTest.php index 5df585a..61fb795 100644 --- a/tests/Form/InputSubmitTest.php +++ b/tests/Form/InputSubmitTest.php @@ -180,34 +180,6 @@ public function testRenderWithAddAriaDescribedByTrueStringValueAndPrefixSuffix() ); } - public function testRenderWithAddAttribute(): void - { - self::assertSame( - << - HTML, - InputSubmit::tag() - ->addAttribute('data-test', 'value') - ->id('inputsubmit') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method.", - ); - } - - public function testRenderWithAddAttributeUsingEnum(): void - { - self::assertSame( - << - HTML, - InputSubmit::tag() - ->addAttribute(GlobalAttribute::TITLE, 'Submit action') - ->id('inputsubmit') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", - ); - } - public function testRenderWithAddDataAttribute(): void { self::assertSame( @@ -687,7 +659,7 @@ public function testRenderWithRemoveAttribute(): void HTML, InputSubmit::tag() - ->addAttribute('data-test', 'value') + ->setAttribute('data-test', 'value') ->id('inputsubmit') ->removeAttribute('data-test') ->render(), @@ -738,6 +710,34 @@ public function testRenderWithRoleUsingEnum(): void ); } + public function testRenderWithSetAttribute(): void + { + self::assertSame( + << + HTML, + InputSubmit::tag() + ->setAttribute('data-test', 'value') + ->id('inputsubmit') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method.", + ); + } + + public function testRenderWithSetAttributeUsingEnum(): void + { + self::assertSame( + << + HTML, + InputSubmit::tag() + ->setAttribute(GlobalAttribute::TITLE, 'Submit action') + ->id('inputsubmit') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method using enum.", + ); + } + public function testRenderWithStyle(): void { self::assertSame( diff --git a/tests/Form/InputTelTest.php b/tests/Form/InputTelTest.php index 0fd7133..d28403a 100644 --- a/tests/Form/InputTelTest.php +++ b/tests/Form/InputTelTest.php @@ -182,34 +182,6 @@ public function testRenderWithAddAriaDescribedByTrueStringValueAndPrefixSuffix() ); } - public function testRenderWithAddAttribute(): void - { - self::assertSame( - << - HTML, - InputTel::tag() - ->addAttribute('data-test', 'value') - ->id('inputtel') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method.", - ); - } - - public function testRenderWithAddAttributeUsingEnum(): void - { - self::assertSame( - << - HTML, - InputTel::tag() - ->addAttribute(GlobalAttribute::TITLE, 'Select phone') - ->id('inputtel') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", - ); - } - public function testRenderWithAddDataAttribute(): void { self::assertSame( @@ -703,7 +675,7 @@ public function testRenderWithRemoveAttribute(): void HTML, InputTel::tag() - ->addAttribute('data-test', 'value') + ->setAttribute('data-test', 'value') ->id('inputtel') ->removeAttribute('data-test') ->render(), @@ -768,6 +740,34 @@ public function testRenderWithRoleUsingEnum(): void ); } + public function testRenderWithSetAttribute(): void + { + self::assertSame( + << + HTML, + InputTel::tag() + ->setAttribute('data-test', 'value') + ->id('inputtel') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method.", + ); + } + + public function testRenderWithSetAttributeUsingEnum(): void + { + self::assertSame( + << + HTML, + InputTel::tag() + ->setAttribute(GlobalAttribute::TITLE, 'Select phone') + ->id('inputtel') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method using enum.", + ); + } + public function testRenderWithSize(): void { self::assertSame( diff --git a/tests/Form/InputTextTest.php b/tests/Form/InputTextTest.php index 5c898b8..63bcc44 100644 --- a/tests/Form/InputTextTest.php +++ b/tests/Form/InputTextTest.php @@ -181,34 +181,6 @@ public function testRenderWithAddAriaDescribedByTrueStringValueAndPrefixSuffix() ); } - public function testRenderWithAddAttribute(): void - { - self::assertSame( - << - HTML, - InputText::tag() - ->addAttribute('data-test', 'value') - ->id('inputtext') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method.", - ); - } - - public function testRenderWithAddAttributeUsingEnum(): void - { - self::assertSame( - << - HTML, - InputText::tag() - ->addAttribute(GlobalAttribute::TITLE, 'Enter text') - ->id('inputtext') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", - ); - } - public function testRenderWithAddDataAttribute(): void { self::assertSame( @@ -716,7 +688,7 @@ public function testRenderWithRemoveAttribute(): void HTML, InputText::tag() - ->addAttribute('data-test', 'value') + ->setAttribute('data-test', 'value') ->id('inputtext') ->removeAttribute('data-test') ->render(), @@ -781,6 +753,34 @@ public function testRenderWithRoleUsingEnum(): void ); } + public function testRenderWithSetAttribute(): void + { + self::assertSame( + << + HTML, + InputText::tag() + ->setAttribute('data-test', 'value') + ->id('inputtext') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method.", + ); + } + + public function testRenderWithSetAttributeUsingEnum(): void + { + self::assertSame( + << + HTML, + InputText::tag() + ->setAttribute(GlobalAttribute::TITLE, 'Enter text') + ->id('inputtext') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method using enum.", + ); + } + public function testRenderWithSize(): void { self::assertSame( diff --git a/tests/Form/InputTimeTest.php b/tests/Form/InputTimeTest.php index eee4e0c..7322fd1 100644 --- a/tests/Form/InputTimeTest.php +++ b/tests/Form/InputTimeTest.php @@ -180,34 +180,6 @@ public function testRenderWithAddAriaDescribedByTrueStringValueAndPrefixSuffix() ); } - public function testRenderWithAddAttribute(): void - { - self::assertSame( - << - HTML, - InputTime::tag() - ->addAttribute('data-test', 'value') - ->id('inputtime') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method.", - ); - } - - public function testRenderWithAddAttributeUsingEnum(): void - { - self::assertSame( - << - HTML, - InputTime::tag() - ->addAttribute(GlobalAttribute::TITLE, 'Select time') - ->id('inputtime') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", - ); - } - public function testRenderWithAddDataAttribute(): void { self::assertSame( @@ -688,7 +660,7 @@ public function testRenderWithRemoveAttribute(): void HTML, InputTime::tag() - ->addAttribute('data-test', 'value') + ->setAttribute('data-test', 'value') ->id('inputtime') ->removeAttribute('data-test') ->render(), @@ -753,6 +725,34 @@ public function testRenderWithRoleUsingEnum(): void ); } + public function testRenderWithSetAttribute(): void + { + self::assertSame( + << + HTML, + InputTime::tag() + ->setAttribute('data-test', 'value') + ->id('inputtime') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method.", + ); + } + + public function testRenderWithSetAttributeUsingEnum(): void + { + self::assertSame( + << + HTML, + InputTime::tag() + ->setAttribute(GlobalAttribute::TITLE, 'Select time') + ->id('inputtime') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method using enum.", + ); + } + public function testRenderWithStep(): void { self::assertSame( diff --git a/tests/Form/InputUrlTest.php b/tests/Form/InputUrlTest.php index 6de5081..44cd4a4 100644 --- a/tests/Form/InputUrlTest.php +++ b/tests/Form/InputUrlTest.php @@ -182,34 +182,6 @@ public function testRenderWithAddAriaDescribedByTrueStringValueAndPrefixSuffix() ); } - public function testRenderWithAddAttribute(): void - { - self::assertSame( - << - HTML, - InputUrl::tag() - ->addAttribute('data-test', 'value') - ->id('inputurl') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method.", - ); - } - - public function testRenderWithAddAttributeUsingEnum(): void - { - self::assertSame( - << - HTML, - InputUrl::tag() - ->addAttribute(GlobalAttribute::TITLE, 'Select url') - ->id('inputurl') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", - ); - } - public function testRenderWithAddDataAttribute(): void { self::assertSame( @@ -703,7 +675,7 @@ public function testRenderWithRemoveAttribute(): void HTML, InputUrl::tag() - ->addAttribute('data-test', 'value') + ->setAttribute('data-test', 'value') ->id('inputurl') ->removeAttribute('data-test') ->render(), @@ -768,6 +740,34 @@ public function testRenderWithRoleUsingEnum(): void ); } + public function testRenderWithSetAttribute(): void + { + self::assertSame( + << + HTML, + InputUrl::tag() + ->setAttribute('data-test', 'value') + ->id('inputurl') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method.", + ); + } + + public function testRenderWithSetAttributeUsingEnum(): void + { + self::assertSame( + << + HTML, + InputUrl::tag() + ->setAttribute(GlobalAttribute::TITLE, 'Select url') + ->id('inputurl') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method using enum.", + ); + } + public function testRenderWithSize(): void { self::assertSame( diff --git a/tests/Form/InputWeekTest.php b/tests/Form/InputWeekTest.php index 82491ef..2ee1b48 100644 --- a/tests/Form/InputWeekTest.php +++ b/tests/Form/InputWeekTest.php @@ -181,34 +181,6 @@ public function testRenderWithAddAriaDescribedByTrueStringValueAndPrefixSuffix() ); } - public function testRenderWithAddAttribute(): void - { - self::assertSame( - << - HTML, - InputWeek::tag() - ->addAttribute('data-test', 'value') - ->id('inputweek') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method.", - ); - } - - public function testRenderWithAddAttributeUsingEnum(): void - { - self::assertSame( - << - HTML, - InputWeek::tag() - ->addAttribute(GlobalAttribute::TITLE, 'Select week') - ->id('inputweek') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", - ); - } - public function testRenderWithAddDataAttribute(): void { self::assertSame( @@ -687,7 +659,7 @@ public function testRenderWithRemoveAttribute(): void HTML, InputWeek::tag() - ->addAttribute('data-test', 'value') + ->setAttribute('data-test', 'value') ->id('inputweek') ->removeAttribute('data-test') ->render(), @@ -752,6 +724,34 @@ public function testRenderWithRoleUsingEnum(): void ); } + public function testRenderWithSetAttribute(): void + { + self::assertSame( + << + HTML, + InputWeek::tag() + ->setAttribute('data-test', 'value') + ->id('inputweek') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method.", + ); + } + + public function testRenderWithSetAttributeUsingEnum(): void + { + self::assertSame( + << + HTML, + InputWeek::tag() + ->setAttribute(GlobalAttribute::TITLE, 'Select week') + ->id('inputweek') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method using enum.", + ); + } + public function testRenderWithStep(): void { self::assertSame( diff --git a/tests/Heading/H1Test.php b/tests/Heading/H1Test.php index ff07dc6..97fc106 100644 --- a/tests/Heading/H1Test.php +++ b/tests/Heading/H1Test.php @@ -61,7 +61,7 @@ public function testGetAttributesReturnsAssignedAttributes(): void self::assertSame( ['data-test' => 'value'], H1::tag() - ->addAttribute('data-test', 'value') + ->setAttribute('data-test', 'value') ->getAttributes(), "Failed asserting that 'getAttributes()' returns the assigned attributes.", ); @@ -124,34 +124,6 @@ public function testRenderWithAddAriaAttributeUsingEnum(): void ); } - public function testRenderWithAddAttribute(): void - { - self::assertSame( - << - - HTML, - H1::tag() - ->addAttribute('data-test', 'value') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method.", - ); - } - - public function testRenderWithAddAttributeUsingEnum(): void - { - self::assertSame( - << - - HTML, - H1::tag() - ->addAttribute(GlobalAttribute::TITLE, 'value') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", - ); - } - public function testRenderWithAddDataAttribute(): void { self::assertSame( @@ -507,7 +479,7 @@ public function testRenderWithRemoveAttribute(): void HTML, H1::tag() - ->addAttribute('data-test', 'value') + ->setAttribute('data-test', 'value') ->removeAttribute('data-test') ->render(), "Failed asserting that element renders correctly with 'removeAttribute()' method.", @@ -557,6 +529,34 @@ public function testRenderWithRoleUsingEnum(): void ); } + public function testRenderWithSetAttribute(): void + { + self::assertSame( + << + + HTML, + H1::tag() + ->setAttribute('data-test', 'value') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method.", + ); + } + + public function testRenderWithSetAttributeUsingEnum(): void + { + self::assertSame( + << + + HTML, + H1::tag() + ->setAttribute(GlobalAttribute::TITLE, 'value') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method using enum.", + ); + } + public function testRenderWithSpellcheck(): void { self::assertSame( diff --git a/tests/Heading/H2Test.php b/tests/Heading/H2Test.php index 9520107..19dd0bb 100644 --- a/tests/Heading/H2Test.php +++ b/tests/Heading/H2Test.php @@ -61,7 +61,7 @@ public function testGetAttributesReturnsAssignedAttributes(): void self::assertSame( ['data-test' => 'value'], H2::tag() - ->addAttribute('data-test', 'value') + ->setAttribute('data-test', 'value') ->getAttributes(), "Failed asserting that 'getAttributes()' returns the assigned attributes.", ); @@ -124,34 +124,6 @@ public function testRenderWithAddAriaAttributeUsingEnum(): void ); } - public function testRenderWithAddAttribute(): void - { - self::assertSame( - << - - HTML, - H2::tag() - ->addAttribute('data-test', 'value') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method.", - ); - } - - public function testRenderWithAddAttributeUsingEnum(): void - { - self::assertSame( - << - - HTML, - H2::tag() - ->addAttribute(GlobalAttribute::TITLE, 'value') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", - ); - } - public function testRenderWithAddDataAttribute(): void { self::assertSame( @@ -507,7 +479,7 @@ public function testRenderWithRemoveAttribute(): void HTML, H2::tag() - ->addAttribute('data-test', 'value') + ->setAttribute('data-test', 'value') ->removeAttribute('data-test') ->render(), "Failed asserting that element renders correctly with 'removeAttribute()' method.", @@ -557,6 +529,34 @@ public function testRenderWithRoleUsingEnum(): void ); } + public function testRenderWithSetAttribute(): void + { + self::assertSame( + << + + HTML, + H2::tag() + ->setAttribute('data-test', 'value') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method.", + ); + } + + public function testRenderWithSetAttributeUsingEnum(): void + { + self::assertSame( + << + + HTML, + H2::tag() + ->setAttribute(GlobalAttribute::TITLE, 'value') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method using enum.", + ); + } + public function testRenderWithSpellcheck(): void { self::assertSame( diff --git a/tests/Heading/H3Test.php b/tests/Heading/H3Test.php index 1896c43..3f3cdab 100644 --- a/tests/Heading/H3Test.php +++ b/tests/Heading/H3Test.php @@ -61,7 +61,7 @@ public function testGetAttributesReturnsAssignedAttributes(): void self::assertSame( ['data-test' => 'value'], H3::tag() - ->addAttribute('data-test', 'value') + ->setAttribute('data-test', 'value') ->getAttributes(), "Failed asserting that 'getAttributes()' returns the assigned attributes.", ); @@ -124,34 +124,6 @@ public function testRenderWithAddAriaAttributeUsingEnum(): void ); } - public function testRenderWithAddAttribute(): void - { - self::assertSame( - << - - HTML, - H3::tag() - ->addAttribute('data-test', 'value') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method.", - ); - } - - public function testRenderWithAddAttributeUsingEnum(): void - { - self::assertSame( - << - - HTML, - H3::tag() - ->addAttribute(GlobalAttribute::TITLE, 'value') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", - ); - } - public function testRenderWithAddDataAttribute(): void { self::assertSame( @@ -507,7 +479,7 @@ public function testRenderWithRemoveAttribute(): void HTML, H3::tag() - ->addAttribute('data-test', 'value') + ->setAttribute('data-test', 'value') ->removeAttribute('data-test') ->render(), "Failed asserting that element renders correctly with 'removeAttribute()' method.", @@ -557,6 +529,34 @@ public function testRenderWithRoleUsingEnum(): void ); } + public function testRenderWithSetAttribute(): void + { + self::assertSame( + << + + HTML, + H3::tag() + ->setAttribute('data-test', 'value') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method.", + ); + } + + public function testRenderWithSetAttributeUsingEnum(): void + { + self::assertSame( + << + + HTML, + H3::tag() + ->setAttribute(GlobalAttribute::TITLE, 'value') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method using enum.", + ); + } + public function testRenderWithSpellcheck(): void { self::assertSame( diff --git a/tests/Heading/H4Test.php b/tests/Heading/H4Test.php index f7e16a6..6ca1acf 100644 --- a/tests/Heading/H4Test.php +++ b/tests/Heading/H4Test.php @@ -61,7 +61,7 @@ public function testGetAttributesReturnsAssignedAttributes(): void self::assertSame( ['data-test' => 'value'], H4::tag() - ->addAttribute('data-test', 'value') + ->setAttribute('data-test', 'value') ->getAttributes(), "Failed asserting that 'getAttributes()' returns the assigned attributes.", ); @@ -124,34 +124,6 @@ public function testRenderWithAddAriaAttributeUsingEnum(): void ); } - public function testRenderWithAddAttribute(): void - { - self::assertSame( - << - - HTML, - H4::tag() - ->addAttribute('data-test', 'value') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method.", - ); - } - - public function testRenderWithAddAttributeUsingEnum(): void - { - self::assertSame( - << - - HTML, - H4::tag() - ->addAttribute(GlobalAttribute::TITLE, 'value') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", - ); - } - public function testRenderWithAddDataAttribute(): void { self::assertSame( @@ -507,7 +479,7 @@ public function testRenderWithRemoveAttribute(): void HTML, H4::tag() - ->addAttribute('data-test', 'value') + ->setAttribute('data-test', 'value') ->removeAttribute('data-test') ->render(), "Failed asserting that element renders correctly with 'removeAttribute()' method.", @@ -557,6 +529,34 @@ public function testRenderWithRoleUsingEnum(): void ); } + public function testRenderWithSetAttribute(): void + { + self::assertSame( + << + + HTML, + H4::tag() + ->setAttribute('data-test', 'value') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method.", + ); + } + + public function testRenderWithSetAttributeUsingEnum(): void + { + self::assertSame( + << + + HTML, + H4::tag() + ->setAttribute(GlobalAttribute::TITLE, 'value') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method using enum.", + ); + } + public function testRenderWithSpellcheck(): void { self::assertSame( diff --git a/tests/Heading/H5Test.php b/tests/Heading/H5Test.php index cbc86da..f151388 100644 --- a/tests/Heading/H5Test.php +++ b/tests/Heading/H5Test.php @@ -61,7 +61,7 @@ public function testGetAttributesReturnsAssignedAttributes(): void self::assertSame( ['data-test' => 'value'], H5::tag() - ->addAttribute('data-test', 'value') + ->setAttribute('data-test', 'value') ->getAttributes(), "Failed asserting that 'getAttributes()' returns the assigned attributes.", ); @@ -124,34 +124,6 @@ public function testRenderWithAddAriaAttributeUsingEnum(): void ); } - public function testRenderWithAddAttribute(): void - { - self::assertSame( - << - - HTML, - H5::tag() - ->addAttribute('data-test', 'value') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method.", - ); - } - - public function testRenderWithAddAttributeUsingEnum(): void - { - self::assertSame( - << - - HTML, - H5::tag() - ->addAttribute(GlobalAttribute::TITLE, 'value') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", - ); - } - public function testRenderWithAddDataAttribute(): void { self::assertSame( @@ -505,7 +477,7 @@ public function testRenderWithRemoveAttribute(): void HTML, H5::tag() - ->addAttribute('data-test', 'value') + ->setAttribute('data-test', 'value') ->removeAttribute('data-test') ->render(), "Failed asserting that element renders correctly with 'removeAttribute()' method.", @@ -555,6 +527,34 @@ public function testRenderWithRoleUsingEnum(): void ); } + public function testRenderWithSetAttribute(): void + { + self::assertSame( + << + + HTML, + H5::tag() + ->setAttribute('data-test', 'value') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method.", + ); + } + + public function testRenderWithSetAttributeUsingEnum(): void + { + self::assertSame( + << + + HTML, + H5::tag() + ->setAttribute(GlobalAttribute::TITLE, 'value') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method using enum.", + ); + } + public function testRenderWithSpellcheck(): void { self::assertSame( diff --git a/tests/Heading/H6Test.php b/tests/Heading/H6Test.php index 9147936..647fa72 100644 --- a/tests/Heading/H6Test.php +++ b/tests/Heading/H6Test.php @@ -61,7 +61,7 @@ public function testGetAttributesReturnsAssignedAttributes(): void self::assertSame( ['data-test' => 'value'], H6::tag() - ->addAttribute('data-test', 'value') + ->setAttribute('data-test', 'value') ->getAttributes(), "Failed asserting that 'getAttributes()' returns the assigned attributes.", ); @@ -124,34 +124,6 @@ public function testRenderWithAddAriaAttributeUsingEnum(): void ); } - public function testRenderWithAddAttribute(): void - { - self::assertSame( - << - - HTML, - H6::tag() - ->addAttribute('data-test', 'value') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method.", - ); - } - - public function testRenderWithAddAttributeUsingEnum(): void - { - self::assertSame( - << - - HTML, - H6::tag() - ->addAttribute(GlobalAttribute::TITLE, 'value') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", - ); - } - public function testRenderWithAddDataAttribute(): void { self::assertSame( @@ -507,7 +479,7 @@ public function testRenderWithRemoveAttribute(): void HTML, H6::tag() - ->addAttribute('data-test', 'value') + ->setAttribute('data-test', 'value') ->removeAttribute('data-test') ->render(), "Failed asserting that element renders correctly with 'removeAttribute()' method.", @@ -557,6 +529,34 @@ public function testRenderWithRoleUsingEnum(): void ); } + public function testRenderWithSetAttribute(): void + { + self::assertSame( + << + + HTML, + H6::tag() + ->setAttribute('data-test', 'value') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method.", + ); + } + + public function testRenderWithSetAttributeUsingEnum(): void + { + self::assertSame( + << + + HTML, + H6::tag() + ->setAttribute(GlobalAttribute::TITLE, 'value') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method using enum.", + ); + } + public function testRenderWithSpellcheck(): void { self::assertSame( diff --git a/tests/Heading/HGroupTest.php b/tests/Heading/HGroupTest.php index 21721bc..53ca844 100644 --- a/tests/Heading/HGroupTest.php +++ b/tests/Heading/HGroupTest.php @@ -61,7 +61,7 @@ public function testGetAttributesReturnsAssignedAttributes(): void self::assertSame( ['data-test' => 'value'], HGroup::tag() - ->addAttribute('data-test', 'value') + ->setAttribute('data-test', 'value') ->getAttributes(), "Failed asserting that 'getAttributes()' returns the assigned attributes.", ); @@ -124,34 +124,6 @@ public function testRenderWithAddAriaAttributeUsingEnum(): void ); } - public function testRenderWithAddAttribute(): void - { - self::assertSame( - << - - HTML, - HGroup::tag() - ->addAttribute('data-test', 'value') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method.", - ); - } - - public function testRenderWithAddAttributeUsingEnum(): void - { - self::assertSame( - << - - HTML, - HGroup::tag() - ->addAttribute(GlobalAttribute::TITLE, 'value') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", - ); - } - public function testRenderWithAddDataAttribute(): void { self::assertSame( @@ -507,7 +479,7 @@ public function testRenderWithRemoveAttribute(): void HTML, HGroup::tag() - ->addAttribute('data-test', 'value') + ->setAttribute('data-test', 'value') ->removeAttribute('data-test') ->render(), "Failed asserting that element renders correctly with 'removeAttribute()' method.", @@ -557,6 +529,34 @@ public function testRenderWithRoleUsingEnum(): void ); } + public function testRenderWithSetAttribute(): void + { + self::assertSame( + << + + HTML, + HGroup::tag() + ->setAttribute('data-test', 'value') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method.", + ); + } + + public function testRenderWithSetAttributeUsingEnum(): void + { + self::assertSame( + << + + HTML, + HGroup::tag() + ->setAttribute(GlobalAttribute::TITLE, 'value') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method using enum.", + ); + } + public function testRenderWithSpellcheck(): void { self::assertSame( diff --git a/tests/List/DdTest.php b/tests/List/DdTest.php index 26089cf..b03f3e2 100644 --- a/tests/List/DdTest.php +++ b/tests/List/DdTest.php @@ -61,7 +61,7 @@ public function testGetAttributesReturnsAssignedAttributes(): void self::assertSame( ['data-test' => 'value'], Dd::tag() - ->addAttribute('data-test', 'value') + ->setAttribute('data-test', 'value') ->getAttributes(), "Failed asserting that 'getAttributes()' returns the assigned attributes.", ); @@ -124,34 +124,6 @@ public function testRenderWithAddAriaAttributeUsingEnum(): void ); } - public function testRenderWithAddAttribute(): void - { - self::assertSame( - << - - HTML, - Dd::tag() - ->addAttribute('data-test', 'value') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method.", - ); - } - - public function testRenderWithAddAttributeUsingEnum(): void - { - self::assertSame( - << - - HTML, - Dd::tag() - ->addAttribute(GlobalAttribute::TITLE, 'value') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", - ); - } - public function testRenderWithAddDataAttribute(): void { self::assertSame( @@ -507,7 +479,7 @@ public function testRenderWithRemoveAttribute(): void HTML, Dd::tag() - ->addAttribute('data-test', 'value') + ->setAttribute('data-test', 'value') ->removeAttribute('data-test') ->render(), "Failed asserting that element renders correctly with 'removeAttribute()' method.", @@ -557,6 +529,34 @@ public function testRenderWithRoleUsingEnum(): void ); } + public function testRenderWithSetAttribute(): void + { + self::assertSame( + << + + HTML, + Dd::tag() + ->setAttribute('data-test', 'value') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method.", + ); + } + + public function testRenderWithSetAttributeUsingEnum(): void + { + self::assertSame( + << + + HTML, + Dd::tag() + ->setAttribute(GlobalAttribute::TITLE, 'value') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method using enum.", + ); + } + public function testRenderWithSpellcheck(): void { self::assertSame( diff --git a/tests/List/DlTest.php b/tests/List/DlTest.php index cf4060b..fa3c6fd 100644 --- a/tests/List/DlTest.php +++ b/tests/List/DlTest.php @@ -61,7 +61,7 @@ public function testGetAttributesReturnsAssignedAttributes(): void self::assertSame( ['data-test' => 'value'], Dl::tag() - ->addAttribute('data-test', 'value') + ->setAttribute('data-test', 'value') ->getAttributes(), "Failed asserting that 'getAttributes()' returns the assigned attributes.", ); @@ -124,34 +124,6 @@ public function testRenderWithAddAriaAttributeUsingEnum(): void ); } - public function testRenderWithAddAttribute(): void - { - self::assertSame( - << - - HTML, - Dl::tag() - ->addAttribute('data-test', 'value') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method.", - ); - } - - public function testRenderWithAddAttributeUsingEnum(): void - { - self::assertSame( - << - - HTML, - Dl::tag() - ->addAttribute(GlobalAttribute::TITLE, 'value') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", - ); - } - public function testRenderWithAddDataAttribute(): void { self::assertSame( @@ -570,7 +542,7 @@ public function testRenderWithRemoveAttribute(): void HTML, Dl::tag() - ->addAttribute('data-test', 'value') + ->setAttribute('data-test', 'value') ->removeAttribute('data-test') ->render(), "Failed asserting that element renders correctly with 'removeAttribute()' method.", @@ -620,6 +592,34 @@ public function testRenderWithRoleUsingEnum(): void ); } + public function testRenderWithSetAttribute(): void + { + self::assertSame( + << + + HTML, + Dl::tag() + ->setAttribute('data-test', 'value') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method.", + ); + } + + public function testRenderWithSetAttributeUsingEnum(): void + { + self::assertSame( + << + + HTML, + Dl::tag() + ->setAttribute(GlobalAttribute::TITLE, 'value') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method using enum.", + ); + } + public function testRenderWithSpellcheck(): void { self::assertSame( diff --git a/tests/List/DtTest.php b/tests/List/DtTest.php index dafef19..0021f90 100644 --- a/tests/List/DtTest.php +++ b/tests/List/DtTest.php @@ -61,7 +61,7 @@ public function testGetAttributesReturnsAssignedAttributes(): void self::assertSame( ['data-test' => 'value'], Dt::tag() - ->addAttribute('data-test', 'value') + ->setAttribute('data-test', 'value') ->getAttributes(), "Failed asserting that 'getAttributes()' returns the assigned attributes.", ); @@ -124,34 +124,6 @@ public function testRenderWithAddAriaAttributeUsingEnum(): void ); } - public function testRenderWithAddAttribute(): void - { - self::assertSame( - << - - HTML, - Dt::tag() - ->addAttribute('data-test', 'value') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method.", - ); - } - - public function testRenderWithAddAttributeUsingEnum(): void - { - self::assertSame( - << - - HTML, - Dt::tag() - ->addAttribute(GlobalAttribute::TITLE, 'value') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", - ); - } - public function testRenderWithAddDataAttribute(): void { self::assertSame( @@ -507,7 +479,7 @@ public function testRenderWithRemoveAttribute(): void HTML, Dt::tag() - ->addAttribute('data-test', 'value') + ->setAttribute('data-test', 'value') ->removeAttribute('data-test') ->render(), "Failed asserting that element renders correctly with 'removeAttribute()' method.", @@ -557,6 +529,34 @@ public function testRenderWithRoleUsingEnum(): void ); } + public function testRenderWithSetAttribute(): void + { + self::assertSame( + << + + HTML, + Dt::tag() + ->setAttribute('data-test', 'value') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method.", + ); + } + + public function testRenderWithSetAttributeUsingEnum(): void + { + self::assertSame( + << + + HTML, + Dt::tag() + ->setAttribute(GlobalAttribute::TITLE, 'value') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method using enum.", + ); + } + public function testRenderWithSpellcheck(): void { self::assertSame( diff --git a/tests/List/LiTest.php b/tests/List/LiTest.php index 1a2eed2..513bff2 100644 --- a/tests/List/LiTest.php +++ b/tests/List/LiTest.php @@ -62,7 +62,7 @@ public function testGetAttributesReturnsAssignedAttributes(): void self::assertSame( ['data-test' => 'value'], Li::tag() - ->addAttribute('data-test', 'value') + ->setAttribute('data-test', 'value') ->getAttributes(), "Failed asserting that 'getAttributes()' returns the assigned attributes.", ); @@ -125,34 +125,6 @@ public function testRenderWithAddAriaAttributeUsingEnum(): void ); } - public function testRenderWithAddAttribute(): void - { - self::assertSame( - << - - HTML, - Li::tag() - ->addAttribute('data-test', 'value') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method.", - ); - } - - public function testRenderWithAddAttributeUsingEnum(): void - { - self::assertSame( - << - - HTML, - Li::tag() - ->addAttribute(GlobalAttribute::TITLE, 'value') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", - ); - } - public function testRenderWithAddDataAttribute(): void { self::assertSame( @@ -523,7 +495,7 @@ public function testRenderWithRemoveAttribute(): void HTML, Li::tag() - ->addAttribute('data-test', 'value') + ->setAttribute('data-test', 'value') ->removeAttribute('data-test') ->render(), "Failed asserting that element renders correctly with 'removeAttribute()' method.", @@ -573,6 +545,34 @@ public function testRenderWithRoleUsingEnum(): void ); } + public function testRenderWithSetAttribute(): void + { + self::assertSame( + << + + HTML, + Li::tag() + ->setAttribute('data-test', 'value') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method.", + ); + } + + public function testRenderWithSetAttributeUsingEnum(): void + { + self::assertSame( + << + + HTML, + Li::tag() + ->setAttribute(GlobalAttribute::TITLE, 'value') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method using enum.", + ); + } + public function testRenderWithSpellcheck(): void { self::assertSame( diff --git a/tests/List/OlTest.php b/tests/List/OlTest.php index 3d56eb9..986bd49 100644 --- a/tests/List/OlTest.php +++ b/tests/List/OlTest.php @@ -62,7 +62,7 @@ public function testGetAttributesReturnsAssignedAttributes(): void self::assertSame( ['data-test' => 'value'], Ol::tag() - ->addAttribute('data-test', 'value') + ->setAttribute('data-test', 'value') ->getAttributes(), "Failed asserting that 'getAttributes()' returns the assigned attributes.", ); @@ -125,34 +125,6 @@ public function testRenderWithAddAriaAttributeUsingEnum(): void ); } - public function testRenderWithAddAttribute(): void - { - self::assertSame( - << - - HTML, - Ol::tag() - ->addAttribute('data-test', 'value') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method.", - ); - } - - public function testRenderWithAddAttributeUsingEnum(): void - { - self::assertSame( - << - - HTML, - Ol::tag() - ->addAttribute(GlobalAttribute::TITLE, 'value') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", - ); - } - public function testRenderWithAddDataAttribute(): void { self::assertSame( @@ -571,7 +543,7 @@ public function testRenderWithRemoveAttribute(): void HTML, Ol::tag() - ->addAttribute('data-test', 'value') + ->setAttribute('data-test', 'value') ->removeAttribute('data-test') ->render(), "Failed asserting that element renders correctly with 'removeAttribute()' method.", @@ -639,6 +611,34 @@ public function testRenderWithRoleUsingEnum(): void ); } + public function testRenderWithSetAttribute(): void + { + self::assertSame( + << + + HTML, + Ol::tag() + ->setAttribute('data-test', 'value') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method.", + ); + } + + public function testRenderWithSetAttributeUsingEnum(): void + { + self::assertSame( + << + + HTML, + Ol::tag() + ->setAttribute(GlobalAttribute::TITLE, 'value') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method using enum.", + ); + } + public function testRenderWithSpellcheck(): void { self::assertSame( diff --git a/tests/List/UlTest.php b/tests/List/UlTest.php index 432b26e..4564b28 100644 --- a/tests/List/UlTest.php +++ b/tests/List/UlTest.php @@ -61,7 +61,7 @@ public function testGetAttributesReturnsAssignedAttributes(): void self::assertSame( ['data-test' => 'value'], Ul::tag() - ->addAttribute('data-test', 'value') + ->setAttribute('data-test', 'value') ->getAttributes(), "Failed asserting that 'getAttributes()' returns the assigned attributes.", ); @@ -124,34 +124,6 @@ public function testRenderWithAddAriaAttributeUsingEnum(): void ); } - public function testRenderWithAddAttribute(): void - { - self::assertSame( - << - - HTML, - Ul::tag() - ->addAttribute('data-test', 'value') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method.", - ); - } - - public function testRenderWithAddAttributeUsingEnum(): void - { - self::assertSame( - << - - HTML, - Ul::tag() - ->addAttribute(GlobalAttribute::TITLE, 'value') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", - ); - } - public function testRenderWithAddDataAttribute(): void { self::assertSame( @@ -568,7 +540,7 @@ public function testRenderWithRemoveAttribute(): void HTML, Ul::tag() - ->addAttribute('data-test', 'value') + ->setAttribute('data-test', 'value') ->removeAttribute('data-test') ->render(), "Failed asserting that element renders correctly with 'removeAttribute()' method.", @@ -618,6 +590,34 @@ public function testRenderWithRoleUsingEnum(): void ); } + public function testRenderWithSetAttribute(): void + { + self::assertSame( + << + + HTML, + Ul::tag() + ->setAttribute('data-test', 'value') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method.", + ); + } + + public function testRenderWithSetAttributeUsingEnum(): void + { + self::assertSame( + << + + HTML, + Ul::tag() + ->setAttribute(GlobalAttribute::TITLE, 'value') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method using enum.", + ); + } + public function testRenderWithSpellcheck(): void { self::assertSame( diff --git a/tests/Metadata/BaseTest.php b/tests/Metadata/BaseTest.php index 36dfa20..d456a9b 100644 --- a/tests/Metadata/BaseTest.php +++ b/tests/Metadata/BaseTest.php @@ -54,7 +54,7 @@ public function testGetAttributesReturnsAssignedAttributes(): void self::assertSame( ['data-test' => 'value'], Base::tag() - ->addAttribute('data-test', 'value') + ->setAttribute('data-test', 'value') ->getAttributes(), "Failed asserting that 'getAttributes()' returns the assigned attributes.", ); @@ -99,32 +99,6 @@ public function testRenderWithAddAriaAttributeUsingEnum(): void ); } - public function testRenderWithAddAttribute(): void - { - self::assertSame( - << - HTML, - Base::tag() - ->addAttribute('data-test', 'value') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method.", - ); - } - - public function testRenderWithAddAttributeUsingEnum(): void - { - self::assertSame( - << - HTML, - Base::tag() - ->addAttribute(GlobalAttribute::TITLE, 'Base URL') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", - ); - } - public function testRenderWithAddDataAttribute(): void { self::assertSame( @@ -383,7 +357,7 @@ public function testRenderWithRemoveAttribute(): void HTML, Base::tag() - ->addAttribute('data-test', 'value') + ->setAttribute('data-test', 'value') ->removeAttribute('data-test') ->render(), "Failed asserting that element renders correctly with 'removeAttribute()' method.", @@ -430,6 +404,32 @@ public function testRenderWithRoleUsingEnum(): void ); } + public function testRenderWithSetAttribute(): void + { + self::assertSame( + << + HTML, + Base::tag() + ->setAttribute('data-test', 'value') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method.", + ); + } + + public function testRenderWithSetAttributeUsingEnum(): void + { + self::assertSame( + << + HTML, + Base::tag() + ->setAttribute(GlobalAttribute::TITLE, 'Base URL') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method using enum.", + ); + } + public function testRenderWithStyle(): void { self::assertSame( diff --git a/tests/Metadata/LinkTest.php b/tests/Metadata/LinkTest.php index 708e5e7..e202617 100644 --- a/tests/Metadata/LinkTest.php +++ b/tests/Metadata/LinkTest.php @@ -59,7 +59,7 @@ public function testGetAttributesReturnsAssignedAttributes(): void self::assertSame( ['data-test' => 'value'], Link::tag() - ->addAttribute('data-test', 'value') + ->setAttribute('data-test', 'value') ->getAttributes(), "Failed asserting that 'getAttributes()' returns the assigned attributes.", ); @@ -104,32 +104,6 @@ public function testRenderWithAddAriaAttributeUsingEnum(): void ); } - public function testRenderWithAddAttribute(): void - { - self::assertSame( - << - HTML, - Link::tag() - ->addAttribute('data-test', 'value') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method.", - ); - } - - public function testRenderWithAddAttributeUsingEnum(): void - { - self::assertSame( - << - HTML, - Link::tag() - ->addAttribute(GlobalAttribute::TITLE, 'Stylesheet') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", - ); - } - public function testRenderWithAddDataAttribute(): void { self::assertSame( @@ -596,7 +570,7 @@ public function testRenderWithRemoveAttribute(): void HTML, Link::tag() - ->addAttribute('data-test', 'value') + ->setAttribute('data-test', 'value') ->removeAttribute('data-test') ->render(), "Failed asserting that element renders correctly with 'removeAttribute()' method.", @@ -643,6 +617,32 @@ public function testRenderWithRoleUsingEnum(): void ); } + public function testRenderWithSetAttribute(): void + { + self::assertSame( + << + HTML, + Link::tag() + ->setAttribute('data-test', 'value') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method.", + ); + } + + public function testRenderWithSetAttributeUsingEnum(): void + { + self::assertSame( + << + HTML, + Link::tag() + ->setAttribute(GlobalAttribute::TITLE, 'Stylesheet') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method using enum.", + ); + } + public function testRenderWithSizes(): void { self::assertSame( diff --git a/tests/Metadata/MetaTest.php b/tests/Metadata/MetaTest.php index c69c7f9..3491267 100644 --- a/tests/Metadata/MetaTest.php +++ b/tests/Metadata/MetaTest.php @@ -54,7 +54,7 @@ public function testGetAttributesReturnsAssignedAttributes(): void self::assertSame( ['data-test' => 'value'], Meta::tag() - ->addAttribute('data-test', 'value') + ->setAttribute('data-test', 'value') ->getAttributes(), "Failed asserting that 'getAttributes()' returns the assigned attributes.", ); @@ -99,32 +99,6 @@ public function testRenderWithAddAriaAttributeUsingEnum(): void ); } - public function testRenderWithAddAttribute(): void - { - self::assertSame( - << - HTML, - Meta::tag() - ->addAttribute('data-test', 'value') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method.", - ); - } - - public function testRenderWithAddAttributeUsingEnum(): void - { - self::assertSame( - << - HTML, - Meta::tag() - ->addAttribute(GlobalAttribute::TITLE, 'Meta tag') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", - ); - } - public function testRenderWithAddDataAttribute(): void { self::assertSame( @@ -450,7 +424,7 @@ public function testRenderWithRemoveAttribute(): void HTML, Meta::tag() - ->addAttribute('data-test', 'value') + ->setAttribute('data-test', 'value') ->removeAttribute('data-test') ->render(), "Failed asserting that element renders correctly with 'removeAttribute()' method.", @@ -495,6 +469,32 @@ public function testRenderWithRoleUsingEnum(): void ); } + public function testRenderWithSetAttribute(): void + { + self::assertSame( + << + HTML, + Meta::tag() + ->setAttribute('data-test', 'value') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method.", + ); + } + + public function testRenderWithSetAttributeUsingEnum(): void + { + self::assertSame( + << + HTML, + Meta::tag() + ->setAttribute(GlobalAttribute::TITLE, 'Meta tag') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method using enum.", + ); + } + public function testRenderWithStyle(): void { self::assertSame( diff --git a/tests/Metadata/NoScriptTest.php b/tests/Metadata/NoScriptTest.php index 805b2a2..5c47971 100644 --- a/tests/Metadata/NoScriptTest.php +++ b/tests/Metadata/NoScriptTest.php @@ -61,7 +61,7 @@ public function testGetAttributesReturnsAssignedAttributes(): void self::assertSame( ['data-test' => 'value'], NoScript::tag() - ->addAttribute('data-test', 'value') + ->setAttribute('data-test', 'value') ->getAttributes(), "Failed asserting that 'getAttributes()' returns the assigned attributes.", ); @@ -124,34 +124,6 @@ public function testRenderWithAddAriaAttributeUsingEnum(): void ); } - public function testRenderWithAddAttribute(): void - { - self::assertSame( - << - - HTML, - NoScript::tag() - ->addAttribute('data-test', 'value') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method.", - ); - } - - public function testRenderWithAddAttributeUsingEnum(): void - { - self::assertSame( - << - - HTML, - NoScript::tag() - ->addAttribute(GlobalAttribute::TITLE, 'Fallback content') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", - ); - } - public function testRenderWithAddDataAttribute(): void { self::assertSame( @@ -518,7 +490,7 @@ public function testRenderWithRemoveAttribute(): void HTML, NoScript::tag() - ->addAttribute('data-test', 'value') + ->setAttribute('data-test', 'value') ->removeAttribute('data-test') ->render(), "Failed asserting that element renders correctly with 'removeAttribute()' method.", @@ -568,6 +540,34 @@ public function testRenderWithRoleUsingEnum(): void ); } + public function testRenderWithSetAttribute(): void + { + self::assertSame( + << + + HTML, + NoScript::tag() + ->setAttribute('data-test', 'value') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method.", + ); + } + + public function testRenderWithSetAttributeUsingEnum(): void + { + self::assertSame( + << + + HTML, + NoScript::tag() + ->setAttribute(GlobalAttribute::TITLE, 'Fallback content') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method using enum.", + ); + } + public function testRenderWithSpellcheck(): void { self::assertSame( diff --git a/tests/Metadata/ScriptTest.php b/tests/Metadata/ScriptTest.php index 284805b..63d1618 100644 --- a/tests/Metadata/ScriptTest.php +++ b/tests/Metadata/ScriptTest.php @@ -71,7 +71,7 @@ public function testGetAttributesReturnsAssignedAttributes(): void self::assertSame( ['data-test' => 'value'], Script::tag() - ->addAttribute('data-test', 'value') + ->setAttribute('data-test', 'value') ->getAttributes(), "Failed asserting that 'getAttributes()' returns the assigned attributes.", ); @@ -134,34 +134,6 @@ public function testRenderWithAddAriaAttributeUsingEnum(): void ); } - public function testRenderWithAddAttribute(): void - { - self::assertSame( - << - - HTML, - Script::tag() - ->addAttribute('data-test', 'value') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method.", - ); - } - - public function testRenderWithAddAttributeUsingEnum(): void - { - self::assertSame( - << - - HTML, - Script::tag() - ->addAttribute(GlobalAttribute::TITLE, 'value') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", - ); - } - public function testRenderWithAddDataAttribute(): void { self::assertSame( @@ -697,7 +669,7 @@ public function testRenderWithRemoveAttribute(): void HTML, Script::tag() - ->addAttribute('data-test', 'value') + ->setAttribute('data-test', 'value') ->removeAttribute('data-test') ->render(), "Failed asserting that element renders correctly with 'removeAttribute()' method.", @@ -747,6 +719,34 @@ public function testRenderWithRoleUsingEnum(): void ); } + public function testRenderWithSetAttribute(): void + { + self::assertSame( + << + + HTML, + Script::tag() + ->setAttribute('data-test', 'value') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method.", + ); + } + + public function testRenderWithSetAttributeUsingEnum(): void + { + self::assertSame( + << + + HTML, + Script::tag() + ->setAttribute(GlobalAttribute::TITLE, 'value') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method using enum.", + ); + } + public function testRenderWithSpellcheck(): void { self::assertSame( diff --git a/tests/Metadata/StyleTest.php b/tests/Metadata/StyleTest.php index 491aebb..eb3ab1b 100644 --- a/tests/Metadata/StyleTest.php +++ b/tests/Metadata/StyleTest.php @@ -67,7 +67,7 @@ public function testGetAttributesReturnsAssignedAttributes(): void self::assertSame( ['data-test' => 'value'], Style::tag() - ->addAttribute('data-test', 'value') + ->setAttribute('data-test', 'value') ->getAttributes(), "Failed asserting that 'getAttributes()' returns the assigned attributes.", ); @@ -130,34 +130,6 @@ public function testRenderWithAddAriaAttributeUsingEnum(): void ); } - public function testRenderWithAddAttribute(): void - { - self::assertSame( - << - - HTML, - Style::tag() - ->addAttribute('data-test', 'value') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method.", - ); - } - - public function testRenderWithAddAttributeUsingEnum(): void - { - self::assertSame( - << - - HTML, - Style::tag() - ->addAttribute(GlobalAttribute::TITLE, 'value') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", - ); - } - public function testRenderWithAddDataAttribute(): void { self::assertSame( @@ -581,7 +553,7 @@ public function testRenderWithRemoveAttribute(): void HTML, Style::tag() - ->addAttribute('data-test', 'value') + ->setAttribute('data-test', 'value') ->removeAttribute('data-test') ->render(), "Failed asserting that element renders correctly with 'removeAttribute()' method.", @@ -631,6 +603,34 @@ public function testRenderWithRoleUsingEnum(): void ); } + public function testRenderWithSetAttribute(): void + { + self::assertSame( + << + + HTML, + Style::tag() + ->setAttribute('data-test', 'value') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method.", + ); + } + + public function testRenderWithSetAttributeUsingEnum(): void + { + self::assertSame( + << + + HTML, + Style::tag() + ->setAttribute(GlobalAttribute::TITLE, 'value') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method using enum.", + ); + } + public function testRenderWithSpellcheck(): void { self::assertSame( diff --git a/tests/Metadata/TemplateTest.php b/tests/Metadata/TemplateTest.php index 407df0c..5da1926 100644 --- a/tests/Metadata/TemplateTest.php +++ b/tests/Metadata/TemplateTest.php @@ -68,7 +68,7 @@ public function testGetAttributesReturnsAssignedAttributes(): void self::assertSame( ['data-test' => 'value'], Template::tag() - ->addAttribute('data-test', 'value') + ->setAttribute('data-test', 'value') ->getAttributes(), "Failed asserting that 'getAttributes()' returns the assigned attributes.", ); @@ -131,34 +131,6 @@ public function testRenderWithAddAriaAttributeUsingEnum(): void ); } - public function testRenderWithAddAttribute(): void - { - self::assertSame( - << - - HTML, - Template::tag() - ->addAttribute('data-test', 'value') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method.", - ); - } - - public function testRenderWithAddAttributeUsingEnum(): void - { - self::assertSame( - << - - HTML, - Template::tag() - ->addAttribute(GlobalAttribute::TITLE, 'value') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", - ); - } - public function testRenderWithAddDataAttribute(): void { self::assertSame( @@ -526,7 +498,7 @@ public function testRenderWithRemoveAttribute(): void HTML, Template::tag() - ->addAttribute('data-test', 'value') + ->setAttribute('data-test', 'value') ->removeAttribute('data-test') ->render(), "Failed asserting that element renders correctly with 'removeAttribute()' method.", @@ -576,6 +548,34 @@ public function testRenderWithRoleUsingEnum(): void ); } + public function testRenderWithSetAttribute(): void + { + self::assertSame( + << + + HTML, + Template::tag() + ->setAttribute('data-test', 'value') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method.", + ); + } + + public function testRenderWithSetAttributeUsingEnum(): void + { + self::assertSame( + << + + HTML, + Template::tag() + ->setAttribute(GlobalAttribute::TITLE, 'value') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method using enum.", + ); + } + public function testRenderWithShadowRootClonable(): void { self::assertSame( diff --git a/tests/Metadata/TitleTest.php b/tests/Metadata/TitleTest.php index 8cd6670..b3fa921 100644 --- a/tests/Metadata/TitleTest.php +++ b/tests/Metadata/TitleTest.php @@ -61,7 +61,7 @@ public function testGetAttributesReturnsAssignedAttributes(): void self::assertSame( ['data-test' => 'value'], Title::tag() - ->addAttribute('data-test', 'value') + ->setAttribute('data-test', 'value') ->getAttributes(), "Failed asserting that 'getAttributes()' returns the assigned attributes.", ); @@ -124,34 +124,6 @@ public function testRenderWithAddAriaAttributeUsingEnum(): void ); } - public function testRenderWithAddAttribute(): void - { - self::assertSame( - << - - HTML, - Title::tag() - ->addAttribute('data-test', 'value') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method.", - ); - } - - public function testRenderWithAddAttributeUsingEnum(): void - { - self::assertSame( - << - - HTML, - Title::tag() - ->addAttribute(GlobalAttribute::TITLE, 'value') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", - ); - } - public function testRenderWithAddDataAttribute(): void { self::assertSame( @@ -519,7 +491,7 @@ public function testRenderWithRemoveAttribute(): void HTML, Title::tag() - ->addAttribute('data-test', 'value') + ->setAttribute('data-test', 'value') ->removeAttribute('data-test') ->render(), "Failed asserting that element renders correctly with 'removeAttribute()' method.", @@ -569,6 +541,34 @@ public function testRenderWithRoleUsingEnum(): void ); } + public function testRenderWithSetAttribute(): void + { + self::assertSame( + << + + HTML, + Title::tag() + ->setAttribute('data-test', 'value') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method.", + ); + } + + public function testRenderWithSetAttributeUsingEnum(): void + { + self::assertSame( + << + + HTML, + Title::tag() + ->setAttribute(GlobalAttribute::TITLE, 'value') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method using enum.", + ); + } + public function testRenderWithSpellcheck(): void { self::assertSame( diff --git a/tests/Palpable/ATest.php b/tests/Palpable/ATest.php index 855253c..6c1d938 100644 --- a/tests/Palpable/ATest.php +++ b/tests/Palpable/ATest.php @@ -67,7 +67,7 @@ public function testGetAttributesReturnsAssignedAttributes(): void self::assertSame( ['data-test' => 'value'], A::tag() - ->addAttribute('data-test', 'value') + ->setAttribute('data-test', 'value') ->getAttributes(), "Failed asserting that 'getAttributes()' returns the assigned attributes.", ); @@ -125,32 +125,6 @@ public function testRenderWithAddAriaAttributeUsingEnum(): void ); } - public function testRenderWithAddAttribute(): void - { - self::assertSame( - << - HTML, - A::tag() - ->addAttribute('data-test', 'value') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method.", - ); - } - - public function testRenderWithAddAttributeUsingEnum(): void - { - self::assertSame( - << - HTML, - A::tag() - ->addAttribute(GlobalAttribute::TITLE, 'Link content') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", - ); - } - public function testRenderWithAddDataAttribute(): void { self::assertSame( @@ -527,7 +501,7 @@ public function testRenderWithRemoveAttribute(): void HTML, A::tag() - ->addAttribute('data-test', 'value') + ->setAttribute('data-test', 'value') ->removeAttribute('data-test') ->render(), "Failed asserting that element renders correctly with 'removeAttribute()' method.", @@ -574,6 +548,32 @@ public function testRenderWithRoleUsingEnum(): void ); } + public function testRenderWithSetAttribute(): void + { + self::assertSame( + << + HTML, + A::tag() + ->setAttribute('data-test', 'value') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method.", + ); + } + + public function testRenderWithSetAttributeUsingEnum(): void + { + self::assertSame( + << + HTML, + A::tag() + ->setAttribute(GlobalAttribute::TITLE, 'Link content') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method using enum.", + ); + } + public function testRenderWithStyle(): void { self::assertSame( diff --git a/tests/Phrasing/ITest.php b/tests/Phrasing/ITest.php index 49b6d65..c084174 100644 --- a/tests/Phrasing/ITest.php +++ b/tests/Phrasing/ITest.php @@ -59,7 +59,7 @@ public function testGetAttributesReturnsAssignedAttributes(): void self::assertSame( ['data-test' => 'value'], I::tag() - ->addAttribute('data-test', 'value') + ->setAttribute('data-test', 'value') ->getAttributes(), "Failed asserting that 'getAttributes()' returns the assigned attributes.", ); @@ -117,32 +117,6 @@ public function testRenderWithAddAriaAttributeUsingEnum(): void ); } - public function testRenderWithAddAttribute(): void - { - self::assertSame( - << - HTML, - I::tag() - ->addAttribute('data-test', 'value') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method.", - ); - } - - public function testRenderWithAddAttributeUsingEnum(): void - { - self::assertSame( - << - HTML, - I::tag() - ->addAttribute(GlobalAttribute::TITLE, 'Idiomatic text') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", - ); - } - public function testRenderWithAddDataAttribute(): void { self::assertSame( @@ -389,7 +363,7 @@ public function testRenderWithRemoveAttribute(): void HTML, I::tag() - ->addAttribute('data-test', 'value') + ->setAttribute('data-test', 'value') ->removeAttribute('data-test') ->render(), "Failed asserting that element renders correctly with 'removeAttribute()' method.", @@ -436,6 +410,32 @@ public function testRenderWithRoleUsingEnum(): void ); } + public function testRenderWithSetAttribute(): void + { + self::assertSame( + << + HTML, + I::tag() + ->setAttribute('data-test', 'value') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method.", + ); + } + + public function testRenderWithSetAttributeUsingEnum(): void + { + self::assertSame( + << + HTML, + I::tag() + ->setAttribute(GlobalAttribute::TITLE, 'Idiomatic text') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method using enum.", + ); + } + public function testRenderWithStyle(): void { self::assertSame( diff --git a/tests/Phrasing/LabelTest.php b/tests/Phrasing/LabelTest.php index efb4b3e..091cc78 100644 --- a/tests/Phrasing/LabelTest.php +++ b/tests/Phrasing/LabelTest.php @@ -59,7 +59,7 @@ public function testGetAttributesReturnsAssignedAttributes(): void self::assertSame( ['data-test' => 'value'], Label::tag() - ->addAttribute('data-test', 'value') + ->setAttribute('data-test', 'value') ->getAttributes(), "Failed asserting that 'getAttributes()' returns the assigned attributes.", ); @@ -117,32 +117,6 @@ public function testRenderWithAddAriaAttributeUsingEnum(): void ); } - public function testRenderWithAddAttribute(): void - { - self::assertSame( - << - HTML, - Label::tag() - ->addAttribute('data-test', 'value') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method.", - ); - } - - public function testRenderWithAddAttributeUsingEnum(): void - { - self::assertSame( - << - HTML, - Label::tag() - ->addAttribute(GlobalAttribute::TITLE, 'Label content') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", - ); - } - public function testRenderWithAddDataAttribute(): void { self::assertSame( @@ -402,7 +376,7 @@ public function testRenderWithRemoveAttribute(): void HTML, Label::tag() - ->addAttribute('data-test', 'value') + ->setAttribute('data-test', 'value') ->removeAttribute('data-test') ->render(), "Failed asserting that element renders correctly with 'removeAttribute()' method.", @@ -449,6 +423,32 @@ public function testRenderWithRoleUsingEnum(): void ); } + public function testRenderWithSetAttribute(): void + { + self::assertSame( + << + HTML, + Label::tag() + ->setAttribute('data-test', 'value') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method.", + ); + } + + public function testRenderWithSetAttributeUsingEnum(): void + { + self::assertSame( + << + HTML, + Label::tag() + ->setAttribute(GlobalAttribute::TITLE, 'Label content') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method using enum.", + ); + } + public function testRenderWithStyle(): void { self::assertSame( diff --git a/tests/Phrasing/SpanTest.php b/tests/Phrasing/SpanTest.php index 1fbcc93..752d7e9 100644 --- a/tests/Phrasing/SpanTest.php +++ b/tests/Phrasing/SpanTest.php @@ -59,7 +59,7 @@ public function testGetAttributesReturnsAssignedAttributes(): void self::assertSame( ['data-test' => 'value'], Span::tag() - ->addAttribute('data-test', 'value') + ->setAttribute('data-test', 'value') ->getAttributes(), "Failed asserting that 'getAttributes()' returns the assigned attributes.", ); @@ -115,32 +115,6 @@ public function testRenderWithAddAriaAttributeUsingEnum(): void ); } - public function testRenderWithAddAttribute(): void - { - self::assertSame( - << - HTML, - Span::tag() - ->addAttribute('data-test', 'value') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method.", - ); - } - - public function testRenderWithAddAttributeUsingEnum(): void - { - self::assertSame( - << - HTML, - Span::tag() - ->addAttribute(GlobalAttribute::TITLE, 'Span content') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", - ); - } - public function testRenderWithAddDataAttribute(): void { self::assertSame( @@ -387,7 +361,7 @@ public function testRenderWithRemoveAttribute(): void HTML, Span::tag() - ->addAttribute('data-test', 'value') + ->setAttribute('data-test', 'value') ->removeAttribute('data-test') ->render(), "Failed asserting that element renders correctly with 'removeAttribute()' method.", @@ -434,6 +408,32 @@ public function testRenderWithRoleUsingEnum(): void ); } + public function testRenderWithSetAttribute(): void + { + self::assertSame( + << + HTML, + Span::tag() + ->setAttribute('data-test', 'value') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method.", + ); + } + + public function testRenderWithSetAttributeUsingEnum(): void + { + self::assertSame( + << + HTML, + Span::tag() + ->setAttribute(GlobalAttribute::TITLE, 'Span content') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method using enum.", + ); + } + public function testRenderWithStyle(): void { self::assertSame( diff --git a/tests/Root/BodyTest.php b/tests/Root/BodyTest.php index 9b15e5b..ea10900 100644 --- a/tests/Root/BodyTest.php +++ b/tests/Root/BodyTest.php @@ -61,7 +61,7 @@ public function testGetAttributesReturnsAssignedAttributes(): void self::assertSame( ['data-test' => 'value'], Body::tag() - ->addAttribute('data-test', 'value') + ->setAttribute('data-test', 'value') ->getAttributes(), "Failed asserting that 'getAttributes()' returns the assigned attributes.", ); @@ -124,34 +124,6 @@ public function testRenderWithAddAriaAttributeUsingEnum(): void ); } - public function testRenderWithAddAttribute(): void - { - self::assertSame( - << - - HTML, - Body::tag() - ->addAttribute('data-test', 'value') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method.", - ); - } - - public function testRenderWithAddAttributeUsingEnum(): void - { - self::assertSame( - << - - HTML, - Body::tag() - ->addAttribute(GlobalAttribute::TITLE, 'value') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", - ); - } - public function testRenderWithAddDataAttribute(): void { self::assertSame( @@ -507,7 +479,7 @@ public function testRenderWithRemoveAttribute(): void HTML, Body::tag() - ->addAttribute('data-test', 'value') + ->setAttribute('data-test', 'value') ->removeAttribute('data-test') ->render(), "Failed asserting that element renders correctly with 'removeAttribute()' method.", @@ -557,6 +529,34 @@ public function testRenderWithRoleUsingEnum(): void ); } + public function testRenderWithSetAttribute(): void + { + self::assertSame( + << + + HTML, + Body::tag() + ->setAttribute('data-test', 'value') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method.", + ); + } + + public function testRenderWithSetAttributeUsingEnum(): void + { + self::assertSame( + << + + HTML, + Body::tag() + ->setAttribute(GlobalAttribute::TITLE, 'value') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method using enum.", + ); + } + public function testRenderWithSpellcheck(): void { self::assertSame( diff --git a/tests/Root/FooterTest.php b/tests/Root/FooterTest.php index 5e84ae9..1aef3f6 100644 --- a/tests/Root/FooterTest.php +++ b/tests/Root/FooterTest.php @@ -61,7 +61,7 @@ public function testGetAttributesReturnsAssignedAttributes(): void self::assertSame( ['data-test' => 'value'], Footer::tag() - ->addAttribute('data-test', 'value') + ->setAttribute('data-test', 'value') ->getAttributes(), "Failed asserting that 'getAttributes()' returns the assigned attributes.", ); @@ -124,34 +124,6 @@ public function testRenderWithAddAriaAttributeUsingEnum(): void ); } - public function testRenderWithAddAttribute(): void - { - self::assertSame( - << - - HTML, - Footer::tag() - ->addAttribute('data-test', 'value') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method.", - ); - } - - public function testRenderWithAddAttributeUsingEnum(): void - { - self::assertSame( - << - - HTML, - Footer::tag() - ->addAttribute(GlobalAttribute::TITLE, 'value') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", - ); - } - public function testRenderWithAddDataAttribute(): void { self::assertSame( @@ -507,7 +479,7 @@ public function testRenderWithRemoveAttribute(): void HTML, Footer::tag() - ->addAttribute('data-test', 'value') + ->setAttribute('data-test', 'value') ->removeAttribute('data-test') ->render(), "Failed asserting that element renders correctly with 'removeAttribute()' method.", @@ -557,6 +529,34 @@ public function testRenderWithRoleUsingEnum(): void ); } + public function testRenderWithSetAttribute(): void + { + self::assertSame( + << + + HTML, + Footer::tag() + ->setAttribute('data-test', 'value') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method.", + ); + } + + public function testRenderWithSetAttributeUsingEnum(): void + { + self::assertSame( + << + + HTML, + Footer::tag() + ->setAttribute(GlobalAttribute::TITLE, 'value') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method using enum.", + ); + } + public function testRenderWithSpellcheck(): void { self::assertSame( diff --git a/tests/Root/HeadTest.php b/tests/Root/HeadTest.php index b5f5b5b..a467830 100644 --- a/tests/Root/HeadTest.php +++ b/tests/Root/HeadTest.php @@ -61,7 +61,7 @@ public function testGetAttributesReturnsAssignedAttributes(): void self::assertSame( ['data-test' => 'value'], Head::tag() - ->addAttribute('data-test', 'value') + ->setAttribute('data-test', 'value') ->getAttributes(), "Failed asserting that 'getAttributes()' returns the assigned attributes.", ); @@ -124,34 +124,6 @@ public function testRenderWithAddAriaAttributeUsingEnum(): void ); } - public function testRenderWithAddAttribute(): void - { - self::assertSame( - << - - HTML, - Head::tag() - ->addAttribute('data-test', 'value') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method.", - ); - } - - public function testRenderWithAddAttributeUsingEnum(): void - { - self::assertSame( - << - - HTML, - Head::tag() - ->addAttribute(GlobalAttribute::TITLE, 'value') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", - ); - } - public function testRenderWithAddDataAttribute(): void { self::assertSame( @@ -507,7 +479,7 @@ public function testRenderWithRemoveAttribute(): void HTML, Head::tag() - ->addAttribute('data-test', 'value') + ->setAttribute('data-test', 'value') ->removeAttribute('data-test') ->render(), "Failed asserting that element renders correctly with 'removeAttribute()' method.", @@ -557,6 +529,34 @@ public function testRenderWithRoleUsingEnum(): void ); } + public function testRenderWithSetAttribute(): void + { + self::assertSame( + << + + HTML, + Head::tag() + ->setAttribute('data-test', 'value') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method.", + ); + } + + public function testRenderWithSetAttributeUsingEnum(): void + { + self::assertSame( + << + + HTML, + Head::tag() + ->setAttribute(GlobalAttribute::TITLE, 'value') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method using enum.", + ); + } + public function testRenderWithSpellcheck(): void { self::assertSame( diff --git a/tests/Root/HeaderTest.php b/tests/Root/HeaderTest.php index d0470cf..6e9a0aa 100644 --- a/tests/Root/HeaderTest.php +++ b/tests/Root/HeaderTest.php @@ -61,7 +61,7 @@ public function testGetAttributesReturnsAssignedAttributes(): void self::assertSame( ['data-test' => 'value'], Header::tag() - ->addAttribute('data-test', 'value') + ->setAttribute('data-test', 'value') ->getAttributes(), "Failed asserting that 'getAttributes()' returns the assigned attributes.", ); @@ -124,34 +124,6 @@ public function testRenderWithAddAriaAttributeUsingEnum(): void ); } - public function testRenderWithAddAttribute(): void - { - self::assertSame( - << - - HTML, - Header::tag() - ->addAttribute('data-test', 'value') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method.", - ); - } - - public function testRenderWithAddAttributeUsingEnum(): void - { - self::assertSame( - << - - HTML, - Header::tag() - ->addAttribute(GlobalAttribute::TITLE, 'value') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", - ); - } - public function testRenderWithAddDataAttribute(): void { self::assertSame( @@ -507,7 +479,7 @@ public function testRenderWithRemoveAttribute(): void HTML, Header::tag() - ->addAttribute('data-test', 'value') + ->setAttribute('data-test', 'value') ->removeAttribute('data-test') ->render(), "Failed asserting that element renders correctly with 'removeAttribute()' method.", @@ -557,6 +529,34 @@ public function testRenderWithRoleUsingEnum(): void ); } + public function testRenderWithSetAttribute(): void + { + self::assertSame( + << + + HTML, + Header::tag() + ->setAttribute('data-test', 'value') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method.", + ); + } + + public function testRenderWithSetAttributeUsingEnum(): void + { + self::assertSame( + << + + HTML, + Header::tag() + ->setAttribute(GlobalAttribute::TITLE, 'value') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method using enum.", + ); + } + public function testRenderWithSpellcheck(): void { self::assertSame( diff --git a/tests/Root/HtmlTest.php b/tests/Root/HtmlTest.php index 5e1f348..2f7b721 100644 --- a/tests/Root/HtmlTest.php +++ b/tests/Root/HtmlTest.php @@ -61,7 +61,7 @@ public function testGetAttributesReturnsAssignedAttributes(): void self::assertSame( ['data-test' => 'value'], Html::tag() - ->addAttribute('data-test', 'value') + ->setAttribute('data-test', 'value') ->getAttributes(), "Failed asserting that 'getAttributes()' returns the assigned attributes.", ); @@ -124,34 +124,6 @@ public function testRenderWithAddAriaAttributeUsingEnum(): void ); } - public function testRenderWithAddAttribute(): void - { - self::assertSame( - << - - HTML, - Html::tag() - ->addAttribute('data-test', 'value') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method.", - ); - } - - public function testRenderWithAddAttributeUsingEnum(): void - { - self::assertSame( - << - - HTML, - Html::tag() - ->addAttribute(GlobalAttribute::TITLE, 'value') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", - ); - } - public function testRenderWithAddDataAttribute(): void { self::assertSame( @@ -507,7 +479,7 @@ public function testRenderWithRemoveAttribute(): void HTML, Html::tag() - ->addAttribute('data-test', 'value') + ->setAttribute('data-test', 'value') ->removeAttribute('data-test') ->render(), "Failed asserting that element renders correctly with 'removeAttribute()' method.", @@ -557,6 +529,34 @@ public function testRenderWithRoleUsingEnum(): void ); } + public function testRenderWithSetAttribute(): void + { + self::assertSame( + << + + HTML, + Html::tag() + ->setAttribute('data-test', 'value') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method.", + ); + } + + public function testRenderWithSetAttributeUsingEnum(): void + { + self::assertSame( + << + + HTML, + Html::tag() + ->setAttribute(GlobalAttribute::TITLE, 'value') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method using enum.", + ); + } + public function testRenderWithSpellcheck(): void { self::assertSame( diff --git a/tests/Sectioning/ArticleTest.php b/tests/Sectioning/ArticleTest.php index 3558649..4967c80 100644 --- a/tests/Sectioning/ArticleTest.php +++ b/tests/Sectioning/ArticleTest.php @@ -61,7 +61,7 @@ public function testGetAttributesReturnsAssignedAttributes(): void self::assertSame( ['data-test' => 'value'], Article::tag() - ->addAttribute('data-test', 'value') + ->setAttribute('data-test', 'value') ->getAttributes(), "Failed asserting that 'getAttributes()' returns the assigned attributes.", ); @@ -124,34 +124,6 @@ public function testRenderWithAddAriaAttributeUsingEnum(): void ); } - public function testRenderWithAddAttribute(): void - { - self::assertSame( - << - - HTML, - Article::tag() - ->addAttribute('data-test', 'value') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method.", - ); - } - - public function testRenderWithAddAttributeUsingEnum(): void - { - self::assertSame( - << - - HTML, - Article::tag() - ->addAttribute(GlobalAttribute::TITLE, 'value') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", - ); - } - public function testRenderWithAddDataAttribute(): void { self::assertSame( @@ -507,7 +479,7 @@ public function testRenderWithRemoveAttribute(): void HTML, Article::tag() - ->addAttribute('data-test', 'value') + ->setAttribute('data-test', 'value') ->removeAttribute('data-test') ->render(), "Failed asserting that element renders correctly with 'removeAttribute()' method.", @@ -557,6 +529,34 @@ public function testRenderWithRoleUsingEnum(): void ); } + public function testRenderWithSetAttribute(): void + { + self::assertSame( + << + + HTML, + Article::tag() + ->setAttribute('data-test', 'value') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method.", + ); + } + + public function testRenderWithSetAttributeUsingEnum(): void + { + self::assertSame( + << + + HTML, + Article::tag() + ->setAttribute(GlobalAttribute::TITLE, 'value') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method using enum.", + ); + } + public function testRenderWithSpellcheck(): void { self::assertSame( diff --git a/tests/Sectioning/AsideTest.php b/tests/Sectioning/AsideTest.php index 0fc448e..7f4c7fe 100644 --- a/tests/Sectioning/AsideTest.php +++ b/tests/Sectioning/AsideTest.php @@ -61,7 +61,7 @@ public function testGetAttributesReturnsAssignedAttributes(): void self::assertSame( ['data-test' => 'value'], Aside::tag() - ->addAttribute('data-test', 'value') + ->setAttribute('data-test', 'value') ->getAttributes(), "Failed asserting that 'getAttributes()' returns the assigned attributes.", ); @@ -124,34 +124,6 @@ public function testRenderWithAddAriaAttributeUsingEnum(): void ); } - public function testRenderWithAddAttribute(): void - { - self::assertSame( - << - - HTML, - Aside::tag() - ->addAttribute('data-test', 'value') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method.", - ); - } - - public function testRenderWithAddAttributeUsingEnum(): void - { - self::assertSame( - << - - HTML, - Aside::tag() - ->addAttribute(GlobalAttribute::TITLE, 'value') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", - ); - } - public function testRenderWithAddDataAttribute(): void { self::assertSame( @@ -507,7 +479,7 @@ public function testRenderWithRemoveAttribute(): void HTML, Aside::tag() - ->addAttribute('data-test', 'value') + ->setAttribute('data-test', 'value') ->removeAttribute('data-test') ->render(), "Failed asserting that element renders correctly with 'removeAttribute()' method.", @@ -557,6 +529,34 @@ public function testRenderWithRoleUsingEnum(): void ); } + public function testRenderWithSetAttribute(): void + { + self::assertSame( + << + + HTML, + Aside::tag() + ->setAttribute('data-test', 'value') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method.", + ); + } + + public function testRenderWithSetAttributeUsingEnum(): void + { + self::assertSame( + << + + HTML, + Aside::tag() + ->setAttribute(GlobalAttribute::TITLE, 'value') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method using enum.", + ); + } + public function testRenderWithSpellcheck(): void { self::assertSame( diff --git a/tests/Sectioning/NavTest.php b/tests/Sectioning/NavTest.php index 1afd8d2..ef67fe8 100644 --- a/tests/Sectioning/NavTest.php +++ b/tests/Sectioning/NavTest.php @@ -61,7 +61,7 @@ public function testGetAttributesReturnsAssignedAttributes(): void self::assertSame( ['data-test' => 'value'], Nav::tag() - ->addAttribute('data-test', 'value') + ->setAttribute('data-test', 'value') ->getAttributes(), "Failed asserting that 'getAttributes()' returns the assigned attributes.", ); @@ -124,34 +124,6 @@ public function testRenderWithAddAriaAttributeUsingEnum(): void ); } - public function testRenderWithAddAttribute(): void - { - self::assertSame( - << - - HTML, - Nav::tag() - ->addAttribute('data-test', 'value') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method.", - ); - } - - public function testRenderWithAddAttributeUsingEnum(): void - { - self::assertSame( - << - - HTML, - Nav::tag() - ->addAttribute(GlobalAttribute::TITLE, 'value') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", - ); - } - public function testRenderWithAddDataAttribute(): void { self::assertSame( @@ -507,7 +479,7 @@ public function testRenderWithRemoveAttribute(): void HTML, Nav::tag() - ->addAttribute('data-test', 'value') + ->setAttribute('data-test', 'value') ->removeAttribute('data-test') ->render(), "Failed asserting that element renders correctly with 'removeAttribute()' method.", @@ -557,6 +529,34 @@ public function testRenderWithRoleUsingEnum(): void ); } + public function testRenderWithSetAttribute(): void + { + self::assertSame( + << + + HTML, + Nav::tag() + ->setAttribute('data-test', 'value') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method.", + ); + } + + public function testRenderWithSetAttributeUsingEnum(): void + { + self::assertSame( + << + + HTML, + Nav::tag() + ->setAttribute(GlobalAttribute::TITLE, 'value') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method using enum.", + ); + } + public function testRenderWithSpellcheck(): void { self::assertSame( diff --git a/tests/Sectioning/SectionTest.php b/tests/Sectioning/SectionTest.php index fd5c210..bcee112 100644 --- a/tests/Sectioning/SectionTest.php +++ b/tests/Sectioning/SectionTest.php @@ -61,7 +61,7 @@ public function testGetAttributesReturnsAssignedAttributes(): void self::assertSame( ['data-test' => 'value'], Section::tag() - ->addAttribute('data-test', 'value') + ->setAttribute('data-test', 'value') ->getAttributes(), "Failed asserting that 'getAttributes()' returns the assigned attributes.", ); @@ -124,34 +124,6 @@ public function testRenderWithAddAriaAttributeUsingEnum(): void ); } - public function testRenderWithAddAttribute(): void - { - self::assertSame( - << - - HTML, - Section::tag() - ->addAttribute('data-test', 'value') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method.", - ); - } - - public function testRenderWithAddAttributeUsingEnum(): void - { - self::assertSame( - << - - HTML, - Section::tag() - ->addAttribute(GlobalAttribute::TITLE, 'value') - ->render(), - "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", - ); - } - public function testRenderWithAddDataAttribute(): void { self::assertSame( @@ -507,7 +479,7 @@ public function testRenderWithRemoveAttribute(): void HTML, Section::tag() - ->addAttribute('data-test', 'value') + ->setAttribute('data-test', 'value') ->removeAttribute('data-test') ->render(), "Failed asserting that element renders correctly with 'removeAttribute()' method.", @@ -557,6 +529,34 @@ public function testRenderWithRoleUsingEnum(): void ); } + public function testRenderWithSetAttribute(): void + { + self::assertSame( + << + + HTML, + Section::tag() + ->setAttribute('data-test', 'value') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method.", + ); + } + + public function testRenderWithSetAttributeUsingEnum(): void + { + self::assertSame( + << + + HTML, + Section::tag() + ->setAttribute(GlobalAttribute::TITLE, 'value') + ->render(), + "Failed asserting that element renders correctly with 'setAttribute()' method using enum.", + ); + } + public function testRenderWithSpellcheck(): void { self::assertSame(