diff --git a/CHANGELOG.md b/CHANGELOG.md index 3858ea2..86a63f6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ - Enh #34: Add `InputHidden` class for HTML `` element with attributes and rendering capabilities (@terabytesoftw) - Enh #35: Add `InputRadio` class for HTML `` element with attributes and rendering capabilities (@terabytesoftw) - Enh #36: Add `InputNumber` class for HTML `` element with attributes and rendering capabilities (@terabytesoftw) +- Bug #37: Apply last changes from `ui-awesome/html-core` package to `ui-awesome/html` package (@terabytesoftw) ## 0.3.0 March 31, 2024 diff --git a/src/Form/InputCheckbox.php b/src/Form/InputCheckbox.php index 6a9dd23..7178533 100644 --- a/src/Form/InputCheckbox.php +++ b/src/Form/InputCheckbox.php @@ -133,7 +133,13 @@ protected function run(): string } if ($this->notLabel || $this->label === '') { - return $this->buildElement('', ['{label}' => '', '{unchecked}' => $unchecked]); + return $this->buildElement( + '', + [ + '{label}' => '', + '{unchecked}' => $unchecked, + ], + ); } $labelTag = Label::tag()->attributes($this->labelAttributes); @@ -156,11 +162,11 @@ protected function run(): string $labelTag = $labelTag ->html( - PHP_EOL, + "\n", Html::element($this->getTag(), '', $this->getAttributes()), - PHP_EOL, + "\n", $this->label, - PHP_EOL, + "\n", ); return $this->buildElement( diff --git a/src/Form/InputRadio.php b/src/Form/InputRadio.php index 56ff3ca..5d3129a 100644 --- a/src/Form/InputRadio.php +++ b/src/Form/InputRadio.php @@ -156,11 +156,11 @@ protected function run(): string $labelTag = $labelTag ->html( - PHP_EOL, + "\n", Html::element($this->getTag(), '', $this->getAttributes()), - PHP_EOL, + "\n", $this->label, - PHP_EOL, + "\n", ); return $this->buildElement( diff --git a/src/List/Dl.php b/src/List/Dl.php index 1ed4fd1..112f7a0 100644 --- a/src/List/Dl.php +++ b/src/List/Dl.php @@ -6,6 +6,7 @@ use Stringable; use UIAwesome\Html\Core\Element\BaseBlock; +use UIAwesome\Html\Helper\LineBreakNormalizer; use UIAwesome\Html\Interop\{BlockInterface, Lists}; /** @@ -47,7 +48,7 @@ public function dd(string|Stringable $content): static { $dd = Dd::tag()->content($content); - return $this->html($dd->render(), PHP_EOL); + return $this->html($dd->render(), "\n"); } /** @@ -67,7 +68,21 @@ public function dt(string|Stringable $content): static { $dt = Dt::tag()->content($content); - return $this->html($dt->render(), PHP_EOL); + return $this->html($dt->render(), "\n"); + } + + /** + * Cleans up the output after rendering the block element. + * + * Removes excessive consecutive newlines from the rendered output to ensure clean HTML structure. + * + * @param string $result Rendered HTML output. + * + * @return string Cleaned HTML output with excessive newlines removed. + */ + protected function afterRun(string $result): string + { + return parent::afterRun(LineBreakNormalizer::normalize($result)); } /** diff --git a/src/List/Ol.php b/src/List/Ol.php index 99e0354..10c555d 100644 --- a/src/List/Ol.php +++ b/src/List/Ol.php @@ -6,6 +6,7 @@ use Stringable; use UIAwesome\Html\Core\Element\BaseBlock; +use UIAwesome\Html\Helper\LineBreakNormalizer; use UIAwesome\Html\Interop\{BlockInterface, Lists}; use UIAwesome\Html\List\Attribute\{HasReversed, HasStart}; @@ -83,7 +84,21 @@ public function li(string|Stringable $content, int|string|null $value = null): s $li = $li->value($value); } - return $this->html($li->render(), PHP_EOL); + return $this->html($li->render(), "\n"); + } + + /** + * Cleans up the output after rendering the block element. + * + * Removes excessive consecutive newlines from the rendered output to ensure clean HTML structure. + * + * @param string $result Rendered HTML output. + * + * @return string Cleaned HTML output with excessive newlines removed. + */ + protected function afterRun(string $result): string + { + return parent::afterRun(LineBreakNormalizer::normalize($result)); } /** diff --git a/src/List/Ul.php b/src/List/Ul.php index fdbb596..6f0af3a 100644 --- a/src/List/Ul.php +++ b/src/List/Ul.php @@ -6,6 +6,7 @@ use Stringable; use UIAwesome\Html\Core\Element\BaseBlock; +use UIAwesome\Html\Helper\LineBreakNormalizer; use UIAwesome\Html\Interop\{BlockInterface, Lists}; /** @@ -77,7 +78,21 @@ public function li(string|Stringable $content, int|string|null $value = null): s $li = $li->value($value); } - return $this->html($li->render(), PHP_EOL); + return $this->html($li->render(), "\n"); + } + + /** + * Cleans up the output after rendering the block element. + * + * Removes excessive consecutive newlines from the rendered output to ensure clean HTML structure. + * + * @param string $result Rendered HTML output. + * + * @return string Cleaned HTML output with excessive newlines removed. + */ + protected function afterRun(string $result): string + { + return parent::afterRun(LineBreakNormalizer::normalize($result)); } /** diff --git a/tests/Embedded/ImgTest.php b/tests/Embedded/ImgTest.php index a0e0986..1f1e4d8 100644 --- a/tests/Embedded/ImgTest.php +++ b/tests/Embedded/ImgTest.php @@ -5,7 +5,6 @@ namespace UIAwesome\Html\Tests\Embedded; use InvalidArgumentException; -use PHPForge\Support\LineEndingNormalizer; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use UIAwesome\Html\Attribute\Values\{ @@ -44,7 +43,6 @@ * @copyright Copyright (C) 2026 Terabytesoftw. * @license https://opensource.org/license/bsd-3-clause BSD 3-Clause License. */ -#[Group('html')] #[Group('embedded')] final class ImgTest extends TestCase { @@ -61,7 +59,9 @@ public function testGetAttributesReturnsAssignedAttributes(): void { self::assertSame( ['data-test' => 'value'], - Img::tag()->addAttribute('data-test', 'value')->getAttributes(), + Img::tag() + ->addAttribute('data-test', 'value') + ->getAttributes(), "Failed asserting that 'getAttributes()' returns the assigned attributes.", ); } @@ -72,7 +72,9 @@ public function testRenderWithAccesskey(): void << HTML, - Img::tag()->accesskey('k')->render(), + Img::tag() + ->accesskey('k') + ->render(), "Failed asserting that element renders correctly with 'accesskey' attribute.", ); } @@ -83,7 +85,9 @@ public function testRenderWithAddAriaAttribute(): void << HTML, - Img::tag()->addAriaAttribute('pressed', true)->render(), + Img::tag() + ->addAriaAttribute('pressed', true) + ->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method.", ); } @@ -94,7 +98,9 @@ public function testRenderWithAddAriaAttributeUsingEnum(): void << HTML, - Img::tag()->addAriaAttribute(Aria::PRESSED, true)->render(), + Img::tag() + ->addAriaAttribute(Aria::PRESSED, true) + ->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method.", ); } @@ -105,7 +111,9 @@ public function testRenderWithAddAttribute(): void << HTML, - Img::tag()->addAttribute('data-test', 'value')->render(), + Img::tag() + ->addAttribute('data-test', 'value') + ->render(), "Failed asserting that element renders correctly with 'addAttribute()' method.", ); } @@ -116,7 +124,9 @@ public function testRenderWithAddAttributeUsingEnum(): void << HTML, - Img::tag()->addAttribute(GlobalAttribute::TITLE, 'value')->render(), + Img::tag() + ->addAttribute(GlobalAttribute::TITLE, 'value') + ->render(), "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", ); } @@ -127,7 +137,9 @@ public function testRenderWithAddDataAttribute(): void << HTML, - Img::tag()->addDataAttribute('value', 'value')->render(), + Img::tag() + ->addDataAttribute('value', 'value') + ->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method.", ); } @@ -138,7 +150,9 @@ public function testRenderWithAddDataAttributeUsingEnum(): void << HTML, - Img::tag()->addDataAttribute(Data::VALUE, 'value')->render(), + Img::tag() + ->addDataAttribute(Data::VALUE, 'value') + ->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method.", ); } @@ -149,7 +163,9 @@ public function testRenderWithAlt(): void << HTML, - Img::tag()->alt('A beautiful landscape')->render(), + Img::tag() + ->alt('A beautiful landscape') + ->render(), "Failed asserting that element renders correctly with 'alt' attribute.", ); } @@ -160,13 +176,14 @@ public function testRenderWithAriaAttributes(): void << HTML, - Img::tag()->ariaAttributes( - [ - 'controls' => static fn(): string => 'modal-1', - 'hidden' => false, - 'label' => 'Close', - ], - ) + Img::tag() + ->ariaAttributes( + [ + 'controls' => static fn(): string => 'modal-1', + 'hidden' => false, + 'label' => 'Close', + ], + ) ->render(), "Failed asserting that element renders correctly with 'ariaAttributes()' method.", ); @@ -178,7 +195,9 @@ public function testRenderWithAttributes(): void << HTML, - Img::tag()->attributes(['class' => 'value'])->render(), + Img::tag() + ->attributes(['class' => 'value']) + ->render(), "Failed asserting that element renders correctly with 'attributes()' method.", ); } @@ -189,7 +208,9 @@ public function testRenderWithClass(): void << HTML, - Img::tag()->class('value')->render(), + Img::tag() + ->class('value') + ->render(), "Failed asserting that element renders correctly with 'class' attribute.", ); } @@ -200,7 +221,9 @@ public function testRenderWithCrossorigin(): void << HTML, - Img::tag()->crossorigin('anonymous')->render(), + Img::tag() + ->crossorigin('anonymous') + ->render(), "Failed asserting that element renders correctly with 'crossorigin' attribute.", ); } @@ -211,7 +234,9 @@ public function testRenderWithCrossoriginUsingEnum(): void << HTML, - Img::tag()->crossorigin(Crossorigin::USE_CREDENTIALS)->render(), + Img::tag() + ->crossorigin(Crossorigin::USE_CREDENTIALS) + ->render(), "Failed asserting that element renders correctly with 'crossorigin' attribute using enum.", ); } @@ -222,7 +247,9 @@ public function testRenderWithDataAttributes(): void << HTML, - Img::tag()->dataAttributes(['value' => 'value'])->render(), + Img::tag() + ->dataAttributes(['value' => 'value']) + ->render(), "Failed asserting that element renders correctly with 'dataAttributes()' method.", ); } @@ -233,7 +260,9 @@ public function testRenderWithDecoding(): void << HTML, - Img::tag()->decoding('async')->render(), + Img::tag() + ->decoding('async') + ->render(), "Failed asserting that element renders correctly with 'decoding' attribute.", ); } @@ -244,7 +273,9 @@ public function testRenderWithDecodingUsingEnum(): void << HTML, - Img::tag()->decoding(Decoding::SYNC)->render(), + Img::tag() + ->decoding(Decoding::SYNC) + ->render(), "Failed asserting that element renders correctly with 'decoding' attribute using enum.", ); } @@ -266,7 +297,9 @@ public function testRenderWithDefaultProvider(): void << HTML, - Img::tag()->addDefaultProvider(DefaultProvider::class)->render(), + Img::tag() + ->addDefaultProvider(DefaultProvider::class) + ->render(), 'Failed asserting that default provider is applied correctly.', ); } @@ -288,7 +321,9 @@ public function testRenderWithDir(): void << HTML, - Img::tag()->dir('ltr')->render(), + Img::tag() + ->dir('ltr') + ->render(), "Failed asserting that element renders correctly with 'dir' attribute.", ); } @@ -299,7 +334,9 @@ public function testRenderWithDirUsingEnum(): void << HTML, - Img::tag()->dir(Direction::LTR)->render(), + Img::tag() + ->dir(Direction::LTR) + ->render(), "Failed asserting that element renders correctly with 'dir' attribute using enum.", ); } @@ -310,7 +347,9 @@ public function testRenderWithElementtiming(): void << HTML, - Img::tag()->elementtiming('hero-image')->render(), + Img::tag() + ->elementtiming('hero-image') + ->render(), "Failed asserting that element renders correctly with 'elementtiming' attribute.", ); } @@ -321,7 +360,9 @@ public function testRenderWithFetchpriority(): void << HTML, - Img::tag()->fetchpriority('high')->render(), + Img::tag() + ->fetchpriority('high') + ->render(), "Failed asserting that element renders correctly with 'fetchpriority' attribute.", ); } @@ -332,7 +373,9 @@ public function testRenderWithFetchpriorityUsingEnum(): void << HTML, - Img::tag()->fetchpriority(Fetchpriority::LOW)->render(), + Img::tag() + ->fetchpriority(Fetchpriority::LOW) + ->render(), "Failed asserting that element renders correctly with 'fetchpriority' attribute using enum.", ); } @@ -356,7 +399,9 @@ public function testRenderWithHeight(): void << HTML, - Img::tag()->height(600)->render(), + Img::tag() + ->height(600) + ->render(), "Failed asserting that element renders correctly with 'height' attribute.", ); } @@ -367,7 +412,9 @@ public function testRenderWithHidden(): void << HTML, - Img::tag()->hidden(true)->render(), + Img::tag() + ->hidden(true) + ->render(), "Failed asserting that element renders correctly with 'hidden' attribute.", ); } @@ -378,7 +425,9 @@ public function testRenderWithId(): void << HTML, - Img::tag()->id('test-id')->render(), + Img::tag() + ->id('test-id') + ->render(), "Failed asserting that element renders correctly with 'id' attribute.", ); } @@ -389,7 +438,9 @@ public function testRenderWithIsmap(): void << HTML, - Img::tag()->ismap(true)->render(), + Img::tag() + ->ismap(true) + ->render(), "Failed asserting that element renders correctly with 'ismap' attribute.", ); } @@ -400,7 +451,9 @@ public function testRenderWithIsmapFalse(): void << HTML, - Img::tag()->ismap(false)->render(), + Img::tag() + ->ismap(false) + ->render(), "Failed asserting that element renders correctly with 'ismap' attribute set to false.", ); } @@ -411,7 +464,9 @@ public function testRenderWithLang(): void << HTML, - Img::tag()->lang('es')->render(), + Img::tag() + ->lang('es') + ->render(), "Failed asserting that element renders correctly with 'lang' attribute.", ); } @@ -422,7 +477,9 @@ public function testRenderWithLangUsingEnum(): void << HTML, - Img::tag()->lang(Language::SPANISH)->render(), + Img::tag() + ->lang(Language::SPANISH) + ->render(), "Failed asserting that element renders correctly with 'lang' attribute using enum.", ); } @@ -433,7 +490,9 @@ public function testRenderWithLoading(): void << HTML, - Img::tag()->loading('lazy')->render(), + Img::tag() + ->loading('lazy') + ->render(), "Failed asserting that element renders correctly with 'loading' attribute.", ); } @@ -444,7 +503,9 @@ public function testRenderWithLoadingUsingEnum(): void << HTML, - Img::tag()->loading(Loading::EAGER)->render(), + Img::tag() + ->loading(Loading::EAGER) + ->render(), "Failed asserting that element renders correctly with 'loading' attribute using enum.", ); } @@ -455,7 +516,9 @@ public function testRenderWithReferrerpolicy(): void << HTML, - Img::tag()->referrerpolicy('no-referrer')->render(), + Img::tag() + ->referrerpolicy('no-referrer') + ->render(), "Failed asserting that element renders correctly with 'referrerpolicy' attribute.", ); } @@ -466,7 +529,9 @@ public function testRenderWithReferrerpolicyUsingEnum(): void << HTML, - Img::tag()->referrerpolicy(Referrerpolicy::ORIGIN)->render(), + Img::tag() + ->referrerpolicy(Referrerpolicy::ORIGIN) + ->render(), "Failed asserting that element renders correctly with 'referrerpolicy' attribute using enum.", ); } @@ -519,7 +584,9 @@ public function testRenderWithRole(): void << HTML, - Img::tag()->role('banner')->render(), + Img::tag() + ->role('banner') + ->render(), "Failed asserting that element renders correctly with 'role' attribute.", ); } @@ -530,7 +597,9 @@ public function testRenderWithRoleUsingEnum(): void << HTML, - Img::tag()->role(Role::BANNER)->render(), + Img::tag() + ->role(Role::BANNER) + ->render(), "Failed asserting that element renders correctly with 'role' attribute using enum.", ); } @@ -541,7 +610,9 @@ public function testRenderWithSizes(): void << HTML, - Img::tag()->sizes('(max-width: 600px) 100vw, 50vw')->render(), + Img::tag() + ->sizes('(max-width: 600px) 100vw, 50vw') + ->render(), "Failed asserting that element renders correctly with 'sizes' attribute.", ); } @@ -552,7 +623,9 @@ public function testRenderWithSrc(): void << HTML, - Img::tag()->src('image.jpg')->render(), + Img::tag() + ->src('image.jpg') + ->render(), "Failed asserting that element renders correctly with 'src' attribute.", ); } @@ -563,7 +636,9 @@ public function testRenderWithSrcset(): void << HTML, - Img::tag()->srcset('image-320w.jpg 320w, image-480w.jpg 480w')->render(), + Img::tag() + ->srcset('image-320w.jpg 320w, image-480w.jpg 480w') + ->render(), "Failed asserting that element renders correctly with 'srcset' attribute.", ); } @@ -574,7 +649,9 @@ public function testRenderWithStyle(): void << HTML, - Img::tag()->style('value')->render(), + Img::tag() + ->style('value') + ->render(), "Failed asserting that element renders correctly with 'style' attribute.", ); } @@ -585,7 +662,9 @@ public function testRenderWithThemeProvider(): void << HTML, - Img::tag()->addThemeProvider('muted', DefaultThemeProvider::class)->render(), + Img::tag() + ->addThemeProvider('muted', DefaultThemeProvider::class) + ->render(), "Failed asserting that element renders correctly with 'addThemeProvider()' method.", ); } @@ -596,7 +675,9 @@ public function testRenderWithTitle(): void << HTML, - Img::tag()->title('value')->render(), + Img::tag() + ->title('value') + ->render(), "Failed asserting that element renders correctly with 'title' attribute.", ); } @@ -605,9 +686,7 @@ public function testRenderWithToString(): void { self::assertSame( '', - LineEndingNormalizer::normalize( - (string) Img::tag(), - ), + (string) Img::tag(), "Failed asserting that '__toString()' method renders correctly.", ); } @@ -618,7 +697,9 @@ public function testRenderWithTranslate(): void << HTML, - Img::tag()->translate(false)->render(), + Img::tag() + ->translate(false) + ->render(), "Failed asserting that element renders correctly with 'translate' attribute.", ); } @@ -629,7 +710,9 @@ public function testRenderWithTranslateUsingEnum(): void << HTML, - Img::tag()->translate(Translate::NO)->render(), + Img::tag() + ->translate(Translate::NO) + ->render(), "Failed asserting that element renders correctly with 'translate' attribute using enum.", ); } @@ -640,7 +723,9 @@ public function testRenderWithUsemap(): void << HTML, - Img::tag()->usemap('#map')->render(), + Img::tag() + ->usemap('#map') + ->render(), "Failed asserting that element renders correctly with 'usemap' attribute.", ); } @@ -666,7 +751,9 @@ public function testRenderWithWidth(): void << HTML, - Img::tag()->width(800)->render(), + Img::tag() + ->width(800) + ->render(), "Failed asserting that element renders correctly with 'width' attribute.", ); } diff --git a/tests/Flow/DivTest.php b/tests/Flow/DivTest.php index e7f5845..547b908 100644 --- a/tests/Flow/DivTest.php +++ b/tests/Flow/DivTest.php @@ -4,7 +4,6 @@ namespace UIAwesome\Html\Tests\Flow; -use PHPForge\Support\LineEndingNormalizer; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use UIAwesome\Html\Attribute\Values\{ @@ -34,17 +33,16 @@ * @copyright Copyright (C) 2026 Terabytesoftw. * @license https://opensource.org/license/bsd-3-clause BSD 3-Clause License. */ -#[Group('html')] #[Group('flow')] final class DivTest extends TestCase { public function testContentEncodesValues(): void { - $div = Div::tag()->content(''); - self::assertSame( '<value>', - $div->getContent(), + Div::tag() + ->content('') + ->getContent(), "Failed asserting that 'content()' method encodes values correctly.", ); } @@ -62,7 +60,9 @@ public function testGetAttributesReturnsAssignedAttributes(): void { self::assertSame( ['data-test' => 'value'], - Div::tag()->addAttribute('data-test', 'value')->getAttributes(), + Div::tag() + ->addAttribute('data-test', 'value') + ->getAttributes(), "Failed asserting that 'getAttributes()' returns the assigned attributes.", ); } @@ -75,9 +75,9 @@ public function testHtmlDoesNotEncodeValues(): void HTML, - LineEndingNormalizer::normalize( - Div::tag()->html('')->render(), - ), + Div::tag() + ->html('') + ->render(), "Failed asserting that element renders correctly with 'html()' method.", ); } @@ -89,9 +89,9 @@ public function testRenderWithAccesskey(): void
HTML, - LineEndingNormalizer::normalize( - Div::tag()->accesskey('k')->render(), - ), + Div::tag() + ->accesskey('k') + ->render(), "Failed asserting that element renders correctly with 'accesskey' attribute.", ); } @@ -103,9 +103,9 @@ public function testRenderWithAddAriaAttribute(): void
HTML, - LineEndingNormalizer::normalize( - Div::tag()->addAriaAttribute('pressed', true)->render(), - ), + Div::tag() + ->addAriaAttribute('pressed', true) + ->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method.", ); } @@ -117,9 +117,9 @@ public function testRenderWithAddAriaAttributeUsingEnum(): void
HTML, - LineEndingNormalizer::normalize( - Div::tag()->addAriaAttribute(Aria::PRESSED, true)->render(), - ), + Div::tag() + ->addAriaAttribute(Aria::PRESSED, true) + ->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method.", ); } @@ -131,9 +131,9 @@ public function testRenderWithAddAttribute(): void
HTML, - LineEndingNormalizer::normalize( - Div::tag()->addAttribute('data-test', 'value')->render(), - ), + Div::tag() + ->addAttribute('data-test', 'value') + ->render(), "Failed asserting that element renders correctly with 'addAttribute()' method.", ); } @@ -145,9 +145,9 @@ public function testRenderWithAddAttributeUsingEnum(): void
HTML, - LineEndingNormalizer::normalize( - Div::tag()->addAttribute(GlobalAttribute::TITLE, 'value')->render(), - ), + Div::tag() + ->addAttribute(GlobalAttribute::TITLE, 'value') + ->render(), "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", ); } @@ -159,9 +159,9 @@ public function testRenderWithAddDataAttribute(): void
HTML, - LineEndingNormalizer::normalize( - Div::tag()->addDataAttribute('value', 'value')->render(), - ), + Div::tag() + ->addDataAttribute('value', 'value') + ->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method.", ); } @@ -173,9 +173,9 @@ public function testRenderWithAddDataAttributeUsingEnum(): void
HTML, - LineEndingNormalizer::normalize( - Div::tag()->addDataAttribute(Data::VALUE, 'value')->render(), - ), + Div::tag() + ->addDataAttribute(Data::VALUE, 'value') + ->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method.", ); } @@ -187,17 +187,15 @@ public function testRenderWithAriaAttributes(): void
HTML, - LineEndingNormalizer::normalize( - Div::tag() - ->ariaAttributes( - [ - 'controls' => static fn(): string => 'modal-1', - 'hidden' => false, - 'label' => 'Close', - ], - ) - ->render(), - ), + Div::tag() + ->ariaAttributes( + [ + 'controls' => static fn(): string => 'modal-1', + 'hidden' => false, + 'label' => 'Close', + ], + ) + ->render(), "Failed asserting that element renders correctly with 'ariaAttributes()' method.", ); } @@ -209,9 +207,9 @@ public function testRenderWithAttributes(): void
HTML, - LineEndingNormalizer::normalize( - Div::tag()->attributes(['class' => 'value'])->render(), - ), + Div::tag() + ->attributes(['class' => 'value']) + ->render(), "Failed asserting that element renders correctly with 'attributes()' method.", ); } @@ -223,9 +221,9 @@ public function testRenderWithAutofocus(): void
HTML, - LineEndingNormalizer::normalize( - Div::tag()->autofocus(true)->render(), - ), + Div::tag() + ->autofocus(true) + ->render(), "Failed asserting that element renders correctly with 'autofocus' attribute.", ); } @@ -238,9 +236,7 @@ public function testRenderWithBeginEnd(): void Content HTML, - LineEndingNormalizer::normalize( - Div::tag()->begin() . 'Content' . Div::end(), - ), + Div::tag()->begin() . 'Content' . Div::end(), "Failed asserting that element renders correctly with 'begin()' and 'end()' methods.", ); } @@ -252,9 +248,9 @@ public function testRenderWithClass(): void
HTML, - LineEndingNormalizer::normalize( - Div::tag()->class('value')->render(), - ), + Div::tag() + ->class('value') + ->render(), "Failed asserting that element renders correctly with 'class' attribute.", ); } @@ -267,9 +263,9 @@ public function testRenderWithContent(): void value HTML, - LineEndingNormalizer::normalize( - Div::tag()->content('value')->render(), - ), + Div::tag() + ->content('value') + ->render(), 'Failed asserting that element renders correctly with default values.', ); } @@ -281,9 +277,9 @@ public function testRenderWithContentEditable(): void
HTML, - LineEndingNormalizer::normalize( - Div::tag()->contentEditable(true)->render(), - ), + Div::tag() + ->contentEditable(true) + ->render(), "Failed asserting that element renders correctly with 'contentEditable' attribute.", ); } @@ -295,9 +291,9 @@ public function testRenderWithContentEditableUsingEnum(): void
HTML, - LineEndingNormalizer::normalize( - Div::tag()->contentEditable(ContentEditable::TRUE)->render(), - ), + Div::tag() + ->contentEditable(ContentEditable::TRUE) + ->render(), "Failed asserting that element renders correctly with 'contentEditable' attribute using enum.", ); } @@ -309,9 +305,9 @@ public function testRenderWithDataAttributes(): void
HTML, - LineEndingNormalizer::normalize( - Div::tag()->dataAttributes(['value' => 'value'])->render(), - ), + Div::tag() + ->dataAttributes(['value' => 'value']) + ->render(), "Failed asserting that element renders correctly with 'dataAttributes()' method.", ); } @@ -323,9 +319,7 @@ public function testRenderWithDefaultConfigurationValues(): void
HTML, - LineEndingNormalizer::normalize( - Div::tag(['class' => 'default-class'])->render(), - ), + Div::tag(['class' => 'default-class'])->render(), 'Failed asserting that default configuration values are applied correctly.', ); } @@ -337,9 +331,9 @@ public function testRenderWithDefaultProvider(): void
HTML, - LineEndingNormalizer::normalize( - Div::tag()->addDefaultProvider(DefaultProvider::class)->render(), - ), + Div::tag() + ->addDefaultProvider(DefaultProvider::class) + ->render(), 'Failed asserting that default provider is applied correctly.', ); } @@ -351,9 +345,9 @@ public function testRenderWithDir(): void
HTML, - LineEndingNormalizer::normalize( - Div::tag()->dir('ltr')->render(), - ), + Div::tag() + ->dir('ltr') + ->render(), "Failed asserting that element renders correctly with 'dir' attribute.", ); } @@ -365,9 +359,9 @@ public function testRenderWithDirUsingEnum(): void
HTML, - LineEndingNormalizer::normalize( - Div::tag()->dir(Direction::LTR)->render(), - ), + Div::tag() + ->dir(Direction::LTR) + ->render(), "Failed asserting that element renders correctly with 'dir' attribute using enum.", ); } @@ -379,9 +373,9 @@ public function testRenderWithDraggable(): void
HTML, - LineEndingNormalizer::normalize( - Div::tag()->draggable(true)->render(), - ), + Div::tag() + ->draggable(true) + ->render(), "Failed asserting that element renders correctly with 'draggable' attribute.", ); } @@ -393,9 +387,9 @@ public function testRenderWithDraggableUsingEnum(): void
HTML, - LineEndingNormalizer::normalize( - Div::tag()->draggable(Draggable::TRUE)->render(), - ), + Div::tag() + ->draggable(Draggable::TRUE) + ->render(), "Failed asserting that element renders correctly with 'draggable' attribute using enum.", ); } @@ -409,9 +403,7 @@ public function testRenderWithGlobalDefaultsAreApplied(): void
HTML, - LineEndingNormalizer::normalize( - Div::tag()->render(), - ), + Div::tag()->render(), 'Failed asserting that global defaults are applied correctly.', ); @@ -425,9 +417,9 @@ public function testRenderWithHidden(): void HTML, - LineEndingNormalizer::normalize( - Div::tag()->hidden(true)->render(), - ), + Div::tag() + ->hidden(true) + ->render(), "Failed asserting that element renders correctly with 'hidden' attribute.", ); } @@ -439,9 +431,9 @@ public function testRenderWithId(): void
HTML, - LineEndingNormalizer::normalize( - Div::tag()->id('test-id')->render(), - ), + Div::tag() + ->id('test-id') + ->render(), "Failed asserting that element renders correctly with 'id' attribute.", ); } @@ -453,9 +445,9 @@ public function testRenderWithLang(): void
HTML, - LineEndingNormalizer::normalize( - Div::tag()->lang('es')->render(), - ), + Div::tag() + ->lang('es') + ->render(), "Failed asserting that element renders correctly with 'lang' attribute.", ); } @@ -467,9 +459,9 @@ public function testRenderWithLangUsingEnum(): void
HTML, - LineEndingNormalizer::normalize( - Div::tag()->lang(Language::SPANISH)->render(), - ), + Div::tag() + ->lang(Language::SPANISH) + ->render(), "Failed asserting that element renders correctly with 'lang' attribute using enum.", ); } @@ -481,15 +473,13 @@ public function testRenderWithMicroData(): void
HTML, - LineEndingNormalizer::normalize( - Div::tag() - ->itemId('https://example.com/item') - ->itemProp('name') - ->itemRef('info') - ->itemScope(true) - ->itemType('https://schema.org/Thing') - ->render(), - ), + Div::tag() + ->itemId('https://example.com/item') + ->itemProp('name') + ->itemRef('info') + ->itemScope(true) + ->itemType('https://schema.org/Thing') + ->render(), 'Failed asserting that element renders correctly with microdata attributes.', ); } @@ -501,12 +491,10 @@ public function testRenderWithRemoveAriaAttribute(): void
HTML, - LineEndingNormalizer::normalize( - Div::tag() - ->addAriaAttribute('label', 'Close') - ->removeAriaAttribute('label') - ->render(), - ), + Div::tag() + ->addAriaAttribute('label', 'Close') + ->removeAriaAttribute('label') + ->render(), "Failed asserting that element renders correctly with 'removeAriaAttribute()' method.", ); } @@ -518,12 +506,10 @@ public function testRenderWithRemoveAttribute(): void
HTML, - LineEndingNormalizer::normalize( - Div::tag() - ->addAttribute('data-test', 'value') - ->removeAttribute('data-test') - ->render(), - ), + Div::tag() + ->addAttribute('data-test', 'value') + ->removeAttribute('data-test') + ->render(), "Failed asserting that element renders correctly with 'removeAttribute()' method.", ); } @@ -535,12 +521,10 @@ public function testRenderWithRemoveDataAttribute(): void
HTML, - LineEndingNormalizer::normalize( - Div::tag() - ->addDataAttribute('value', 'test') - ->removeDataAttribute('value') - ->render(), - ), + Div::tag() + ->addDataAttribute('value', 'test') + ->removeDataAttribute('value') + ->render(), "Failed asserting that element renders correctly with 'removeDataAttribute()' method.", ); } @@ -552,9 +536,9 @@ public function testRenderWithRole(): void
HTML, - LineEndingNormalizer::normalize( - Div::tag()->role('banner')->render(), - ), + Div::tag() + ->role('banner') + ->render(), "Failed asserting that element renders correctly with 'role' attribute.", ); } @@ -566,9 +550,9 @@ public function testRenderWithRoleUsingEnum(): void
HTML, - LineEndingNormalizer::normalize( - Div::tag()->role(Role::BANNER)->render(), - ), + Div::tag() + ->role(Role::BANNER) + ->render(), "Failed asserting that element renders correctly with 'role' attribute using enum.", ); } @@ -580,9 +564,9 @@ public function testRenderWithSpellcheck(): void
HTML, - LineEndingNormalizer::normalize( - Div::tag()->spellcheck(true)->render(), - ), + Div::tag() + ->spellcheck(true) + ->render(), "Failed asserting that element renders correctly with 'spellcheck' attribute.", ); } @@ -594,9 +578,9 @@ public function testRenderWithStyle(): void
HTML, - LineEndingNormalizer::normalize( - Div::tag()->style('value')->render(), - ), + Div::tag() + ->style('value') + ->render(), "Failed asserting that element renders correctly with 'style' attribute.", ); } @@ -608,9 +592,9 @@ public function testRenderWithTabindex(): void
HTML, - LineEndingNormalizer::normalize( - Div::tag()->tabIndex(3)->render(), - ), + Div::tag() + ->tabIndex(3) + ->render(), "Failed asserting that element renders correctly with 'tabindex' attribute.", ); } @@ -622,9 +606,9 @@ public function testRenderWithThemeProvider(): void
HTML, - LineEndingNormalizer::normalize( - Div::tag()->addThemeProvider('muted', DefaultThemeProvider::class)->render(), - ), + Div::tag() + ->addThemeProvider('muted', DefaultThemeProvider::class) + ->render(), "Failed asserting that element renders correctly with 'addThemeProvider()' method.", ); } @@ -636,7 +620,9 @@ public function testRenderWithTitle(): void
HTML, - Div::tag()->title('value')->render(), + Div::tag() + ->title('value') + ->render(), "Failed asserting that element renders correctly with 'title' attribute.", ); } @@ -648,9 +634,7 @@ public function testRenderWithToString(): void
HTML, - LineEndingNormalizer::normalize( - (string) Div::tag(), - ), + (string) Div::tag(), "Failed asserting that '__toString()' method renders correctly.", ); } @@ -662,9 +646,9 @@ public function testRenderWithTranslate(): void
HTML, - LineEndingNormalizer::normalize( - Div::tag()->translate(false)->render(), - ), + Div::tag() + ->translate(false) + ->render(), "Failed asserting that element renders correctly with 'translate' attribute.", ); } @@ -676,9 +660,9 @@ public function testRenderWithTranslateUsingEnum(): void
HTML, - LineEndingNormalizer::normalize( - Div::tag()->translate(Translate::NO)->render(), - ), + Div::tag() + ->translate(Translate::NO) + ->render(), "Failed asserting that element renders correctly with 'translate' attribute using enum.", ); } @@ -692,9 +676,7 @@ public function testRenderWithUserOverridesGlobalDefaults(): void
HTML, - LineEndingNormalizer::normalize( - Div::tag(['id' => 'id-user'])->render(), - ), + Div::tag(['id' => 'id-user'])->render(), 'Failed asserting that user-defined attributes override global defaults correctly.', ); diff --git a/tests/Flow/HrTest.php b/tests/Flow/HrTest.php index edf3dc1..b7fb0f4 100644 --- a/tests/Flow/HrTest.php +++ b/tests/Flow/HrTest.php @@ -4,7 +4,6 @@ namespace UIAwesome\Html\Tests\Flow; -use PHPForge\Support\LineEndingNormalizer; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use UIAwesome\Html\Attribute\Values\{ @@ -32,7 +31,6 @@ * @copyright Copyright (C) 2026 Terabytesoftw. * @license https://opensource.org/license/bsd-3-clause BSD 3-Clause License. */ -#[Group('html')] #[Group('flow')] final class HrTest extends TestCase { @@ -49,7 +47,9 @@ public function testGetAttributesReturnsAssignedAttributes(): void { self::assertSame( ['data-test' => 'value'], - Hr::tag()->addAttribute('data-test', 'value')->getAttributes(), + Hr::tag() + ->addAttribute('data-test', 'value') + ->getAttributes(), "Failed asserting that 'getAttributes()' returns the assigned attributes.", ); } @@ -60,7 +60,9 @@ public function testRenderWithAccesskey(): void << HTML, - Hr::tag()->accesskey('k')->render(), + Hr::tag() + ->accesskey('k') + ->render(), "Failed asserting that element renders correctly with 'accesskey' attribute.", ); } @@ -71,7 +73,9 @@ public function testRenderWithAddAriaAttribute(): void << HTML, - Hr::tag()->addAriaAttribute('pressed', true)->render(), + Hr::tag() + ->addAriaAttribute('pressed', true) + ->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method.", ); } @@ -82,7 +86,9 @@ public function testRenderWithAddAriaAttributeUsingEnum(): void << HTML, - Hr::tag()->addAriaAttribute(Aria::PRESSED, true)->render(), + Hr::tag() + ->addAriaAttribute(Aria::PRESSED, true) + ->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method.", ); } @@ -93,7 +99,9 @@ public function testRenderWithAddAttribute(): void << HTML, - Hr::tag()->addAttribute('data-test', 'value')->render(), + Hr::tag() + ->addAttribute('data-test', 'value') + ->render(), "Failed asserting that element renders correctly with 'addAttribute()' method.", ); } @@ -104,7 +112,9 @@ public function testRenderWithAddAttributeUsingEnum(): void << HTML, - Hr::tag()->addAttribute(GlobalAttribute::TITLE, 'value')->render(), + Hr::tag() + ->addAttribute(GlobalAttribute::TITLE, 'value') + ->render(), "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", ); } @@ -115,7 +125,9 @@ public function testRenderWithAddDataAttribute(): void << HTML, - Hr::tag()->addDataAttribute('value', 'value')->render(), + Hr::tag() + ->addDataAttribute('value', 'value') + ->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method.", ); } @@ -126,7 +138,9 @@ public function testRenderWithAddDataAttributeUsingEnum(): void << HTML, - Hr::tag()->addDataAttribute(Data::VALUE, 'value')->render(), + Hr::tag() + ->addDataAttribute(Data::VALUE, 'value') + ->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method.", ); } @@ -137,13 +151,14 @@ public function testRenderWithAriaAttributes(): void << HTML, - Hr::tag()->ariaAttributes( - [ - 'controls' => static fn(): string => 'modal-1', - 'hidden' => false, - 'label' => 'Close', - ], - ) + Hr::tag() + ->ariaAttributes( + [ + 'controls' => static fn(): string => 'modal-1', + 'hidden' => false, + 'label' => 'Close', + ], + ) ->render(), "Failed asserting that element renders correctly with 'ariaAttributes()' method.", ); @@ -155,7 +170,9 @@ public function testRenderWithAttributes(): void << HTML, - Hr::tag()->attributes(['class' => 'value'])->render(), + Hr::tag() + ->attributes(['class' => 'value']) + ->render(), "Failed asserting that element renders correctly with 'attributes()' method.", ); } @@ -166,7 +183,9 @@ public function testRenderWithClass(): void << HTML, - Hr::tag()->class('value')->render(), + Hr::tag() + ->class('value') + ->render(), "Failed asserting that element renders correctly with 'class' attribute.", ); } @@ -177,7 +196,9 @@ public function testRenderWithDataAttributes(): void << HTML, - Hr::tag()->dataAttributes(['value' => 'value'])->render(), + Hr::tag() + ->dataAttributes(['value' => 'value']) + ->render(), "Failed asserting that element renders correctly with 'dataAttributes()' method.", ); } @@ -199,7 +220,9 @@ public function testRenderWithDefaultProvider(): void << HTML, - Hr::tag()->addDefaultProvider(DefaultProvider::class)->render(), + Hr::tag() + ->addDefaultProvider(DefaultProvider::class) + ->render(), 'Failed asserting that default provider is applied correctly.', ); } @@ -221,7 +244,9 @@ public function testRenderWithDir(): void << HTML, - Hr::tag()->dir('ltr')->render(), + Hr::tag() + ->dir('ltr') + ->render(), "Failed asserting that element renders correctly with 'dir' attribute.", ); } @@ -232,7 +257,9 @@ public function testRenderWithDirUsingEnum(): void << HTML, - Hr::tag()->dir(Direction::LTR)->render(), + Hr::tag() + ->dir(Direction::LTR) + ->render(), "Failed asserting that element renders correctly with 'dir' attribute using enum.", ); } @@ -256,7 +283,9 @@ public function testRenderWithHidden(): void << HTML, - Hr::tag()->hidden(true)->render(), + Hr::tag() + ->hidden(true) + ->render(), "Failed asserting that element renders correctly with 'hidden' attribute.", ); } @@ -267,7 +296,9 @@ public function testRenderWithId(): void << HTML, - Hr::tag()->id('test-id')->render(), + Hr::tag() + ->id('test-id') + ->render(), "Failed asserting that element renders correctly with 'id' attribute.", ); } @@ -278,7 +309,9 @@ public function testRenderWithLang(): void << HTML, - Hr::tag()->lang('es')->render(), + Hr::tag() + ->lang('es') + ->render(), "Failed asserting that element renders correctly with 'lang' attribute.", ); } @@ -289,7 +322,9 @@ public function testRenderWithLangUsingEnum(): void << HTML, - Hr::tag()->lang(Language::SPANISH)->render(), + Hr::tag() + ->lang(Language::SPANISH) + ->render(), "Failed asserting that element renders correctly with 'lang' attribute using enum.", ); } @@ -342,7 +377,9 @@ public function testRenderWithRole(): void << HTML, - Hr::tag()->role('banner')->render(), + Hr::tag() + ->role('banner') + ->render(), "Failed asserting that element renders correctly with 'role' attribute.", ); } @@ -353,7 +390,9 @@ public function testRenderWithRoleUsingEnum(): void << HTML, - Hr::tag()->role(Role::BANNER)->render(), + Hr::tag() + ->role(Role::BANNER) + ->render(), "Failed asserting that element renders correctly with 'role' attribute using enum.", ); } @@ -364,7 +403,9 @@ public function testRenderWithStyle(): void << HTML, - Hr::tag()->style('value')->render(), + Hr::tag() + ->style('value') + ->render(), "Failed asserting that element renders correctly with 'style' attribute.", ); } @@ -375,7 +416,9 @@ public function testRenderWithThemeProvider(): void << HTML, - Hr::tag()->addThemeProvider('muted', DefaultThemeProvider::class)->render(), + Hr::tag() + ->addThemeProvider('muted', DefaultThemeProvider::class) + ->render(), "Failed asserting that element renders correctly with 'addThemeProvider()' method.", ); } @@ -386,7 +429,9 @@ public function testRenderWithTitle(): void << HTML, - Hr::tag()->title('value')->render(), + Hr::tag() + ->title('value') + ->render(), "Failed asserting that element renders correctly with 'title' attribute.", ); } @@ -395,9 +440,7 @@ public function testRenderWithToString(): void { self::assertSame( '
', - LineEndingNormalizer::normalize( - (string) Hr::tag(), - ), + (string) Hr::tag(), "Failed asserting that '__toString()' method renders correctly.", ); } @@ -408,7 +451,9 @@ public function testRenderWithTranslate(): void << HTML, - Hr::tag()->translate(false)->render(), + Hr::tag() + ->translate(false) + ->render(), "Failed asserting that element renders correctly with 'translate' attribute.", ); } @@ -419,7 +464,9 @@ public function testRenderWithTranslateUsingEnum(): void << HTML, - Hr::tag()->translate(Translate::NO)->render(), + Hr::tag() + ->translate(Translate::NO) + ->render(), "Failed asserting that element renders correctly with 'translate' attribute using enum.", ); } diff --git a/tests/Flow/MainTest.php b/tests/Flow/MainTest.php index fc2aa82..6556b8a 100644 --- a/tests/Flow/MainTest.php +++ b/tests/Flow/MainTest.php @@ -4,7 +4,6 @@ namespace UIAwesome\Html\Tests\Flow; -use PHPForge\Support\LineEndingNormalizer; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use UIAwesome\Html\Attribute\Values\{ @@ -34,17 +33,16 @@ * @copyright Copyright (C) 2026 Terabytesoftw. * @license https://opensource.org/license/bsd-3-clause BSD 3-Clause License. */ -#[Group('html')] #[Group('flow')] final class MainTest extends TestCase { public function testContentEncodesValues(): void { - $main = Main::tag()->content(''); - self::assertSame( '<value>', - $main->getContent(), + Main::tag() + ->content('') + ->getContent(), "Failed asserting that 'content()' method encodes values correctly.", ); } @@ -62,7 +60,9 @@ public function testGetAttributesReturnsAssignedAttributes(): void { self::assertSame( ['data-test' => 'value'], - Main::tag()->addAttribute('data-test', 'value')->getAttributes(), + Main::tag() + ->addAttribute('data-test', 'value') + ->getAttributes(), "Failed asserting that 'getAttributes()' returns the assigned attributes.", ); } @@ -75,9 +75,9 @@ public function testHtmlDoesNotEncodeValues(): void HTML, - LineEndingNormalizer::normalize( - Main::tag()->html('')->render(), - ), + Main::tag() + ->html('') + ->render(), "Failed asserting that element renders correctly with 'html()' method.", ); } @@ -89,9 +89,9 @@ public function testRenderWithAccesskey(): void
HTML, - LineEndingNormalizer::normalize( - Main::tag()->accesskey('k')->render(), - ), + Main::tag() + ->accesskey('k') + ->render(), "Failed asserting that element renders correctly with 'accesskey' attribute.", ); } @@ -103,9 +103,9 @@ public function testRenderWithAddAriaAttribute(): void
HTML, - LineEndingNormalizer::normalize( - Main::tag()->addAriaAttribute('pressed', true)->render(), - ), + Main::tag() + ->addAriaAttribute('pressed', true) + ->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method.", ); } @@ -117,9 +117,9 @@ public function testRenderWithAddAriaAttributeUsingEnum(): void
HTML, - LineEndingNormalizer::normalize( - Main::tag()->addAriaAttribute(Aria::PRESSED, true)->render(), - ), + Main::tag() + ->addAriaAttribute(Aria::PRESSED, true) + ->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method.", ); } @@ -131,9 +131,9 @@ public function testRenderWithAddAttribute(): void
HTML, - LineEndingNormalizer::normalize( - Main::tag()->addAttribute('data-test', 'value')->render(), - ), + Main::tag() + ->addAttribute('data-test', 'value') + ->render(), "Failed asserting that element renders correctly with 'addAttribute()' method.", ); } @@ -145,9 +145,9 @@ public function testRenderWithAddAttributeUsingEnum(): void
HTML, - LineEndingNormalizer::normalize( - Main::tag()->addAttribute(GlobalAttribute::TITLE, 'value')->render(), - ), + Main::tag() + ->addAttribute(GlobalAttribute::TITLE, 'value') + ->render(), "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", ); } @@ -159,9 +159,9 @@ public function testRenderWithAddDataAttribute(): void
HTML, - LineEndingNormalizer::normalize( - Main::tag()->addDataAttribute('value', 'value')->render(), - ), + Main::tag() + ->addDataAttribute('value', 'value') + ->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method.", ); } @@ -173,9 +173,9 @@ public function testRenderWithAddDataAttributeUsingEnum(): void
HTML, - LineEndingNormalizer::normalize( - Main::tag()->addDataAttribute(Data::VALUE, 'value')->render(), - ), + Main::tag() + ->addDataAttribute(Data::VALUE, 'value') + ->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method.", ); } @@ -187,17 +187,15 @@ public function testRenderWithAriaAttributes(): void
HTML, - LineEndingNormalizer::normalize( - Main::tag() - ->ariaAttributes( - [ - 'controls' => static fn(): string => 'modal-1', - 'hidden' => false, - 'label' => 'Close', - ], - ) - ->render(), - ), + Main::tag() + ->ariaAttributes( + [ + 'controls' => static fn(): string => 'modal-1', + 'hidden' => false, + 'label' => 'Close', + ], + ) + ->render(), "Failed asserting that element renders correctly with 'ariaAttributes()' method.", ); } @@ -209,9 +207,9 @@ public function testRenderWithAttributes(): void
HTML, - LineEndingNormalizer::normalize( - Main::tag()->attributes(['class' => 'value'])->render(), - ), + Main::tag() + ->attributes(['class' => 'value']) + ->render(), "Failed asserting that element renders correctly with 'attributes()' method.", ); } @@ -223,9 +221,9 @@ public function testRenderWithAutofocus(): void
HTML, - LineEndingNormalizer::normalize( - Main::tag()->autofocus(true)->render(), - ), + Main::tag() + ->autofocus(true) + ->render(), "Failed asserting that element renders correctly with 'autofocus' attribute.", ); } @@ -238,9 +236,7 @@ public function testRenderWithBeginEnd(): void Content HTML, - LineEndingNormalizer::normalize( - Main::tag()->begin() . 'Content' . Main::end(), - ), + Main::tag()->begin() . 'Content' . Main::end(), "Failed asserting that element renders correctly with 'begin()' and 'end()' methods.", ); } @@ -252,9 +248,9 @@ public function testRenderWithClass(): void
HTML, - LineEndingNormalizer::normalize( - Main::tag()->class('value')->render(), - ), + Main::tag() + ->class('value') + ->render(), "Failed asserting that element renders correctly with 'class' attribute.", ); } @@ -267,9 +263,9 @@ public function testRenderWithContent(): void value HTML, - LineEndingNormalizer::normalize( - Main::tag()->content('value')->render(), - ), + Main::tag() + ->content('value') + ->render(), 'Failed asserting that element renders correctly with default values.', ); } @@ -281,9 +277,9 @@ public function testRenderWithContentEditable(): void
HTML, - LineEndingNormalizer::normalize( - Main::tag()->contentEditable(true)->render(), - ), + Main::tag() + ->contentEditable(true) + ->render(), "Failed asserting that element renders correctly with 'contentEditable' attribute.", ); } @@ -295,9 +291,9 @@ public function testRenderWithContentEditableUsingEnum(): void
HTML, - LineEndingNormalizer::normalize( - Main::tag()->contentEditable(ContentEditable::TRUE)->render(), - ), + Main::tag() + ->contentEditable(ContentEditable::TRUE) + ->render(), "Failed asserting that element renders correctly with 'contentEditable' attribute using enum.", ); } @@ -309,9 +305,9 @@ public function testRenderWithDataAttributes(): void
HTML, - LineEndingNormalizer::normalize( - Main::tag()->dataAttributes(['value' => 'value'])->render(), - ), + Main::tag() + ->dataAttributes(['value' => 'value']) + ->render(), "Failed asserting that element renders correctly with 'dataAttributes()' method.", ); } @@ -323,9 +319,7 @@ public function testRenderWithDefaultConfigurationValues(): void
HTML, - LineEndingNormalizer::normalize( - Main::tag(['class' => 'default-class'])->render(), - ), + Main::tag(['class' => 'default-class'])->render(), 'Failed asserting that default configuration values are applied correctly.', ); } @@ -337,9 +331,9 @@ public function testRenderWithDefaultProvider(): void
HTML, - LineEndingNormalizer::normalize( - Main::tag()->addDefaultProvider(DefaultProvider::class)->render(), - ), + Main::tag() + ->addDefaultProvider(DefaultProvider::class) + ->render(), 'Failed asserting that default provider is applied correctly.', ); } @@ -351,9 +345,9 @@ public function testRenderWithDir(): void
HTML, - LineEndingNormalizer::normalize( - Main::tag()->dir('ltr')->render(), - ), + Main::tag() + ->dir('ltr') + ->render(), "Failed asserting that element renders correctly with 'dir' attribute.", ); } @@ -365,9 +359,9 @@ public function testRenderWithDirUsingEnum(): void
HTML, - LineEndingNormalizer::normalize( - Main::tag()->dir(Direction::LTR)->render(), - ), + Main::tag() + ->dir(Direction::LTR) + ->render(), "Failed asserting that element renders correctly with 'dir' attribute using enum.", ); } @@ -379,9 +373,9 @@ public function testRenderWithDraggable(): void
HTML, - LineEndingNormalizer::normalize( - Main::tag()->draggable(true)->render(), - ), + Main::tag() + ->draggable(true) + ->render(), "Failed asserting that element renders correctly with 'draggable' attribute.", ); } @@ -393,9 +387,9 @@ public function testRenderWithDraggableUsingEnum(): void
HTML, - LineEndingNormalizer::normalize( - Main::tag()->draggable(Draggable::TRUE)->render(), - ), + Main::tag() + ->draggable(Draggable::TRUE) + ->render(), "Failed asserting that element renders correctly with 'draggable' attribute using enum.", ); } @@ -409,9 +403,7 @@ public function testRenderWithGlobalDefaultsAreApplied(): void
HTML, - LineEndingNormalizer::normalize( - Main::tag()->render(), - ), + Main::tag()->render(), 'Failed asserting that global defaults are applied correctly.', ); @@ -425,9 +417,9 @@ public function testRenderWithHidden(): void
HTML, - LineEndingNormalizer::normalize( - Main::tag()->hidden(true)->render(), - ), + Main::tag() + ->hidden(true) + ->render(), "Failed asserting that element renders correctly with 'hidden' attribute.", ); } @@ -439,9 +431,9 @@ public function testRenderWithId(): void
HTML, - LineEndingNormalizer::normalize( - Main::tag()->id('test-id')->render(), - ), + Main::tag() + ->id('test-id') + ->render(), "Failed asserting that element renders correctly with 'id' attribute.", ); } @@ -453,9 +445,9 @@ public function testRenderWithLang(): void
HTML, - LineEndingNormalizer::normalize( - Main::tag()->lang('es')->render(), - ), + Main::tag() + ->lang('es') + ->render(), "Failed asserting that element renders correctly with 'lang' attribute.", ); } @@ -467,9 +459,9 @@ public function testRenderWithLangUsingEnum(): void
HTML, - LineEndingNormalizer::normalize( - Main::tag()->lang(Language::SPANISH)->render(), - ), + Main::tag() + ->lang(Language::SPANISH) + ->render(), "Failed asserting that element renders correctly with 'lang' attribute using enum.", ); } @@ -481,15 +473,13 @@ public function testRenderWithMicroData(): void
HTML, - LineEndingNormalizer::normalize( - Main::tag() - ->itemId('https://example.com/item') - ->itemProp('name') - ->itemRef('info') - ->itemScope(true) - ->itemType('https://schema.org/Thing') - ->render(), - ), + Main::tag() + ->itemId('https://example.com/item') + ->itemProp('name') + ->itemRef('info') + ->itemScope(true) + ->itemType('https://schema.org/Thing') + ->render(), 'Failed asserting that element renders correctly with microdata attributes.', ); } @@ -501,12 +491,10 @@ public function testRenderWithRemoveAriaAttribute(): void
HTML, - LineEndingNormalizer::normalize( - Main::tag() - ->addAriaAttribute('label', 'Close') - ->removeAriaAttribute('label') - ->render(), - ), + Main::tag() + ->addAriaAttribute('label', 'Close') + ->removeAriaAttribute('label') + ->render(), "Failed asserting that element renders correctly with 'removeAriaAttribute()' method.", ); } @@ -518,12 +506,10 @@ public function testRenderWithRemoveAttribute(): void
HTML, - LineEndingNormalizer::normalize( - Main::tag() - ->addAttribute('data-test', 'value') - ->removeAttribute('data-test') - ->render(), - ), + Main::tag() + ->addAttribute('data-test', 'value') + ->removeAttribute('data-test') + ->render(), "Failed asserting that element renders correctly with 'removeAttribute()' method.", ); } @@ -535,12 +521,10 @@ public function testRenderWithRemoveDataAttribute(): void
HTML, - LineEndingNormalizer::normalize( - Main::tag() - ->addDataAttribute('value', 'test') - ->removeDataAttribute('value') - ->render(), - ), + Main::tag() + ->addDataAttribute('value', 'test') + ->removeDataAttribute('value') + ->render(), "Failed asserting that element renders correctly with 'removeDataAttribute()' method.", ); } @@ -552,9 +536,9 @@ public function testRenderWithRole(): void
HTML, - LineEndingNormalizer::normalize( - Main::tag()->role('banner')->render(), - ), + Main::tag() + ->role('banner') + ->render(), "Failed asserting that element renders correctly with 'role' attribute.", ); } @@ -566,9 +550,9 @@ public function testRenderWithRoleUsingEnum(): void
HTML, - LineEndingNormalizer::normalize( - Main::tag()->role(Role::BANNER)->render(), - ), + Main::tag() + ->role(Role::BANNER) + ->render(), "Failed asserting that element renders correctly with 'role' attribute using enum.", ); } @@ -580,9 +564,9 @@ public function testRenderWithSpellcheck(): void
HTML, - LineEndingNormalizer::normalize( - Main::tag()->spellcheck(true)->render(), - ), + Main::tag() + ->spellcheck(true) + ->render(), "Failed asserting that element renders correctly with 'spellcheck' attribute.", ); } @@ -594,9 +578,9 @@ public function testRenderWithStyle(): void
HTML, - LineEndingNormalizer::normalize( - Main::tag()->style('value')->render(), - ), + Main::tag() + ->style('value') + ->render(), "Failed asserting that element renders correctly with 'style' attribute.", ); } @@ -608,9 +592,9 @@ public function testRenderWithTabindex(): void
HTML, - LineEndingNormalizer::normalize( - Main::tag()->tabIndex(3)->render(), - ), + Main::tag() + ->tabIndex(3) + ->render(), "Failed asserting that element renders correctly with 'tabindex' attribute.", ); } @@ -622,9 +606,9 @@ public function testRenderWithThemeProvider(): void
HTML, - LineEndingNormalizer::normalize( - Main::tag()->addThemeProvider('muted', DefaultThemeProvider::class)->render(), - ), + Main::tag() + ->addThemeProvider('muted', DefaultThemeProvider::class) + ->render(), "Failed asserting that element renders correctly with 'addThemeProvider()' method.", ); } @@ -636,7 +620,9 @@ public function testRenderWithTitle(): void
HTML, - Main::tag()->title('value')->render(), + Main::tag() + ->title('value') + ->render(), "Failed asserting that element renders correctly with 'title' attribute.", ); } @@ -648,9 +634,7 @@ public function testRenderWithToString(): void
HTML, - LineEndingNormalizer::normalize( - (string) Main::tag(), - ), + (string) Main::tag(), "Failed asserting that '__toString()' method renders correctly.", ); } @@ -662,9 +646,9 @@ public function testRenderWithTranslate(): void
HTML, - LineEndingNormalizer::normalize( - Main::tag()->translate(false)->render(), - ), + Main::tag() + ->translate(false) + ->render(), "Failed asserting that element renders correctly with 'translate' attribute.", ); } @@ -676,9 +660,9 @@ public function testRenderWithTranslateUsingEnum(): void
HTML, - LineEndingNormalizer::normalize( - Main::tag()->translate(Translate::NO)->render(), - ), + Main::tag() + ->translate(Translate::NO) + ->render(), "Failed asserting that element renders correctly with 'translate' attribute using enum.", ); } @@ -692,9 +676,7 @@ public function testRenderWithUserOverridesGlobalDefaults(): void
HTML, - LineEndingNormalizer::normalize( - Main::tag(['id' => 'id-user'])->render(), - ), + Main::tag(['id' => 'id-user'])->render(), 'Failed asserting that user-defined attributes override global defaults correctly.', ); diff --git a/tests/Flow/PTest.php b/tests/Flow/PTest.php index dffd13a..3b90694 100644 --- a/tests/Flow/PTest.php +++ b/tests/Flow/PTest.php @@ -4,7 +4,6 @@ namespace UIAwesome\Html\Tests\Flow; -use PHPForge\Support\LineEndingNormalizer; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use UIAwesome\Html\Attribute\Values\{ @@ -34,17 +33,16 @@ * @copyright Copyright (C) 2026 Terabytesoftw. * @license https://opensource.org/license/bsd-3-clause BSD 3-Clause License. */ -#[Group('html')] #[Group('flow')] final class PTest extends TestCase { public function testContentEncodesValues(): void { - $p = P::tag()->content(''); - self::assertSame( '<value>', - $p->getContent(), + P::tag() + ->content('') + ->getContent(), "Failed asserting that 'content()' method encodes values correctly.", ); } @@ -62,7 +60,9 @@ public function testGetAttributesReturnsAssignedAttributes(): void { self::assertSame( ['data-test' => 'value'], - P::tag()->addAttribute('data-test', 'value')->getAttributes(), + P::tag() + ->addAttribute('data-test', 'value') + ->getAttributes(), "Failed asserting that 'getAttributes()' returns the assigned attributes.", ); } @@ -75,9 +75,9 @@ public function testHtmlDoesNotEncodeValues(): void

HTML, - LineEndingNormalizer::normalize( - P::tag()->html('')->render(), - ), + P::tag() + ->html('') + ->render(), "Failed asserting that element renders correctly with 'html()' method.", ); } @@ -89,9 +89,9 @@ public function testRenderWithAccesskey(): void

HTML, - LineEndingNormalizer::normalize( - P::tag()->accesskey('k')->render(), - ), + P::tag() + ->accesskey('k') + ->render(), "Failed asserting that element renders correctly with 'accesskey' attribute.", ); } @@ -103,9 +103,9 @@ public function testRenderWithAddAriaAttribute(): void

HTML, - LineEndingNormalizer::normalize( - P::tag()->addAriaAttribute('pressed', true)->render(), - ), + P::tag() + ->addAriaAttribute('pressed', true) + ->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method.", ); } @@ -117,9 +117,9 @@ public function testRenderWithAddAriaAttributeUsingEnum(): void

HTML, - LineEndingNormalizer::normalize( - P::tag()->addAriaAttribute(Aria::PRESSED, true)->render(), - ), + P::tag() + ->addAriaAttribute(Aria::PRESSED, true) + ->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method.", ); } @@ -131,9 +131,9 @@ public function testRenderWithAddAttribute(): void

HTML, - LineEndingNormalizer::normalize( - P::tag()->addAttribute('data-test', 'value')->render(), - ), + P::tag() + ->addAttribute('data-test', 'value') + ->render(), "Failed asserting that element renders correctly with 'addAttribute()' method.", ); } @@ -145,9 +145,9 @@ public function testRenderWithAddAttributeUsingEnum(): void

HTML, - LineEndingNormalizer::normalize( - P::tag()->addAttribute(GlobalAttribute::TITLE, 'value')->render(), - ), + P::tag() + ->addAttribute(GlobalAttribute::TITLE, 'value') + ->render(), "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", ); } @@ -159,9 +159,9 @@ public function testRenderWithAddDataAttribute(): void

HTML, - LineEndingNormalizer::normalize( - P::tag()->addDataAttribute('value', 'value')->render(), - ), + P::tag() + ->addDataAttribute('value', 'value') + ->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method.", ); } @@ -173,9 +173,9 @@ public function testRenderWithAddDataAttributeUsingEnum(): void

HTML, - LineEndingNormalizer::normalize( - P::tag()->addDataAttribute(Data::VALUE, 'value')->render(), - ), + P::tag() + ->addDataAttribute(Data::VALUE, 'value') + ->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method.", ); } @@ -187,17 +187,15 @@ public function testRenderWithAriaAttributes(): void

HTML, - LineEndingNormalizer::normalize( - P::tag() - ->ariaAttributes( - [ - 'controls' => static fn(): string => 'modal-1', - 'hidden' => false, - 'label' => 'Close', - ], - ) - ->render(), - ), + P::tag() + ->ariaAttributes( + [ + 'controls' => static fn(): string => 'modal-1', + 'hidden' => false, + 'label' => 'Close', + ], + ) + ->render(), "Failed asserting that element renders correctly with 'ariaAttributes()' method.", ); } @@ -209,9 +207,9 @@ public function testRenderWithAttributes(): void

HTML, - LineEndingNormalizer::normalize( - P::tag()->attributes(['class' => 'value'])->render(), - ), + P::tag() + ->attributes(['class' => 'value']) + ->render(), "Failed asserting that element renders correctly with 'attributes()' method.", ); } @@ -223,9 +221,9 @@ public function testRenderWithAutofocus(): void

HTML, - LineEndingNormalizer::normalize( - P::tag()->autofocus(true)->render(), - ), + P::tag() + ->autofocus(true) + ->render(), "Failed asserting that element renders correctly with 'autofocus' attribute.", ); } @@ -238,9 +236,7 @@ public function testRenderWithBeginEnd(): void Content

HTML, - LineEndingNormalizer::normalize( - P::tag()->begin() . 'Content' . P::end(), - ), + P::tag()->begin() . 'Content' . P::end(), "Failed asserting that element renders correctly with 'begin()' and 'end()' methods.", ); } @@ -252,9 +248,9 @@ public function testRenderWithClass(): void

HTML, - LineEndingNormalizer::normalize( - P::tag()->class('value')->render(), - ), + P::tag() + ->class('value') + ->render(), "Failed asserting that element renders correctly with 'class' attribute.", ); } @@ -267,9 +263,9 @@ public function testRenderWithContent(): void value

HTML, - LineEndingNormalizer::normalize( - P::tag()->content('value')->render(), - ), + P::tag() + ->content('value') + ->render(), 'Failed asserting that element renders correctly with default values.', ); } @@ -281,9 +277,9 @@ public function testRenderWithContentEditable(): void

HTML, - LineEndingNormalizer::normalize( - P::tag()->contentEditable(true)->render(), - ), + P::tag() + ->contentEditable(true) + ->render(), "Failed asserting that element renders correctly with 'contentEditable' attribute.", ); } @@ -295,9 +291,9 @@ public function testRenderWithContentEditableUsingEnum(): void

HTML, - LineEndingNormalizer::normalize( - P::tag()->contentEditable(ContentEditable::TRUE)->render(), - ), + P::tag() + ->contentEditable(ContentEditable::TRUE) + ->render(), "Failed asserting that element renders correctly with 'contentEditable' attribute using enum.", ); } @@ -309,9 +305,9 @@ public function testRenderWithDataAttributes(): void

HTML, - LineEndingNormalizer::normalize( - P::tag()->dataAttributes(['value' => 'value'])->render(), - ), + P::tag() + ->dataAttributes(['value' => 'value']) + ->render(), "Failed asserting that element renders correctly with 'dataAttributes()' method.", ); } @@ -323,9 +319,7 @@ public function testRenderWithDefaultConfigurationValues(): void

HTML, - LineEndingNormalizer::normalize( - P::tag(['class' => 'default-class'])->render(), - ), + P::tag(['class' => 'default-class'])->render(), 'Failed asserting that default configuration values are applied correctly.', ); } @@ -337,9 +331,9 @@ public function testRenderWithDefaultProvider(): void

HTML, - LineEndingNormalizer::normalize( - P::tag()->addDefaultProvider(DefaultProvider::class)->render(), - ), + P::tag() + ->addDefaultProvider(DefaultProvider::class) + ->render(), 'Failed asserting that default provider is applied correctly.', ); } @@ -351,9 +345,9 @@ public function testRenderWithDir(): void

HTML, - LineEndingNormalizer::normalize( - P::tag()->dir('ltr')->render(), - ), + P::tag() + ->dir('ltr') + ->render(), "Failed asserting that element renders correctly with 'dir' attribute.", ); } @@ -365,9 +359,9 @@ public function testRenderWithDirUsingEnum(): void

HTML, - LineEndingNormalizer::normalize( - P::tag()->dir(Direction::LTR)->render(), - ), + P::tag() + ->dir(Direction::LTR) + ->render(), "Failed asserting that element renders correctly with 'dir' attribute using enum.", ); } @@ -379,9 +373,9 @@ public function testRenderWithDraggable(): void

HTML, - LineEndingNormalizer::normalize( - P::tag()->draggable(true)->render(), - ), + P::tag() + ->draggable(true) + ->render(), "Failed asserting that element renders correctly with 'draggable' attribute.", ); } @@ -393,9 +387,9 @@ public function testRenderWithDraggableUsingEnum(): void

HTML, - LineEndingNormalizer::normalize( - P::tag()->draggable(Draggable::TRUE)->render(), - ), + P::tag() + ->draggable(Draggable::TRUE) + ->render(), "Failed asserting that element renders correctly with 'draggable' attribute using enum.", ); } @@ -409,9 +403,7 @@ public function testRenderWithGlobalDefaultsAreApplied(): void

HTML, - LineEndingNormalizer::normalize( - P::tag()->render(), - ), + P::tag()->render(), 'Failed asserting that global defaults are applied correctly.', ); @@ -425,9 +417,9 @@ public function testRenderWithHidden(): void HTML, - LineEndingNormalizer::normalize( - P::tag()->hidden(true)->render(), - ), + P::tag() + ->hidden(true) + ->render(), "Failed asserting that element renders correctly with 'hidden' attribute.", ); } @@ -439,9 +431,9 @@ public function testRenderWithId(): void

HTML, - LineEndingNormalizer::normalize( - P::tag()->id('test-id')->render(), - ), + P::tag() + ->id('test-id') + ->render(), "Failed asserting that element renders correctly with 'id' attribute.", ); } @@ -453,9 +445,9 @@ public function testRenderWithLang(): void

HTML, - LineEndingNormalizer::normalize( - P::tag()->lang('es')->render(), - ), + P::tag() + ->lang('es') + ->render(), "Failed asserting that element renders correctly with 'lang' attribute.", ); } @@ -467,9 +459,9 @@ public function testRenderWithLangUsingEnum(): void

HTML, - LineEndingNormalizer::normalize( - P::tag()->lang(Language::SPANISH)->render(), - ), + P::tag() + ->lang(Language::SPANISH) + ->render(), "Failed asserting that element renders correctly with 'lang' attribute using enum.", ); } @@ -481,15 +473,13 @@ public function testRenderWithMicroData(): void

HTML, - LineEndingNormalizer::normalize( - P::tag() - ->itemId('https://example.com/item') - ->itemProp('name') - ->itemRef('info') - ->itemScope(true) - ->itemType('https://schema.org/Thing') - ->render(), - ), + P::tag() + ->itemId('https://example.com/item') + ->itemProp('name') + ->itemRef('info') + ->itemScope(true) + ->itemType('https://schema.org/Thing') + ->render(), 'Failed asserting that element renders correctly with microdata attributes.', ); } @@ -501,12 +491,10 @@ public function testRenderWithRemoveAriaAttribute(): void

HTML, - LineEndingNormalizer::normalize( - P::tag() - ->addAriaAttribute('label', 'Close') - ->removeAriaAttribute('label') - ->render(), - ), + P::tag() + ->addAriaAttribute('label', 'Close') + ->removeAriaAttribute('label') + ->render(), "Failed asserting that element renders correctly with 'removeAriaAttribute()' method.", ); } @@ -518,12 +506,10 @@ public function testRenderWithRemoveAttribute(): void

HTML, - LineEndingNormalizer::normalize( - P::tag() - ->addAttribute('data-test', 'value') - ->removeAttribute('data-test') - ->render(), - ), + P::tag() + ->addAttribute('data-test', 'value') + ->removeAttribute('data-test') + ->render(), "Failed asserting that element renders correctly with 'removeAttribute()' method.", ); } @@ -535,12 +521,10 @@ public function testRenderWithRemoveDataAttribute(): void

HTML, - LineEndingNormalizer::normalize( - P::tag() - ->addDataAttribute('value', 'test') - ->removeDataAttribute('value') - ->render(), - ), + P::tag() + ->addDataAttribute('value', 'test') + ->removeDataAttribute('value') + ->render(), "Failed asserting that element renders correctly with 'removeDataAttribute()' method.", ); } @@ -552,9 +536,9 @@ public function testRenderWithRole(): void

HTML, - LineEndingNormalizer::normalize( - P::tag()->role('banner')->render(), - ), + P::tag() + ->role('banner') + ->render(), "Failed asserting that element renders correctly with 'role' attribute.", ); } @@ -566,9 +550,9 @@ public function testRenderWithRoleUsingEnum(): void

HTML, - LineEndingNormalizer::normalize( - P::tag()->role(Role::BANNER)->render(), - ), + P::tag() + ->role(Role::BANNER) + ->render(), "Failed asserting that element renders correctly with 'role' attribute using enum.", ); } @@ -580,9 +564,9 @@ public function testRenderWithSpellcheck(): void

HTML, - LineEndingNormalizer::normalize( - P::tag()->spellcheck(true)->render(), - ), + P::tag() + ->spellcheck(true) + ->render(), "Failed asserting that element renders correctly with 'spellcheck' attribute.", ); } @@ -594,9 +578,9 @@ public function testRenderWithStyle(): void

HTML, - LineEndingNormalizer::normalize( - P::tag()->style('value')->render(), - ), + P::tag() + ->style('value') + ->render(), "Failed asserting that element renders correctly with 'style' attribute.", ); } @@ -608,9 +592,9 @@ public function testRenderWithTabindex(): void

HTML, - LineEndingNormalizer::normalize( - P::tag()->tabIndex(3)->render(), - ), + P::tag() + ->tabIndex(3) + ->render(), "Failed asserting that element renders correctly with 'tabindex' attribute.", ); } @@ -622,9 +606,9 @@ public function testRenderWithThemeProvider(): void

HTML, - LineEndingNormalizer::normalize( - P::tag()->addThemeProvider('muted', DefaultThemeProvider::class)->render(), - ), + P::tag() + ->addThemeProvider('muted', DefaultThemeProvider::class) + ->render(), "Failed asserting that element renders correctly with 'addThemeProvider()' method.", ); } @@ -636,7 +620,9 @@ public function testRenderWithTitle(): void

HTML, - P::tag()->title('value')->render(), + P::tag() + ->title('value') + ->render(), "Failed asserting that element renders correctly with 'title' attribute.", ); } @@ -648,9 +634,7 @@ public function testRenderWithToString(): void

HTML, - LineEndingNormalizer::normalize( - (string) P::tag(), - ), + (string) P::tag(), "Failed asserting that '__toString()' method renders correctly.", ); } @@ -662,9 +646,9 @@ public function testRenderWithTranslate(): void

HTML, - LineEndingNormalizer::normalize( - P::tag()->translate(false)->render(), - ), + P::tag() + ->translate(false) + ->render(), "Failed asserting that element renders correctly with 'translate' attribute.", ); } @@ -676,9 +660,9 @@ public function testRenderWithTranslateUsingEnum(): void

HTML, - LineEndingNormalizer::normalize( - P::tag()->translate(Translate::NO)->render(), - ), + P::tag() + ->translate(Translate::NO) + ->render(), "Failed asserting that element renders correctly with 'translate' attribute using enum.", ); } @@ -692,9 +676,7 @@ public function testRenderWithUserOverridesGlobalDefaults(): void

HTML, - LineEndingNormalizer::normalize( - P::tag(['id' => 'id-user'])->render(), - ), + P::tag(['id' => 'id-user'])->render(), 'Failed asserting that user-defined attributes override global defaults correctly.', ); diff --git a/tests/Form/InputCheckboxTest.php b/tests/Form/InputCheckboxTest.php index 2f3cf34..d1d2978 100644 --- a/tests/Form/InputCheckboxTest.php +++ b/tests/Form/InputCheckboxTest.php @@ -4,7 +4,6 @@ namespace UIAwesome\Html\Tests\Form; -use PHPForge\Support\LineEndingNormalizer; use PHPForge\Support\Stub\BackedString; use PHPUnit\Framework\Attributes\{DataProviderExternal, Group}; use PHPUnit\Framework\TestCase; @@ -12,6 +11,7 @@ use UIAwesome\Html\Attribute\Values\{Aria, Data, Direction, GlobalAttribute, Language, Role, Translate}; use UIAwesome\Html\Core\Factory\SimpleFactory; use UIAwesome\Html\Form\InputCheckbox; +use UIAwesome\Html\Interop\Inline; use UIAwesome\Html\Tests\Provider\Form\CheckedProvider; use UIAwesome\Html\Tests\Support\Stub\{DefaultProvider, DefaultThemeProvider}; use UnitEnum; @@ -34,7 +34,6 @@ * @copyright Copyright (C) 2026 Terabytesoftw. * @license https://opensource.org/license/bsd-3-clause BSD 3-Clause License. */ -#[Group('html')] #[Group('form')] final class InputCheckboxTest extends TestCase { @@ -42,8 +41,7 @@ public function testGetAttributeReturnsDefaultWhenMissing(): void { self::assertSame( 'default', - InputCheckbox::tag() - ->getAttribute('data-test', 'default'), + InputCheckbox::tag()->getAttribute('data-test', 'default'), "Failed asserting that 'getAttribute()' returns the default value when missing.", ); } @@ -52,11 +50,11 @@ public function testRenderWithAccesskey(): void { self::assertSame( << + HTML, InputCheckbox::tag() ->accesskey('k') - ->id('inputcheckbox-') + ->id('inputcheckbox') ->render(), "Failed asserting that element renders correctly with 'accesskey' attribute.", ); @@ -66,11 +64,11 @@ public function testRenderWithAddAriaAttribute(): void { self::assertSame( << + HTML, InputCheckbox::tag() ->addAriaAttribute('label', 'Checkbox selector') - ->id('inputcheckbox-') + ->id('inputcheckbox') ->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method.", ); @@ -80,25 +78,126 @@ public function testRenderWithAddAriaAttributeUsingEnum(): void { self::assertSame( << + HTML, InputCheckbox::tag() ->addAriaAttribute(Aria::HIDDEN, true) - ->id('inputcheckbox-') + ->id('inputcheckbox') ->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method using enum.", ); } + public function testRenderWithAddAriaDescribedByString(): void + { + self::assertSame( + << + HTML, + InputCheckbox::tag() + ->addAriaAttribute('describedby', 'custom-help') + ->id('inputcheckbox') + ->render(), + "Failed asserting that an explicit 'aria-describedby' string value is preserved.", + ); + } + + public function testRenderWithAddAriaDescribedByTrueBooleanValue(): void + { + self::assertSame( + << + HTML, + InputCheckbox::tag() + ->addAriaAttribute('describedby', true) + ->id('inputcheckbox') + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to " + . "'true'.", + ); + } + + public function testRenderWithAddAriaDescribedByTrueBooleanValueAndIdNull(): void + { + self::assertSame( + << + HTML, + InputCheckbox::tag() + ->addAriaAttribute('describedby', true) + ->id(null) + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to " + . "'true' and 'id' is 'null'.", + ); + } + + public function testRenderWithAddAriaDescribedByTrueBooleanValueAndPrefixSuffix(): void + { + self::assertSame( + <<Prefix + + Suffix + HTML, + InputCheckbox::tag() + ->addAriaAttribute('describedby', true) + ->id('inputcheckbox') + ->prefix('Prefix') + ->prefixTag(Inline::SPAN) + ->suffix('Suffix') + ->suffixTag(Inline::SPAN) + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to " + . "'true' and prefix/suffix.", + ); + } + + public function testRenderWithAddAriaDescribedByTrueBooleanValueString(): void + { + self::assertSame( + << + HTML, + InputCheckbox::tag() + ->addAriaAttribute('describedby', 'true') + ->id('inputcheckbox') + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to " + . "'true'.", + ); + } + + public function testRenderWithAddAriaDescribedByTrueStringValueAndPrefixSuffix(): void + { + self::assertSame( + <<Prefix + + Suffix + HTML, + InputCheckbox::tag() + ->addAriaAttribute('describedby', 'true') + ->id('inputcheckbox') + ->prefix('Prefix') + ->prefixTag(Inline::SPAN) + ->suffix('Suffix') + ->suffixTag(Inline::SPAN) + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to " + . "'true' and prefix/suffix.", + ); + } + public function testRenderWithAddAttribute(): void { self::assertSame( << + HTML, InputCheckbox::tag() ->addAttribute('data-test', 'value') - ->id('inputcheckbox-') + ->id('inputcheckbox') ->render(), "Failed asserting that element renders correctly with 'addAttribute()' method.", ); @@ -108,11 +207,11 @@ public function testRenderWithAddAttributeUsingEnum(): void { self::assertSame( << + HTML, InputCheckbox::tag() ->addAttribute(GlobalAttribute::TITLE, 'Select checkbox') - ->id('inputcheckbox-') + ->id('inputcheckbox') ->render(), "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", ); @@ -122,11 +221,11 @@ public function testRenderWithAddDataAttribute(): void { self::assertSame( << + HTML, InputCheckbox::tag() ->addDataAttribute('checkbox', 'value') - ->id('inputcheckbox-') + ->id('inputcheckbox') ->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method.", ); @@ -136,11 +235,11 @@ public function testRenderWithAddDataAttributeUsingEnum(): void { self::assertSame( << + HTML, InputCheckbox::tag() ->addDataAttribute(Data::VALUE, 'test') - ->id('inputcheckbox-') + ->id('inputcheckbox') ->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method using enum.", ); @@ -150,7 +249,7 @@ public function testRenderWithAriaAttributes(): void { self::assertSame( << + HTML, InputCheckbox::tag() ->ariaAttributes( @@ -159,35 +258,91 @@ public function testRenderWithAriaAttributes(): void 'label' => 'Select a checkbox', ], ) - ->id('inputcheckbox-') + ->id('inputcheckbox') ->render(), "Failed asserting that element renders correctly with 'ariaAttributes()' method.", ); } + public function testRenderWithAriaAttributesAndAriaDescribedByTrueBooleanValue(): void + { + self::assertSame( + << + HTML, + InputCheckbox::tag() + ->ariaAttributes(['describedby' => true]) + ->id('inputcheckbox') + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to true.", + ); + } + + public function testRenderWithAriaAttributesAndAriaDescribedByTrueStringValue(): void + { + self::assertSame( + << + HTML, + InputCheckbox::tag() + ->ariaAttributes(['describedby' => 'true']) + ->id('inputcheckbox') + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to true.", + ); + } + public function testRenderWithAttributes(): void { self::assertSame( << + HTML, InputCheckbox::tag() ->attributes(['class' => 'checkbox-input']) - ->id('inputcheckbox-') + ->id('inputcheckbox') ->render(), "Failed asserting that element renders correctly with 'attributes()' method.", ); } + public function testRenderWithAttributesAndAriaDescribedByTrueBooleanValue(): void + { + self::assertSame( + << + HTML, + InputCheckbox::tag() + ->attributes(['aria-describedby' => true]) + ->id('inputcheckbox') + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to true.", + ); + } + + public function testRenderWithAttributesAndAriaDescribedByTrueStringValue(): void + { + self::assertSame( + << + HTML, + InputCheckbox::tag() + ->attributes(['aria-describedby' => 'true']) + ->id('inputcheckbox') + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to true.", + ); + } + public function testRenderWithAutofocus(): void { self::assertSame( << + HTML, InputCheckbox::tag() ->autofocus(true) - ->id('inputcheckbox-') + ->id('inputcheckbox') ->render(), "Failed asserting that element renders correctly with 'autofocus' attribute.", ); @@ -197,11 +352,11 @@ public function testRenderWithChecked(): void { self::assertSame( << + HTML, InputCheckbox::tag() ->checked(true) - ->id('inputcheckbox-') + ->id('inputcheckbox') ->render(), "Failed asserting that element renders correctly with 'checked' attribute.", ); @@ -219,7 +374,7 @@ public function testRenderWithCheckedAndValue( self::assertSame( $expected, InputCheckbox::tag() - ->id('inputcheckbox-') + ->id('inputcheckbox') ->checked($checked) ->value($value) ->render(), @@ -231,11 +386,11 @@ public function testRenderWithClass(): void { self::assertSame( << + HTML, InputCheckbox::tag() ->class('checkbox-input') - ->id('inputcheckbox-') + ->id('inputcheckbox') ->render(), "Failed asserting that element renders correctly with 'class' attribute.", ); @@ -245,11 +400,11 @@ public function testRenderWithClassUsingEnum(): void { self::assertSame( << + HTML, InputCheckbox::tag() ->class(BackedString::VALUE) - ->id('inputcheckbox-') + ->id('inputcheckbox') ->render(), "Failed asserting that element renders correctly with 'class' attribute.", ); @@ -259,11 +414,11 @@ public function testRenderWithDataAttributes(): void { self::assertSame( << + HTML, InputCheckbox::tag() ->dataAttributes(['checkbox' => 'value']) - ->id('inputcheckbox-') + ->id('inputcheckbox') ->render(), "Failed asserting that element renders correctly with 'dataAttributes()' method.", ); @@ -273,10 +428,10 @@ public function testRenderWithDefaultConfigurationValues(): void { self::assertSame( << + HTML, InputCheckbox::tag(['class' => 'default-class']) - ->id('inputcheckbox-') + ->id('inputcheckbox') ->render(), 'Failed asserting that default configuration values are applied correctly.', ); @@ -286,11 +441,11 @@ public function testRenderWithDefaultProvider(): void { self::assertSame( << + HTML, InputCheckbox::tag() ->addDefaultProvider(DefaultProvider::class) - ->id('inputcheckbox-') + ->id('inputcheckbox') ->render(), 'Failed asserting that default provider is applied correctly.', ); @@ -300,10 +455,10 @@ public function testRenderWithDefaultValues(): void { self::assertSame( << + HTML, InputCheckbox::tag() - ->id('inputcheckbox-') + ->id('inputcheckbox') ->render(), 'Failed asserting that element renders correctly with default values.', ); @@ -313,11 +468,11 @@ public function testRenderWithDir(): void { self::assertSame( << + HTML, InputCheckbox::tag() ->dir('ltr') - ->id('inputcheckbox-') + ->id('inputcheckbox') ->render(), "Failed asserting that element renders correctly with 'dir' attribute.", ); @@ -327,11 +482,11 @@ public function testRenderWithDirUsingEnum(): void { self::assertSame( << + HTML, InputCheckbox::tag() ->dir(Direction::LTR) - ->id('inputcheckbox-') + ->id('inputcheckbox') ->render(), "Failed asserting that element renders correctly with 'dir' attribute using enum.", ); @@ -341,11 +496,11 @@ public function testRenderWithDisabled(): void { self::assertSame( << + HTML, InputCheckbox::tag() ->disabled(true) - ->id('inputcheckbox-') + ->id('inputcheckbox') ->render(), "Failed asserting that element renders correctly with 'disabled' attribute.", ); @@ -356,17 +511,15 @@ public function testRenderWithEnclosedByLabel(): void self::assertSame( << - + Label HTML, - LineEndingNormalizer::normalize( - InputCheckbox::tag() - ->enclosedByLabel(true) - ->id('inputcheckbox-') - ->label('Label') - ->render(), - ), + InputCheckbox::tag() + ->enclosedByLabel(true) + ->id('inputcheckbox') + ->label('Label') + ->render(), ); } @@ -376,19 +529,17 @@ public function testRenderWithEnclosedByLabelAndCustomTemplate(): void << HTML, - LineEndingNormalizer::normalize( - InputCheckbox::tag() - ->enclosedByLabel(true) - ->id('inputcheckbox-') - ->label('Red') - ->template('
' . PHP_EOL . '{tag}' . PHP_EOL . '
') - ->render(), - ), + InputCheckbox::tag() + ->enclosedByLabel(true) + ->id('inputcheckbox') + ->label('Red') + ->template('
' . PHP_EOL . '{tag}' . PHP_EOL . '
') + ->render(), ); } @@ -396,11 +547,11 @@ public function testRenderWithEnclosedByLabelAndLabelContentEmpty(): void { self::assertSame( << + HTML, InputCheckbox::tag() ->enclosedByLabel(true) - ->id('inputcheckbox-') + ->id('inputcheckbox') ->render(), ); } @@ -410,18 +561,16 @@ public function testRenderWithEnclosedByLabelAndLabelFor(): void self::assertSame( << - + Label HTML, - LineEndingNormalizer::normalize( - InputCheckbox::tag() - ->enclosedByLabel(true) - ->id('inputcheckbox-') - ->label('Label') - ->labelFor('label-for') - ->render(), - ), + InputCheckbox::tag() + ->enclosedByLabel(true) + ->id('inputcheckbox') + ->label('Label') + ->labelFor('label-for') + ->render(), ); } @@ -429,7 +578,7 @@ public function testRenderWithEnclosedByLabelIsIdempotent(): void { $checkbox = InputCheckbox::tag() ->enclosedByLabel(true) - ->id('inputcheckbox-') + ->id('inputcheckbox') ->label('Label'); $first = $checkbox->render(); @@ -451,13 +600,11 @@ public function testRenderWithEnclosedByLabelWithoutId(): void Red HTML, - LineEndingNormalizer::normalize( - InputCheckbox::tag() - ->enclosedByLabel(true) - ->id(null) - ->label('Red') - ->render(), - ), + InputCheckbox::tag() + ->enclosedByLabel(true) + ->id(null) + ->label('Red') + ->render(), ); } @@ -465,11 +612,11 @@ public function testRenderWithForm(): void { self::assertSame( << + HTML, InputCheckbox::tag() ->form('form-id') - ->id('inputcheckbox-') + ->id('inputcheckbox') ->render(), "Failed asserting that element renders correctly with 'form' attribute.", ); @@ -504,11 +651,11 @@ public function testRenderWithHidden(): void { self::assertSame( << + HTML, InputCheckbox::tag() ->hidden(true) - ->id('inputcheckbox-') + ->id('inputcheckbox') ->render(), "Failed asserting that element renders correctly with 'hidden' attribute.", ); @@ -531,11 +678,11 @@ public function testRenderWithLabel(): void { self::assertSame( << - + + HTML, InputCheckbox::tag() - ->id('inputcheckbox-') + ->id('inputcheckbox') ->label('Label') ->render(), ); @@ -545,11 +692,11 @@ public function testRenderWithLabelAttributes(): void { self::assertSame( << - + + HTML, InputCheckbox::tag() - ->id('inputcheckbox-') + ->id('inputcheckbox') ->label('Label') ->labelAttributes(['class' => 'value']) ->render(), @@ -560,11 +707,11 @@ public function testRenderWithLabelClass(): void { self::assertSame( << - + + HTML, InputCheckbox::tag() - ->id('inputcheckbox-') + ->id('inputcheckbox') ->label('Label') ->labelClass('value') ->render(), @@ -575,11 +722,11 @@ public function testRenderWithLabelClassNullValue(): void { self::assertSame( << - + + HTML, InputCheckbox::tag() - ->id('inputcheckbox-') + ->id('inputcheckbox') ->label('Label') ->labelAttributes(['class' => 'value']) ->labelClass(null) @@ -591,11 +738,11 @@ public function testRenderWithLabelClassOverridesFalse(): void { self::assertSame( << - + + HTML, InputCheckbox::tag() - ->id('inputcheckbox-') + ->id('inputcheckbox') ->label('Label') ->labelAttributes(['class' => 'value']) ->labelClass('value-override') @@ -607,11 +754,11 @@ public function testRenderWithLabelClassOverridesTrue(): void { self::assertSame( << - + + HTML, InputCheckbox::tag() - ->id('inputcheckbox-') + ->id('inputcheckbox') ->label('Label') ->labelAttributes(['class' => 'value']) ->labelClass('value-override', true) @@ -623,11 +770,11 @@ public function testRenderWithLabelClassUsingEnum(): void { self::assertSame( << - + + HTML, InputCheckbox::tag() - ->id('inputcheckbox-') + ->id('inputcheckbox') ->label('Label') ->labelClass(BackedString::VALUE) ->render(), @@ -638,11 +785,11 @@ public function testRenderWithLabelFor(): void { self::assertSame( << + HTML, InputCheckbox::tag() - ->id('inputcheckbox-') + ->id('inputcheckbox') ->label('Label') ->labelFor('value') ->render(), @@ -653,11 +800,11 @@ public function testRenderWithLabelForNullValue(): void { self::assertSame( << + HTML, InputCheckbox::tag() - ->id('inputcheckbox-') + ->id('inputcheckbox') ->label('Label') ->labelFor(null) ->render(), @@ -668,10 +815,10 @@ public function testRenderWithLang(): void { self::assertSame( << + HTML, InputCheckbox::tag() - ->id('inputcheckbox-') + ->id('inputcheckbox') ->lang('en') ->render(), "Failed asserting that element renders correctly with 'lang' attribute.", @@ -682,10 +829,10 @@ public function testRenderWithLangUsingEnum(): void { self::assertSame( << + HTML, InputCheckbox::tag() - ->id('inputcheckbox-') + ->id('inputcheckbox') ->lang(Language::ENGLISH) ->render(), "Failed asserting that element renders correctly with 'lang' attribute using enum.", @@ -696,10 +843,10 @@ public function testRenderWithName(): void { self::assertSame( << + HTML, InputCheckbox::tag() - ->id('inputcheckbox-') + ->id('inputcheckbox') ->name('agree') ->render(), "Failed asserting that element renders correctly with 'name' attribute.", @@ -710,10 +857,10 @@ public function testRenderWithNotLabel(): void { self::assertSame( << + HTML, InputCheckbox::tag() - ->id('inputcheckbox-') + ->id('inputcheckbox') ->label('Label') ->notLabel() ->render(), @@ -724,11 +871,11 @@ public function testRenderWithRemoveAriaAttribute(): void { self::assertSame( << + HTML, InputCheckbox::tag() ->addAriaAttribute('label', 'Close') - ->id('inputcheckbox-') + ->id('inputcheckbox') ->removeAriaAttribute('label') ->render(), "Failed asserting that element renders correctly with 'removeAriaAttribute()' method.", @@ -739,11 +886,11 @@ public function testRenderWithRemoveAttribute(): void { self::assertSame( << + HTML, InputCheckbox::tag() ->addAttribute('data-test', 'value') - ->id('inputcheckbox-') + ->id('inputcheckbox') ->removeAttribute('data-test') ->render(), "Failed asserting that element renders correctly with 'removeAttribute()' method.", @@ -754,11 +901,11 @@ public function testRenderWithRemoveDataAttribute(): void { self::assertSame( << + HTML, InputCheckbox::tag() ->addDataAttribute('value', 'test') - ->id('inputcheckbox-') + ->id('inputcheckbox') ->removeDataAttribute('value') ->render(), "Failed asserting that element renders correctly with 'removeDataAttribute()' method.", @@ -769,10 +916,10 @@ public function testRenderWithRequired(): void { self::assertSame( << + HTML, InputCheckbox::tag() - ->id('inputcheckbox-') + ->id('inputcheckbox') ->required(true) ->render(), "Failed asserting that element renders correctly with 'required' attribute.", @@ -783,10 +930,10 @@ public function testRenderWithRole(): void { self::assertSame( << + HTML, InputCheckbox::tag() - ->id('inputcheckbox-') + ->id('inputcheckbox') ->role('checkbox') ->render(), "Failed asserting that element renders correctly with 'role' attribute.", @@ -797,10 +944,10 @@ public function testRenderWithRoleUsingEnum(): void { self::assertSame( << + HTML, InputCheckbox::tag() - ->id('inputcheckbox-') + ->id('inputcheckbox') ->role(Role::CHECKBOX) ->render(), "Failed asserting that element renders correctly with 'role' attribute using enum.", @@ -811,10 +958,10 @@ public function testRenderWithStyle(): void { self::assertSame( << + HTML, InputCheckbox::tag() - ->id('inputcheckbox-') + ->id('inputcheckbox') ->style('width: 20px;') ->render(), "Failed asserting that element renders correctly with 'style' attribute.", @@ -825,10 +972,10 @@ public function testRenderWithTabindex(): void { self::assertSame( << + HTML, InputCheckbox::tag() - ->id('inputcheckbox-') + ->id('inputcheckbox') ->tabIndex(1) ->render(), "Failed asserting that element renders correctly with 'tabindex' attribute.", @@ -839,11 +986,11 @@ public function testRenderWithThemeProvider(): void { self::assertSame( << + HTML, InputCheckbox::tag() ->addThemeProvider('muted', DefaultThemeProvider::class) - ->id('inputcheckbox-') + ->id('inputcheckbox') ->render(), "Failed asserting that element renders correctly with 'addThemeProvider()' method.", ); @@ -853,10 +1000,10 @@ public function testRenderWithTitle(): void { self::assertSame( << + HTML, InputCheckbox::tag() - ->id('inputcheckbox-') + ->id('inputcheckbox') ->title('Select a checkbox') ->render(), "Failed asserting that element renders correctly with 'title' attribute.", @@ -865,9 +1012,11 @@ public function testRenderWithTitle(): void public function testRenderWithToString(): void { - self::assertStringContainsString( - 'type="checkbox"', - (string) InputCheckbox::tag(), + self::assertSame( + << + HTML, + (string) InputCheckbox::tag()->id(null), "Failed asserting that '__toString()' method renders correctly.", ); } @@ -876,10 +1025,10 @@ public function testRenderWithTranslate(): void { self::assertSame( << + HTML, InputCheckbox::tag() - ->id('inputcheckbox-') + ->id('inputcheckbox') ->translate(false) ->render(), "Failed asserting that element renders correctly with 'translate' attribute.", @@ -890,10 +1039,10 @@ public function testRenderWithTranslateUsingEnum(): void { self::assertSame( << + HTML, InputCheckbox::tag() - ->id('inputcheckbox-') + ->id('inputcheckbox') ->translate(Translate::NO) ->render(), "Failed asserting that element renders correctly with 'translate' attribute using enum.", @@ -905,10 +1054,10 @@ public function testRenderWithUncheckedValue(): void self::assertSame( << - + HTML, InputCheckbox::tag() - ->id('inputcheckbox-') + ->id('inputcheckbox') ->name('agree') ->uncheckedValue('0') ->value('1') @@ -923,20 +1072,18 @@ public function testRenderWithUncheckedValueAndEnclosedByLabel(): void << HTML, - LineEndingNormalizer::normalize( - InputCheckbox::tag() - ->enclosedByLabel(true) - ->id('inputcheckbox-') - ->label('Label') - ->name('agree') - ->uncheckedValue('0') - ->value('1') - ->render(), - ), + InputCheckbox::tag() + ->enclosedByLabel(true) + ->id('inputcheckbox') + ->label('Label') + ->name('agree') + ->uncheckedValue('0') + ->value('1') + ->render(), ); } @@ -956,10 +1103,10 @@ public function testRenderWithValue(): void { self::assertSame( << + HTML, InputCheckbox::tag() - ->id('inputcheckbox-') + ->id('inputcheckbox') ->value('accepted') ->render(), "Failed asserting that element renders correctly with 'value' attribute.", diff --git a/tests/Form/InputHiddenTest.php b/tests/Form/InputHiddenTest.php index 32cdf94..f0baff9 100644 --- a/tests/Form/InputHiddenTest.php +++ b/tests/Form/InputHiddenTest.php @@ -4,12 +4,12 @@ namespace UIAwesome\Html\Tests\Form; -use PHPForge\Support\LineEndingNormalizer; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use UIAwesome\Html\Attribute\Values\{Aria, Autocomplete, Data, Direction, GlobalAttribute, Language, Role, Translate}; use UIAwesome\Html\Core\Factory\SimpleFactory; use UIAwesome\Html\Form\InputHidden; +use UIAwesome\Html\Interop\Inline; use UIAwesome\Html\Tests\Support\Stub\{DefaultProvider, DefaultThemeProvider}; /** @@ -26,7 +26,6 @@ * @copyright Copyright (C) 2026 Terabytesoftw. * @license https://opensource.org/license/bsd-3-clause BSD 3-Clause License. */ -#[Group('html')] #[Group('form')] final class InputHiddenTest extends TestCase { @@ -43,9 +42,9 @@ public function testRenderWithAccesskey(): void { self::assertSame( << + HTML, - InputHidden::tag()->id('inputhidden-')->accesskey('k')->render(), + InputHidden::tag()->id('inputhidden')->accesskey('k')->render(), "Failed asserting that element renders correctly with 'accesskey' attribute.", ); } @@ -54,9 +53,9 @@ public function testRenderWithAddAriaAttribute(): void { self::assertSame( << + HTML, - InputHidden::tag()->id('inputhidden-')->addAriaAttribute('label', 'Hidden input')->render(), + InputHidden::tag()->id('inputhidden')->addAriaAttribute('label', 'Hidden input')->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method.", ); } @@ -65,20 +64,121 @@ public function testRenderWithAddAriaAttributeUsingEnum(): void { self::assertSame( << + HTML, - InputHidden::tag()->id('inputhidden-')->addAriaAttribute(Aria::HIDDEN, true)->render(), + InputHidden::tag()->id('inputhidden')->addAriaAttribute(Aria::HIDDEN, true)->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method using enum.", ); } + public function testRenderWithAddAriaDescribedByString(): void + { + self::assertSame( + << + HTML, + InputHidden::tag() + ->addAriaAttribute('describedby', 'custom-help') + ->id('inputhidden') + ->render(), + "Failed asserting that an explicit 'aria-describedby' string value is preserved.", + ); + } + + public function testRenderWithAddAriaDescribedByTrueBooleanValue(): void + { + self::assertSame( + << + HTML, + InputHidden::tag() + ->addAriaAttribute('describedby', true) + ->id('inputhidden') + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to " + . "'true'.", + ); + } + + public function testRenderWithAddAriaDescribedByTrueBooleanValueAndIdNull(): void + { + self::assertSame( + << + HTML, + InputHidden::tag() + ->addAriaAttribute('describedby', true) + ->id(null) + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to " + . "'true' and 'id' is 'null'.", + ); + } + + public function testRenderWithAddAriaDescribedByTrueBooleanValueAndPrefixSuffix(): void + { + self::assertSame( + <<Prefix + + Suffix + HTML, + InputHidden::tag() + ->addAriaAttribute('describedby', true) + ->id('inputhidden') + ->prefix('Prefix') + ->prefixTag(Inline::SPAN) + ->suffix('Suffix') + ->suffixTag(Inline::SPAN) + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to " + . "'true' and prefix/suffix.", + ); + } + + public function testRenderWithAddAriaDescribedByTrueBooleanValueString(): void + { + self::assertSame( + << + HTML, + InputHidden::tag() + ->addAriaAttribute('describedby', 'true') + ->id('inputhidden') + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to " + . "'true'.", + ); + } + + public function testRenderWithAddAriaDescribedByTrueStringValueAndPrefixSuffix(): void + { + self::assertSame( + <<Prefix + + Suffix + HTML, + InputHidden::tag() + ->addAriaAttribute('describedby', 'true') + ->id('inputhidden') + ->prefix('Prefix') + ->prefixTag(Inline::SPAN) + ->suffix('Suffix') + ->suffixTag(Inline::SPAN) + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to " + . "'true' and prefix/suffix.", + ); + } + public function testRenderWithAddAttribute(): void { self::assertSame( << + HTML, - InputHidden::tag()->id('inputhidden-')->addAttribute('data-test', 'value')->render(), + InputHidden::tag()->id('inputhidden')->addAttribute('data-test', 'value')->render(), "Failed asserting that element renders correctly with 'addAttribute()' method.", ); } @@ -87,9 +187,9 @@ public function testRenderWithAddAttributeUsingEnum(): void { self::assertSame( << + HTML, - InputHidden::tag()->id('inputhidden-')->addAttribute(GlobalAttribute::TITLE, 'Hidden input')->render(), + InputHidden::tag()->id('inputhidden')->addAttribute(GlobalAttribute::TITLE, 'Hidden input')->render(), "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", ); } @@ -98,9 +198,9 @@ public function testRenderWithAddDataAttribute(): void { self::assertSame( << + HTML, - InputHidden::tag()->id('inputhidden-')->addDataAttribute('hidden', 'value')->render(), + InputHidden::tag()->id('inputhidden')->addDataAttribute('hidden', 'value')->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method.", ); } @@ -109,9 +209,9 @@ public function testRenderWithAddDataAttributeUsingEnum(): void { self::assertSame( << + HTML, - InputHidden::tag()->id('inputhidden-')->addDataAttribute(Data::VALUE, 'test')->render(), + InputHidden::tag()->id('inputhidden')->addDataAttribute(Data::VALUE, 'test')->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method using enum.", ); } @@ -120,10 +220,10 @@ public function testRenderWithAriaAttributes(): void { self::assertSame( << + HTML, InputHidden::tag() - ->id('inputhidden-') + ->id('inputhidden') ->ariaAttributes([ 'controls' => 'hidden-picker', 'label' => 'Select a hidden', @@ -133,24 +233,80 @@ public function testRenderWithAriaAttributes(): void ); } + public function testRenderWithAriaAttributesAndAriaDescribedByTrueBooleanValue(): void + { + self::assertSame( + << + HTML, + InputHidden::tag() + ->ariaAttributes(['describedby' => true]) + ->id('inputhidden') + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to true.", + ); + } + + public function testRenderWithAriaAttributesAndAriaDescribedByTrueStringValue(): void + { + self::assertSame( + << + HTML, + InputHidden::tag() + ->ariaAttributes(['describedby' => 'true']) + ->id('inputhidden') + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to true.", + ); + } + public function testRenderWithAttributes(): void { self::assertSame( << + HTML, - InputHidden::tag()->id('inputhidden-')->attributes(['class' => 'hidden-input'])->render(), + InputHidden::tag()->id('inputhidden')->attributes(['class' => 'hidden-input'])->render(), "Failed asserting that element renders correctly with 'attributes()' method.", ); } + public function testRenderWithAttributesAndAriaDescribedByTrueBooleanValue(): void + { + self::assertSame( + << + HTML, + InputHidden::tag() + ->attributes(['aria-describedby' => true]) + ->id('inputhidden') + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to true.", + ); + } + + public function testRenderWithAttributesAndAriaDescribedByTrueStringValue(): void + { + self::assertSame( + << + HTML, + InputHidden::tag() + ->attributes(['aria-describedby' => 'true']) + ->id('inputhidden') + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to true.", + ); + } + public function testRenderWithAutocomplete(): void { self::assertSame( << + HTML, - InputHidden::tag()->autocomplete('on')->id('inputhidden-')->render(), + InputHidden::tag()->autocomplete('on')->id('inputhidden')->render(), "Failed asserting that element renders correctly with 'autocomplete' attribute.", ); } @@ -159,9 +315,9 @@ public function testRenderWithAutocompleteUsingEnum(): void { self::assertSame( << + HTML, - InputHidden::tag()->autocomplete(Autocomplete::ON)->id('inputhidden-')->render(), + InputHidden::tag()->autocomplete(Autocomplete::ON)->id('inputhidden')->render(), "Failed asserting that element renders correctly with 'autocomplete' attribute using enum.", ); } @@ -170,9 +326,9 @@ public function testRenderWithClass(): void { self::assertSame( << + HTML, - InputHidden::tag()->id('inputhidden-')->class('hidden-input')->render(), + InputHidden::tag()->id('inputhidden')->class('hidden-input')->render(), "Failed asserting that element renders correctly with 'class' attribute.", ); } @@ -181,9 +337,9 @@ public function testRenderWithDataAttributes(): void { self::assertSame( << + HTML, - InputHidden::tag()->id('inputhidden-')->dataAttributes(['hidden' => 'value'])->render(), + InputHidden::tag()->id('inputhidden')->dataAttributes(['hidden' => 'value'])->render(), "Failed asserting that element renders correctly with 'dataAttributes()' method.", ); } @@ -192,9 +348,9 @@ public function testRenderWithDefaultConfigurationValues(): void { self::assertSame( << + HTML, - InputHidden::tag(['class' => 'default-class'])->id('inputhidden-')->render(), + InputHidden::tag(['class' => 'default-class'])->id('inputhidden')->render(), 'Failed asserting that default configuration values are applied correctly.', ); } @@ -203,9 +359,9 @@ public function testRenderWithDefaultProvider(): void { self::assertSame( << + HTML, - InputHidden::tag()->id('inputhidden-')->addDefaultProvider(DefaultProvider::class)->render(), + InputHidden::tag()->id('inputhidden')->addDefaultProvider(DefaultProvider::class)->render(), 'Failed asserting that default provider is applied correctly.', ); } @@ -214,9 +370,9 @@ public function testRenderWithDefaultValues(): void { self::assertSame( << + HTML, - InputHidden::tag()->id('inputhidden-')->render(), + InputHidden::tag()->id('inputhidden')->render(), 'Failed asserting that element renders correctly with default values.', ); } @@ -225,9 +381,9 @@ public function testRenderWithDir(): void { self::assertSame( << + HTML, - InputHidden::tag()->id('inputhidden-')->dir('ltr')->render(), + InputHidden::tag()->id('inputhidden')->dir('ltr')->render(), "Failed asserting that element renders correctly with 'dir' attribute.", ); } @@ -236,9 +392,9 @@ public function testRenderWithDirUsingEnum(): void { self::assertSame( << + HTML, - InputHidden::tag()->id('inputhidden-')->dir(Direction::LTR)->render(), + InputHidden::tag()->id('inputhidden')->dir(Direction::LTR)->render(), "Failed asserting that element renders correctly with 'dir' attribute using enum.", ); } @@ -247,9 +403,9 @@ public function testRenderWithDisabled(): void { self::assertSame( << + HTML, - InputHidden::tag()->id('inputhidden-')->disabled(true)->render(), + InputHidden::tag()->id('inputhidden')->disabled(true)->render(), "Failed asserting that element renders correctly with 'disabled' attribute.", ); } @@ -258,13 +414,25 @@ public function testRenderWithForm(): void { self::assertSame( << + HTML, - InputHidden::tag()->form('form-id')->id('inputhidden-')->render(), + InputHidden::tag()->form('form-id')->id('inputhidden')->render(), "Failed asserting that element renders correctly with 'form' attribute.", ); } + public function testRenderWithGenerateId(): void + { + /** @phpstan-var string $id */ + $id = InputHidden::tag()->getAttribute('id', ''); + + self::assertMatchesRegularExpression( + '/^inputhidden-\w+$/', + $id, + 'Failed asserting that element generates an ID when not provided.', + ); + } + public function testRenderWithGlobalDefaultsAreApplied(): void { SimpleFactory::setDefaults(InputHidden::class, ['class' => 'default-class']); @@ -282,9 +450,9 @@ public function testRenderWithHidden(): void { self::assertSame( << + HTML, - InputHidden::tag()->id('inputhidden-')->hidden(true)->render(), + InputHidden::tag()->id('inputhidden')->hidden(true)->render(), "Failed asserting that element renders correctly with 'hidden' attribute.", ); } @@ -304,9 +472,9 @@ public function testRenderWithLang(): void { self::assertSame( << + HTML, - InputHidden::tag()->id('inputhidden-')->lang('en')->render(), + InputHidden::tag()->id('inputhidden')->lang('en')->render(), "Failed asserting that element renders correctly with 'lang' attribute.", ); } @@ -315,9 +483,9 @@ public function testRenderWithLangUsingEnum(): void { self::assertSame( << + HTML, - InputHidden::tag()->id('inputhidden-')->lang(Language::ENGLISH)->render(), + InputHidden::tag()->id('inputhidden')->lang(Language::ENGLISH)->render(), "Failed asserting that element renders correctly with 'lang' attribute using enum.", ); } @@ -326,9 +494,9 @@ public function testRenderWithName(): void { self::assertSame( << + HTML, - InputHidden::tag()->id('inputhidden-')->name('csrf_token')->render(), + InputHidden::tag()->id('inputhidden')->name('csrf_token')->render(), "Failed asserting that element renders correctly with 'name' attribute.", ); } @@ -337,10 +505,10 @@ public function testRenderWithRemoveAriaAttribute(): void { self::assertSame( << + HTML, InputHidden::tag() - ->id('inputhidden-') + ->id('inputhidden') ->addAriaAttribute('label', 'Close') ->removeAriaAttribute('label') ->render(), @@ -352,10 +520,10 @@ public function testRenderWithRemoveAttribute(): void { self::assertSame( << + HTML, InputHidden::tag() - ->id('inputhidden-') + ->id('inputhidden') ->addAttribute('data-test', 'value') ->removeAttribute('data-test') ->render(), @@ -367,10 +535,10 @@ public function testRenderWithRemoveDataAttribute(): void { self::assertSame( << + HTML, InputHidden::tag() - ->id('inputhidden-') + ->id('inputhidden') ->addDataAttribute('value', 'test') ->removeDataAttribute('value') ->render(), @@ -382,9 +550,9 @@ public function testRenderWithRole(): void { self::assertSame( << + HTML, - InputHidden::tag()->id('inputhidden-')->role('presentation')->render(), + InputHidden::tag()->id('inputhidden')->role('presentation')->render(), "Failed asserting that element renders correctly with 'role' attribute.", ); } @@ -393,9 +561,9 @@ public function testRenderWithRoleUsingEnum(): void { self::assertSame( << + HTML, - InputHidden::tag()->id('inputhidden-')->role(Role::PRESENTATION)->render(), + InputHidden::tag()->id('inputhidden')->role(Role::PRESENTATION)->render(), "Failed asserting that element renders correctly with 'role' attribute using enum.", ); } @@ -404,9 +572,9 @@ public function testRenderWithStyle(): void { self::assertSame( << + HTML, - InputHidden::tag()->id('inputhidden-')->style('display: none;')->render(), + InputHidden::tag()->id('inputhidden')->style('display: none;')->render(), "Failed asserting that element renders correctly with 'style' attribute.", ); } @@ -415,9 +583,9 @@ public function testRenderWithThemeProvider(): void { self::assertSame( << + HTML, - InputHidden::tag()->id('inputhidden-')->addThemeProvider('muted', DefaultThemeProvider::class)->render(), + InputHidden::tag()->id('inputhidden')->addThemeProvider('muted', DefaultThemeProvider::class)->render(), "Failed asserting that element renders correctly with 'addThemeProvider()' method.", ); } @@ -426,18 +594,22 @@ public function testRenderWithTitle(): void { self::assertSame( << + HTML, - InputHidden::tag()->id('inputhidden-')->title('Hidden input')->render(), + InputHidden::tag()->id('inputhidden')->title('Hidden input')->render(), "Failed asserting that element renders correctly with 'title' attribute.", ); } public function testRenderWithToString(): void { - self::assertStringContainsString( - 'type="hidden"', - LineEndingNormalizer::normalize((string) InputHidden::tag()), + self::assertSame( + << + HTML, + InputHidden::tag() + ->id(null) + ->render(), "Failed asserting that '__toString()' method renders correctly.", ); } @@ -446,9 +618,9 @@ public function testRenderWithTranslate(): void { self::assertSame( << + HTML, - InputHidden::tag()->id('inputhidden-')->translate(false)->render(), + InputHidden::tag()->id('inputhidden')->translate(false)->render(), "Failed asserting that element renders correctly with 'translate' attribute.", ); } @@ -457,9 +629,9 @@ public function testRenderWithTranslateUsingEnum(): void { self::assertSame( << + HTML, - InputHidden::tag()->id('inputhidden-')->translate(Translate::NO)->render(), + InputHidden::tag()->id('inputhidden')->translate(Translate::NO)->render(), "Failed asserting that element renders correctly with 'translate' attribute using enum.", ); } @@ -480,9 +652,9 @@ public function testRenderWithValue(): void { self::assertSame( << + HTML, - InputHidden::tag()->id('inputhidden-')->value('1234567890')->render(), + InputHidden::tag()->id('inputhidden')->value('1234567890')->render(), "Failed asserting that element renders correctly with 'value' attribute.", ); } diff --git a/tests/Form/InputNumberTest.php b/tests/Form/InputNumberTest.php index 1b63d4f..a528341 100644 --- a/tests/Form/InputNumberTest.php +++ b/tests/Form/InputNumberTest.php @@ -4,12 +4,12 @@ namespace UIAwesome\Html\Tests\Form; -use PHPForge\Support\LineEndingNormalizer; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use UIAwesome\Html\Attribute\Values\{Aria, Autocomplete, Data, Direction, GlobalAttribute, Language, Role, Translate}; use UIAwesome\Html\Core\Factory\SimpleFactory; use UIAwesome\Html\Form\InputNumber; +use UIAwesome\Html\Interop\Inline; use UIAwesome\Html\Tests\Support\Stub\{DefaultProvider, DefaultThemeProvider}; /** @@ -27,7 +27,6 @@ * @copyright Copyright (C) 2026 Terabytesoftw. * @license https://opensource.org/license/bsd-3-clause BSD 3-Clause License. */ -#[Group('html')] #[Group('form')] final class InputNumberTest extends TestCase { @@ -45,11 +44,11 @@ public function testRenderWithAccesskey(): void { self::assertSame( << + HTML, InputNumber::tag() ->accesskey('k') - ->id('inputnumber-') + ->id('inputnumber') ->render(), "Failed asserting that element renders correctly with 'accesskey' attribute.", ); @@ -59,11 +58,11 @@ public function testRenderWithAddAriaAttribute(): void { self::assertSame( << + HTML, InputNumber::tag() ->addAriaAttribute('label', 'Number selector') - ->id('inputnumber-') + ->id('inputnumber') ->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method.", ); @@ -73,25 +72,126 @@ public function testRenderWithAddAriaAttributeUsingEnum(): void { self::assertSame( << + HTML, InputNumber::tag() ->addAriaAttribute(Aria::HIDDEN, true) - ->id('inputnumber-') + ->id('inputnumber') ->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method using enum.", ); } + public function testRenderWithAddAriaDescribedByString(): void + { + self::assertSame( + << + HTML, + InputNumber::tag() + ->addAriaAttribute('describedby', 'custom-help') + ->id('inputnumber') + ->render(), + "Failed asserting that an explicit 'aria-describedby' string value is preserved.", + ); + } + + public function testRenderWithAddAriaDescribedByTrueBooleanValue(): void + { + self::assertSame( + << + HTML, + InputNumber::tag() + ->addAriaAttribute('describedby', true) + ->id('inputnumber') + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to " + . "'true'.", + ); + } + + public function testRenderWithAddAriaDescribedByTrueBooleanValueAndIdNull(): void + { + self::assertSame( + << + HTML, + InputNumber::tag() + ->addAriaAttribute('describedby', true) + ->id(null) + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to " + . "'true' and 'id' is 'null'.", + ); + } + + public function testRenderWithAddAriaDescribedByTrueBooleanValueAndPrefixSuffix(): void + { + self::assertSame( + <<Prefix + + Suffix + HTML, + InputNumber::tag() + ->addAriaAttribute('describedby', true) + ->id('inputnumber') + ->prefix('Prefix') + ->prefixTag(Inline::SPAN) + ->suffix('Suffix') + ->suffixTag(Inline::SPAN) + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to " + . "'true' and prefix/suffix.", + ); + } + + public function testRenderWithAddAriaDescribedByTrueBooleanValueString(): void + { + self::assertSame( + << + HTML, + InputNumber::tag() + ->addAriaAttribute('describedby', 'true') + ->id('inputnumber') + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to " + . "'true'.", + ); + } + + public function testRenderWithAddAriaDescribedByTrueStringValueAndPrefixSuffix(): void + { + self::assertSame( + <<Prefix + + Suffix + HTML, + InputNumber::tag() + ->addAriaAttribute('describedby', 'true') + ->id('inputnumber') + ->prefix('Prefix') + ->prefixTag(Inline::SPAN) + ->suffix('Suffix') + ->suffixTag(Inline::SPAN) + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to " + . "'true' and prefix/suffix.", + ); + } + public function testRenderWithAddAttribute(): void { self::assertSame( << + HTML, InputNumber::tag() ->addAttribute('data-test', 'value') - ->id('inputnumber-') + ->id('inputnumber') ->render(), "Failed asserting that element renders correctly with 'addAttribute()' method.", ); @@ -101,11 +201,11 @@ public function testRenderWithAddAttributeUsingEnum(): void { self::assertSame( << + HTML, InputNumber::tag() ->addAttribute(GlobalAttribute::TITLE, 'Select number') - ->id('inputnumber-') + ->id('inputnumber') ->render(), "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", ); @@ -115,11 +215,11 @@ public function testRenderWithAddDataAttribute(): void { self::assertSame( << + HTML, InputNumber::tag() ->addDataAttribute('number', 'value') - ->id('inputnumber-') + ->id('inputnumber') ->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method.", ); @@ -129,11 +229,11 @@ public function testRenderWithAddDataAttributeUsingEnum(): void { self::assertSame( << + HTML, InputNumber::tag() ->addDataAttribute(Data::VALUE, 'test') - ->id('inputnumber-') + ->id('inputnumber') ->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method using enum.", ); @@ -143,42 +243,98 @@ public function testRenderWithAriaAttributes(): void { self::assertSame( << + HTML, InputNumber::tag() ->ariaAttributes([ 'controls' => 'number-picker', 'label' => 'Select a number', ]) - ->id('inputnumber-') + ->id('inputnumber') ->render(), "Failed asserting that element renders correctly with 'ariaAttributes()' method.", ); } + public function testRenderWithAriaAttributesAndAriaDescribedByTrueBooleanValue(): void + { + self::assertSame( + << + HTML, + InputNumber::tag() + ->ariaAttributes(['describedby' => true]) + ->id('inputnumber') + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to true.", + ); + } + + public function testRenderWithAriaAttributesAndAriaDescribedByTrueStringValue(): void + { + self::assertSame( + << + HTML, + InputNumber::tag() + ->ariaAttributes(['describedby' => 'true']) + ->id('inputnumber') + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to true.", + ); + } + public function testRenderWithAttributes(): void { self::assertSame( << + HTML, InputNumber::tag() ->attributes(['class' => 'number-input']) - ->id('inputnumber-') + ->id('inputnumber') ->render(), "Failed asserting that element renders correctly with 'attributes()' method.", ); } + public function testRenderWithAttributesAndAriaDescribedByTrueBooleanValue(): void + { + self::assertSame( + << + HTML, + InputNumber::tag() + ->attributes(['aria-describedby' => true]) + ->id('inputnumber') + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to true.", + ); + } + + public function testRenderWithAttributesAndAriaDescribedByTrueStringValue(): void + { + self::assertSame( + << + HTML, + InputNumber::tag() + ->attributes(['aria-describedby' => 'true']) + ->id('inputnumber') + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to true.", + ); + } + public function testRenderWithAutocomplete(): void { self::assertSame( << + HTML, InputNumber::tag() ->autocomplete('on') - ->id('inputnumber-') + ->id('inputnumber') ->render(), "Failed asserting that element renders correctly with 'autocomplete' attribute.", ); @@ -188,11 +344,11 @@ public function testRenderWithAutocompleteUsingEnum(): void { self::assertSame( << + HTML, InputNumber::tag() ->autocomplete(Autocomplete::ON) - ->id('inputnumber-') + ->id('inputnumber') ->render(), "Failed asserting that element renders correctly with 'autocomplete' attribute using enum.", ); @@ -202,11 +358,11 @@ public function testRenderWithAutofocus(): void { self::assertSame( << + HTML, InputNumber::tag() ->autofocus(true) - ->id('inputnumber-') + ->id('inputnumber') ->render(), "Failed asserting that element renders correctly with 'autofocus' attribute.", ); @@ -216,11 +372,11 @@ public function testRenderWithClass(): void { self::assertSame( << + HTML, InputNumber::tag() ->class('number-input') - ->id('inputnumber-') + ->id('inputnumber') ->render(), "Failed asserting that element renders correctly with 'class' attribute.", ); @@ -230,11 +386,11 @@ public function testRenderWithDataAttributes(): void { self::assertSame( << + HTML, InputNumber::tag() ->dataAttributes(['number' => 'value']) - ->id('inputnumber-') + ->id('inputnumber') ->render(), "Failed asserting that element renders correctly with 'dataAttributes()' method.", ); @@ -244,10 +400,10 @@ public function testRenderWithDefaultConfigurationValues(): void { self::assertSame( << + HTML, InputNumber::tag(['class' => 'default-class']) - ->id('inputnumber-') + ->id('inputnumber') ->render(), 'Failed asserting that default configuration values are applied correctly.', ); @@ -257,11 +413,11 @@ public function testRenderWithDefaultProvider(): void { self::assertSame( << + HTML, InputNumber::tag() ->addDefaultProvider(DefaultProvider::class) - ->id('inputnumber-') + ->id('inputnumber') ->render(), 'Failed asserting that default provider is applied correctly.', ); @@ -271,10 +427,10 @@ public function testRenderWithDefaultValues(): void { self::assertSame( << + HTML, InputNumber::tag() - ->id('inputnumber-') + ->id('inputnumber') ->render(), 'Failed asserting that element renders correctly with default values.', ); @@ -284,10 +440,10 @@ public function testRenderWithDir(): void { self::assertSame( << + HTML, InputNumber::tag() - ->id('inputnumber-') + ->id('inputnumber') ->dir('ltr') ->render(), "Failed asserting that element renders correctly with 'dir' attribute.", @@ -298,10 +454,10 @@ public function testRenderWithDirUsingEnum(): void { self::assertSame( << + HTML, InputNumber::tag() - ->id('inputnumber-') + ->id('inputnumber') ->dir(Direction::LTR) ->render(), "Failed asserting that element renders correctly with 'dir' attribute using enum.", @@ -312,10 +468,10 @@ public function testRenderWithDisabled(): void { self::assertSame( << + HTML, InputNumber::tag() - ->id('inputnumber-') + ->id('inputnumber') ->disabled(true) ->render(), "Failed asserting that element renders correctly with 'disabled' attribute.", @@ -326,16 +482,28 @@ public function testRenderWithForm(): void { self::assertSame( << + HTML, InputNumber::tag() ->form('form-id') - ->id('inputnumber-') + ->id('inputnumber') ->render(), "Failed asserting that element renders correctly with 'form' attribute.", ); } + public function testRenderWithGenerateId(): void + { + /** @phpstan-var string $id */ + $id = InputNumber::tag()->getAttribute('id', ''); + + self::assertMatchesRegularExpression( + '/^inputnumber-\w+$/', + $id, + 'Failed asserting that element generates an ID when not provided.', + ); + } + public function testRenderWithGlobalDefaultsAreApplied(): void { SimpleFactory::setDefaults(InputNumber::class, ['class' => 'default-class']); @@ -353,10 +521,10 @@ public function testRenderWithHidden(): void { self::assertSame( << + HTML, InputNumber::tag() - ->id('inputnumber-') + ->id('inputnumber') ->hidden(true) ->render(), "Failed asserting that element renders correctly with 'hidden' attribute.", @@ -380,10 +548,10 @@ public function testRenderWithLang(): void { self::assertSame( << + HTML, InputNumber::tag() - ->id('inputnumber-') + ->id('inputnumber') ->lang('en') ->render(), "Failed asserting that element renders correctly with 'lang' attribute.", @@ -394,10 +562,10 @@ public function testRenderWithLangUsingEnum(): void { self::assertSame( << + HTML, InputNumber::tag() - ->id('inputnumber-') + ->id('inputnumber') ->lang(Language::ENGLISH) ->render(), "Failed asserting that element renders correctly with 'lang' attribute using enum.", @@ -408,10 +576,10 @@ public function testRenderWithList(): void { self::assertSame( << + HTML, InputNumber::tag() - ->id('inputnumber-') + ->id('inputnumber') ->list('numbers') ->render(), "Failed asserting that element renders correctly with 'list' attribute.", @@ -422,10 +590,10 @@ public function testRenderWithMax(): void { self::assertSame( << + HTML, InputNumber::tag() - ->id('inputnumber-') + ->id('inputnumber') ->max(100) ->render(), "Failed asserting that element renders correctly with 'max' attribute.", @@ -436,10 +604,10 @@ public function testRenderWithMin(): void { self::assertSame( << + HTML, InputNumber::tag() - ->id('inputnumber-') + ->id('inputnumber') ->min(10) ->render(), "Failed asserting that element renders correctly with 'min' attribute.", @@ -450,10 +618,10 @@ public function testRenderWithMinAndMax(): void { self::assertSame( << + HTML, InputNumber::tag() - ->id('inputnumber-') + ->id('inputnumber') ->min(1) ->max(5) ->render(), @@ -465,10 +633,10 @@ public function testRenderWithName(): void { self::assertSame( << + HTML, InputNumber::tag() - ->id('inputnumber-') + ->id('inputnumber') ->name('quantity') ->render(), "Failed asserting that element renders correctly with 'name' attribute.", @@ -479,10 +647,10 @@ public function testRenderWithPlaceholder(): void { self::assertSame( << + HTML, InputNumber::tag() - ->id('inputnumber-') + ->id('inputnumber') ->placeholder('Enter a number') ->render(), "Failed asserting that element renders correctly with 'placeholder' attribute.", @@ -493,10 +661,10 @@ public function testRenderWithReadonly(): void { self::assertSame( << + HTML, InputNumber::tag() - ->id('inputnumber-') + ->id('inputnumber') ->readonly(true) ->render(), "Failed asserting that element renders correctly with 'readonly' attribute.", @@ -507,10 +675,10 @@ public function testRenderWithRemoveAriaAttribute(): void { self::assertSame( << + HTML, InputNumber::tag() - ->id('inputnumber-') + ->id('inputnumber') ->addAriaAttribute('label', 'Close') ->removeAriaAttribute('label') ->render(), @@ -522,10 +690,10 @@ public function testRenderWithRemoveAttribute(): void { self::assertSame( << + HTML, InputNumber::tag() - ->id('inputnumber-') + ->id('inputnumber') ->addAttribute('data-test', 'value') ->removeAttribute('data-test') ->render(), @@ -537,10 +705,10 @@ public function testRenderWithRemoveDataAttribute(): void { self::assertSame( << + HTML, InputNumber::tag() - ->id('inputnumber-') + ->id('inputnumber') ->addDataAttribute('value', 'test') ->removeDataAttribute('value') ->render(), @@ -552,10 +720,10 @@ public function testRenderWithRequired(): void { self::assertSame( << + HTML, InputNumber::tag() - ->id('inputnumber-') + ->id('inputnumber') ->required(true) ->render(), "Failed asserting that element renders correctly with 'required' attribute.", @@ -566,10 +734,10 @@ public function testRenderWithRole(): void { self::assertSame( << + HTML, InputNumber::tag() - ->id('inputnumber-') + ->id('inputnumber') ->role('spinbutton') ->render(), "Failed asserting that element renders correctly with 'role' attribute.", @@ -580,10 +748,10 @@ public function testRenderWithRoleUsingEnum(): void { self::assertSame( << + HTML, InputNumber::tag() - ->id('inputnumber-') + ->id('inputnumber') ->role(Role::SPINBUTTON) ->render(), "Failed asserting that element renders correctly with 'role' attribute using enum.", @@ -594,10 +762,10 @@ public function testRenderWithStep(): void { self::assertSame( << + HTML, InputNumber::tag() - ->id('inputnumber-') + ->id('inputnumber') ->step(2) ->render(), "Failed asserting that element renders correctly with 'step' attribute.", @@ -608,10 +776,10 @@ public function testRenderWithStepAny(): void { self::assertSame( << + HTML, InputNumber::tag() - ->id('inputnumber-') + ->id('inputnumber') ->step('any') ->render(), "Failed asserting that element renders correctly with 'step' attribute set to 'any'.", @@ -622,10 +790,10 @@ public function testRenderWithStyle(): void { self::assertSame( << + HTML, InputNumber::tag() - ->id('inputnumber-') + ->id('inputnumber') ->style('width: 200px;') ->render(), "Failed asserting that element renders correctly with 'style' attribute.", @@ -636,10 +804,10 @@ public function testRenderWithTabindex(): void { self::assertSame( << + HTML, InputNumber::tag() - ->id('inputnumber-') + ->id('inputnumber') ->tabIndex(1) ->render(), "Failed asserting that element renders correctly with 'tabindex' attribute.", @@ -650,10 +818,10 @@ public function testRenderWithThemeProvider(): void { self::assertSame( << + HTML, InputNumber::tag() - ->id('inputnumber-') + ->id('inputnumber') ->addThemeProvider('muted', DefaultThemeProvider::class) ->render(), "Failed asserting that element renders correctly with 'addThemeProvider()' method.", @@ -664,10 +832,10 @@ public function testRenderWithTitle(): void { self::assertSame( << + HTML, InputNumber::tag() - ->id('inputnumber-') + ->id('inputnumber') ->title('Select a number') ->render(), "Failed asserting that element renders correctly with 'title' attribute.", @@ -676,9 +844,13 @@ public function testRenderWithTitle(): void public function testRenderWithToString(): void { - self::assertStringContainsString( - 'type="number"', - LineEndingNormalizer::normalize((string) InputNumber::tag()), + self::assertSame( + << + HTML, + InputNumber::tag() + ->id(null) + ->render(), "Failed asserting that '__toString()' method renders correctly.", ); } @@ -687,10 +859,10 @@ public function testRenderWithTranslate(): void { self::assertSame( << + HTML, InputNumber::tag() - ->id('inputnumber-') + ->id('inputnumber') ->translate(false) ->render(), "Failed asserting that element renders correctly with 'translate' attribute.", @@ -701,10 +873,10 @@ public function testRenderWithTranslateUsingEnum(): void { self::assertSame( << + HTML, InputNumber::tag() - ->id('inputnumber-') + ->id('inputnumber') ->translate(Translate::NO) ->render(), "Failed asserting that element renders correctly with 'translate' attribute using enum.", @@ -727,10 +899,10 @@ public function testRenderWithValue(): void { self::assertSame( << + HTML, InputNumber::tag() - ->id('inputnumber-') + ->id('inputnumber') ->value(42) ->render(), "Failed asserting that element renders correctly with 'value' attribute.", diff --git a/tests/Form/InputPasswordTest.php b/tests/Form/InputPasswordTest.php index 7c9db53..7086b63 100644 --- a/tests/Form/InputPasswordTest.php +++ b/tests/Form/InputPasswordTest.php @@ -4,7 +4,6 @@ namespace UIAwesome\Html\Tests\Form; -use PHPForge\Support\LineEndingNormalizer; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use UIAwesome\Html\Attribute\Values\{ @@ -20,6 +19,7 @@ }; use UIAwesome\Html\Core\Factory\SimpleFactory; use UIAwesome\Html\Form\InputPassword; +use UIAwesome\Html\Interop\Inline; use UIAwesome\Html\Tests\Support\Stub\{DefaultProvider, DefaultThemeProvider}; /** @@ -38,7 +38,6 @@ * @copyright Copyright (C) 2026 Terabytesoftw. * @license https://opensource.org/license/bsd-3-clause BSD 3-Clause License. */ -#[Group('html')] #[Group('form')] final class InputPasswordTest extends TestCase { @@ -55,9 +54,9 @@ public function testRenderWithAccesskey(): void { self::assertSame( << + HTML, - InputPassword::tag()->id('inputpassword-')->accesskey('k')->render(), + InputPassword::tag()->id('inputpassword')->accesskey('k')->render(), "Failed asserting that element renders correctly with 'accesskey' attribute.", ); } @@ -66,9 +65,9 @@ public function testRenderWithAddAriaAttribute(): void { self::assertSame( << + HTML, - InputPassword::tag()->id('inputpassword-')->addAriaAttribute('label', 'Password')->render(), + InputPassword::tag()->id('inputpassword')->addAriaAttribute('label', 'Password')->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method.", ); } @@ -77,20 +76,121 @@ public function testRenderWithAddAriaAttributeUsingEnum(): void { self::assertSame( << + HTML, - InputPassword::tag()->id('inputpassword-')->addAriaAttribute(Aria::HIDDEN, true)->render(), + InputPassword::tag()->id('inputpassword')->addAriaAttribute(Aria::HIDDEN, true)->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method using enum.", ); } + public function testRenderWithAddAriaDescribedByString(): void + { + self::assertSame( + << + HTML, + InputPassword::tag() + ->addAriaAttribute('describedby', 'custom-help') + ->id('inputpassword') + ->render(), + "Failed asserting that an explicit 'aria-describedby' string value is preserved.", + ); + } + + public function testRenderWithAddAriaDescribedByTrueBooleanValue(): void + { + self::assertSame( + << + HTML, + InputPassword::tag() + ->addAriaAttribute('describedby', true) + ->id('inputpassword') + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to " + . "'true'.", + ); + } + + public function testRenderWithAddAriaDescribedByTrueBooleanValueAndIdNull(): void + { + self::assertSame( + << + HTML, + InputPassword::tag() + ->addAriaAttribute('describedby', true) + ->id(null) + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to " + . "'true' and 'id' is 'null'.", + ); + } + + public function testRenderWithAddAriaDescribedByTrueBooleanValueAndPrefixSuffix(): void + { + self::assertSame( + <<Prefix + + Suffix + HTML, + InputPassword::tag() + ->addAriaAttribute('describedby', true) + ->id('inputpassword') + ->prefix('Prefix') + ->prefixTag(Inline::SPAN) + ->suffix('Suffix') + ->suffixTag(Inline::SPAN) + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to " + . "'true' and prefix/suffix.", + ); + } + + public function testRenderWithAddAriaDescribedByTrueBooleanValueString(): void + { + self::assertSame( + << + HTML, + InputPassword::tag() + ->addAriaAttribute('describedby', 'true') + ->id('inputpassword') + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to " + . "'true'.", + ); + } + + public function testRenderWithAddAriaDescribedByTrueStringValueAndPrefixSuffix(): void + { + self::assertSame( + <<Prefix + + Suffix + HTML, + InputPassword::tag() + ->addAriaAttribute('describedby', 'true') + ->id('inputpassword') + ->prefix('Prefix') + ->prefixTag(Inline::SPAN) + ->suffix('Suffix') + ->suffixTag(Inline::SPAN) + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to " + . "'true' and prefix/suffix.", + ); + } + public function testRenderWithAddAttribute(): void { self::assertSame( << + HTML, - InputPassword::tag()->id('inputpassword-')->addAttribute('data-test', 'value')->render(), + InputPassword::tag()->id('inputpassword')->addAttribute('data-test', 'value')->render(), "Failed asserting that element renders correctly with 'addAttribute()' method.", ); } @@ -99,9 +199,9 @@ public function testRenderWithAddAttributeUsingEnum(): void { self::assertSame( << + HTML, - InputPassword::tag()->id('inputpassword-')->addAttribute(GlobalAttribute::TITLE, 'Enter password')->render(), + InputPassword::tag()->id('inputpassword')->addAttribute(GlobalAttribute::TITLE, 'Enter password')->render(), "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", ); } @@ -110,9 +210,9 @@ public function testRenderWithAddDataAttribute(): void { self::assertSame( << + HTML, - InputPassword::tag()->id('inputpassword-')->addDataAttribute('id', 'value')->render(), + InputPassword::tag()->id('inputpassword')->addDataAttribute('id', 'value')->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method.", ); } @@ -121,9 +221,9 @@ public function testRenderWithAddDataAttributeUsingEnum(): void { self::assertSame( << + HTML, - InputPassword::tag()->id('inputpassword-')->addDataAttribute(Data::VALUE, 'test')->render(), + InputPassword::tag()->id('inputpassword')->addDataAttribute(Data::VALUE, 'test')->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method using enum.", ); } @@ -132,10 +232,10 @@ public function testRenderWithAriaAttributes(): void { self::assertSame( << + HTML, InputPassword::tag() - ->id('inputpassword-') + ->id('inputpassword') ->ariaAttributes([ 'controls' => 'password-field', 'label' => 'Enter password', @@ -145,24 +245,80 @@ public function testRenderWithAriaAttributes(): void ); } + public function testRenderWithAriaAttributesAndAriaDescribedByTrueBooleanValue(): void + { + self::assertSame( + << + HTML, + InputPassword::tag() + ->ariaAttributes(['describedby' => true]) + ->id('inputpassword') + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to true.", + ); + } + + public function testRenderWithAriaAttributesAndAriaDescribedByTrueStringValue(): void + { + self::assertSame( + << + HTML, + InputPassword::tag() + ->ariaAttributes(['describedby' => 'true']) + ->id('inputpassword') + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to true.", + ); + } + public function testRenderWithAttributes(): void { self::assertSame( << + HTML, - InputPassword::tag()->id('inputpassword-')->attributes(['class' => 'password-input'])->render(), + InputPassword::tag()->id('inputpassword')->attributes(['class' => 'password-input'])->render(), "Failed asserting that element renders correctly with 'attributes()' method.", ); } + public function testRenderWithAttributesAndAriaDescribedByTrueBooleanValue(): void + { + self::assertSame( + << + HTML, + InputPassword::tag() + ->attributes(['aria-describedby' => true]) + ->id('inputpassword') + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to true.", + ); + } + + public function testRenderWithAttributesAndAriaDescribedByTrueStringValue(): void + { + self::assertSame( + << + HTML, + InputPassword::tag() + ->attributes(['aria-describedby' => 'true']) + ->id('inputpassword') + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to true.", + ); + } + public function testRenderWithAutocomplete(): void { self::assertSame( << + HTML, - InputPassword::tag()->autocomplete('current-password')->id('inputpassword-')->render(), + InputPassword::tag()->autocomplete('current-password')->id('inputpassword')->render(), "Failed asserting that element renders correctly with 'autocomplete' attribute.", ); } @@ -171,9 +327,9 @@ public function testRenderWithAutocompleteUsingEnum(): void { self::assertSame( << + HTML, - InputPassword::tag()->autocomplete(Autocomplete::OFF)->id('inputpassword-')->render(), + InputPassword::tag()->autocomplete(Autocomplete::OFF)->id('inputpassword')->render(), "Failed asserting that element renders correctly with 'autocomplete' attribute using enum.", ); } @@ -182,9 +338,9 @@ public function testRenderWithAutofocus(): void { self::assertSame( << + HTML, - InputPassword::tag()->autofocus(true)->id('inputpassword-')->render(), + InputPassword::tag()->autofocus(true)->id('inputpassword')->render(), "Failed asserting that element renders correctly with 'autofocus' attribute.", ); } @@ -193,9 +349,9 @@ public function testRenderWithClass(): void { self::assertSame( << + HTML, - InputPassword::tag()->id('inputpassword-')->class('password-input')->render(), + InputPassword::tag()->id('inputpassword')->class('password-input')->render(), "Failed asserting that element renders correctly with 'class' attribute.", ); } @@ -204,9 +360,9 @@ public function testRenderWithDataAttributes(): void { self::assertSame( << + HTML, - InputPassword::tag()->id('inputpassword-')->dataAttributes(['id' => 'value'])->render(), + InputPassword::tag()->id('inputpassword')->dataAttributes(['id' => 'value'])->render(), "Failed asserting that element renders correctly with 'dataAttributes()' method.", ); } @@ -215,9 +371,9 @@ public function testRenderWithDefaultConfigurationValues(): void { self::assertSame( << + HTML, - InputPassword::tag(['class' => 'default-class'])->id('inputpassword-')->render(), + InputPassword::tag(['class' => 'default-class'])->id('inputpassword')->render(), 'Failed asserting that default configuration values are applied correctly.', ); } @@ -226,9 +382,9 @@ public function testRenderWithDefaultProvider(): void { self::assertSame( << + HTML, - InputPassword::tag()->id('inputpassword-')->addDefaultProvider(DefaultProvider::class)->render(), + InputPassword::tag()->id('inputpassword')->addDefaultProvider(DefaultProvider::class)->render(), 'Failed asserting that default provider is applied correctly.', ); } @@ -237,9 +393,9 @@ public function testRenderWithDefaultValues(): void { self::assertSame( << + HTML, - InputPassword::tag()->id('inputpassword-')->render(), + InputPassword::tag()->id('inputpassword')->render(), 'Failed asserting that element renders correctly with default values.', ); } @@ -248,9 +404,9 @@ public function testRenderWithDir(): void { self::assertSame( << + HTML, - InputPassword::tag()->id('inputpassword-')->dir('ltr')->render(), + InputPassword::tag()->id('inputpassword')->dir('ltr')->render(), "Failed asserting that element renders correctly with 'dir' attribute.", ); } @@ -259,9 +415,9 @@ public function testRenderWithDirUsingEnum(): void { self::assertSame( << + HTML, - InputPassword::tag()->id('inputpassword-')->dir(Direction::LTR)->render(), + InputPassword::tag()->id('inputpassword')->dir(Direction::LTR)->render(), "Failed asserting that element renders correctly with 'dir' attribute using enum.", ); } @@ -270,9 +426,9 @@ public function testRenderWithDisabled(): void { self::assertSame( << + HTML, - InputPassword::tag()->id('inputpassword-')->disabled(true)->render(), + InputPassword::tag()->id('inputpassword')->disabled(true)->render(), "Failed asserting that element renders correctly with 'disabled' attribute.", ); } @@ -281,13 +437,25 @@ public function testRenderWithForm(): void { self::assertSame( << + HTML, - InputPassword::tag()->form('form-id')->id('inputpassword-')->render(), + InputPassword::tag()->form('form-id')->id('inputpassword')->render(), "Failed asserting that element renders correctly with 'form' attribute.", ); } + public function testRenderWithGenerateId(): void + { + /** @phpstan-var string $id */ + $id = InputPassword::tag()->getAttribute('id', ''); + + self::assertMatchesRegularExpression( + '/^inputpassword-\w+$/', + $id, + 'Failed asserting that element generates an ID when not provided.', + ); + } + public function testRenderWithGlobalDefaultsAreApplied(): void { SimpleFactory::setDefaults(InputPassword::class, ['class' => 'default-class']); @@ -305,9 +473,9 @@ public function testRenderWithHidden(): void { self::assertSame( << + HTML, - InputPassword::tag()->id('inputpassword-')->hidden(true)->render(), + InputPassword::tag()->id('inputpassword')->hidden(true)->render(), "Failed asserting that element renders correctly with 'hidden' attribute.", ); } @@ -327,9 +495,9 @@ public function testRenderWithInputMode(): void { self::assertSame( << + HTML, - InputPassword::tag()->id('inputpassword-')->inputMode('numeric')->render(), + InputPassword::tag()->id('inputpassword')->inputMode('numeric')->render(), "Failed asserting that element renders correctly with 'inputmode' attribute.", ); } @@ -338,9 +506,9 @@ public function testRenderWithInputModeUsingEnum(): void { self::assertSame( << + HTML, - InputPassword::tag()->id('inputpassword-')->inputMode(InputMode::NUMERIC)->render(), + InputPassword::tag()->id('inputpassword')->inputMode(InputMode::NUMERIC)->render(), "Failed asserting that element renders correctly with 'inputmode' attribute using enum.", ); } @@ -349,9 +517,9 @@ public function testRenderWithLang(): void { self::assertSame( << + HTML, - InputPassword::tag()->id('inputpassword-')->lang('en')->render(), + InputPassword::tag()->id('inputpassword')->lang('en')->render(), "Failed asserting that element renders correctly with 'lang' attribute.", ); } @@ -360,9 +528,9 @@ public function testRenderWithLangUsingEnum(): void { self::assertSame( << + HTML, - InputPassword::tag()->id('inputpassword-')->lang(Language::ENGLISH)->render(), + InputPassword::tag()->id('inputpassword')->lang(Language::ENGLISH)->render(), "Failed asserting that element renders correctly with 'lang' attribute using enum.", ); } @@ -371,9 +539,9 @@ public function testRenderWithMaxlength(): void { self::assertSame( << + HTML, - InputPassword::tag()->id('inputpassword-')->maxlength(12)->render(), + InputPassword::tag()->id('inputpassword')->maxlength(12)->render(), "Failed asserting that element renders correctly with 'maxlength' attribute.", ); } @@ -382,9 +550,9 @@ public function testRenderWithMinlength(): void { self::assertSame( << + HTML, - InputPassword::tag()->id('inputpassword-')->minlength(8)->render(), + InputPassword::tag()->id('inputpassword')->minlength(8)->render(), "Failed asserting that element renders correctly with 'minlength' attribute.", ); } @@ -393,9 +561,9 @@ public function testRenderWithName(): void { self::assertSame( << + HTML, - InputPassword::tag()->id('inputpassword-')->name('password')->render(), + InputPassword::tag()->id('inputpassword')->name('password')->render(), "Failed asserting that element renders correctly with 'name' attribute.", ); } @@ -404,9 +572,9 @@ public function testRenderWithPattern(): void { self::assertSame( << + HTML, - InputPassword::tag()->id('inputpassword-')->pattern('.{8,}')->render(), + InputPassword::tag()->id('inputpassword')->pattern('.{8,}')->render(), "Failed asserting that element renders correctly with 'pattern' attribute.", ); } @@ -415,9 +583,9 @@ public function testRenderWithPlaceholder(): void { self::assertSame( << + HTML, - InputPassword::tag()->id('inputpassword-')->placeholder('Password')->render(), + InputPassword::tag()->id('inputpassword')->placeholder('Password')->render(), "Failed asserting that element renders correctly with 'placeholder' attribute.", ); } @@ -426,9 +594,9 @@ public function testRenderWithReadonly(): void { self::assertSame( << + HTML, - InputPassword::tag()->id('inputpassword-')->readonly(true)->render(), + InputPassword::tag()->id('inputpassword')->readonly(true)->render(), "Failed asserting that element renders correctly with 'readonly' attribute.", ); } @@ -437,10 +605,10 @@ public function testRenderWithRemoveAriaAttribute(): void { self::assertSame( << + HTML, InputPassword::tag() - ->id('inputpassword-') + ->id('inputpassword') ->addAriaAttribute('label', 'Close') ->removeAriaAttribute('label') ->render(), @@ -452,10 +620,10 @@ public function testRenderWithRemoveAttribute(): void { self::assertSame( << + HTML, InputPassword::tag() - ->id('inputpassword-') + ->id('inputpassword') ->addAttribute('data-test', 'value') ->removeAttribute('data-test') ->render(), @@ -467,10 +635,10 @@ public function testRenderWithRemoveDataAttribute(): void { self::assertSame( << + HTML, InputPassword::tag() - ->id('inputpassword-') + ->id('inputpassword') ->addDataAttribute('value', 'test') ->removeDataAttribute('value') ->render(), @@ -482,9 +650,9 @@ public function testRenderWithRequired(): void { self::assertSame( << + HTML, - InputPassword::tag()->id('inputpassword-')->required(true)->render(), + InputPassword::tag()->id('inputpassword')->required(true)->render(), "Failed asserting that element renders correctly with 'required' attribute.", ); } @@ -493,9 +661,9 @@ public function testRenderWithRole(): void { self::assertSame( << + HTML, - InputPassword::tag()->id('inputpassword-')->role('textbox')->render(), + InputPassword::tag()->id('inputpassword')->role('textbox')->render(), "Failed asserting that element renders correctly with 'role' attribute.", ); } @@ -504,9 +672,9 @@ public function testRenderWithRoleUsingEnum(): void { self::assertSame( << + HTML, - InputPassword::tag()->id('inputpassword-')->role(Role::TEXTBOX)->render(), + InputPassword::tag()->id('inputpassword')->role(Role::TEXTBOX)->render(), "Failed asserting that element renders correctly with 'role' attribute using enum.", ); } @@ -515,9 +683,9 @@ public function testRenderWithSize(): void { self::assertSame( << + HTML, - InputPassword::tag()->id('inputpassword-')->size(20)->render(), + InputPassword::tag()->id('inputpassword')->size(20)->render(), "Failed asserting that element renders correctly with 'size' attribute.", ); } @@ -526,9 +694,9 @@ public function testRenderWithStyle(): void { self::assertSame( << + HTML, - InputPassword::tag()->id('inputpassword-')->style('width: 200px;')->render(), + InputPassword::tag()->id('inputpassword')->style('width: 200px;')->render(), "Failed asserting that element renders correctly with 'style' attribute.", ); } @@ -537,9 +705,9 @@ public function testRenderWithTabindex(): void { self::assertSame( << + HTML, - InputPassword::tag()->id('inputpassword-')->tabIndex(1)->render(), + InputPassword::tag()->id('inputpassword')->tabIndex(1)->render(), "Failed asserting that element renders correctly with 'tabindex' attribute.", ); } @@ -548,9 +716,9 @@ public function testRenderWithThemeProvider(): void { self::assertSame( << + HTML, - InputPassword::tag()->id('inputpassword-')->addThemeProvider('muted', DefaultThemeProvider::class)->render(), + InputPassword::tag()->id('inputpassword')->addThemeProvider('muted', DefaultThemeProvider::class)->render(), "Failed asserting that element renders correctly with 'addThemeProvider()' method.", ); } @@ -559,18 +727,22 @@ public function testRenderWithTitle(): void { self::assertSame( << + HTML, - InputPassword::tag()->id('inputpassword-')->title('Enter password')->render(), + InputPassword::tag()->id('inputpassword')->title('Enter password')->render(), "Failed asserting that element renders correctly with 'title' attribute.", ); } public function testRenderWithToString(): void { - self::assertStringContainsString( - 'type="password"', - LineEndingNormalizer::normalize((string) InputPassword::tag()), + self::assertSame( + << + HTML, + InputPassword::tag() + ->id(null) + ->render(), "Failed asserting that '__toString()' method renders correctly.", ); } @@ -579,9 +751,9 @@ public function testRenderWithTranslate(): void { self::assertSame( << + HTML, - InputPassword::tag()->id('inputpassword-')->translate(false)->render(), + InputPassword::tag()->id('inputpassword')->translate(false)->render(), "Failed asserting that element renders correctly with 'translate' attribute.", ); } @@ -590,9 +762,9 @@ public function testRenderWithTranslateUsingEnum(): void { self::assertSame( << + HTML, - InputPassword::tag()->id('inputpassword-')->translate(Translate::NO)->render(), + InputPassword::tag()->id('inputpassword')->translate(Translate::NO)->render(), "Failed asserting that element renders correctly with 'translate' attribute using enum.", ); } @@ -613,9 +785,9 @@ public function testRenderWithValue(): void { self::assertSame( << + HTML, - InputPassword::tag()->id('inputpassword-')->value('secret')->render(), + InputPassword::tag()->id('inputpassword')->value('secret')->render(), "Failed asserting that element renders correctly with 'value' attribute.", ); } diff --git a/tests/Form/InputRadioTest.php b/tests/Form/InputRadioTest.php index b27d021..c8e5b68 100644 --- a/tests/Form/InputRadioTest.php +++ b/tests/Form/InputRadioTest.php @@ -4,7 +4,6 @@ namespace UIAwesome\Html\Tests\Form; -use PHPForge\Support\LineEndingNormalizer; use PHPForge\Support\Stub\BackedString; use PHPUnit\Framework\Attributes\{DataProviderExternal, Group}; use PHPUnit\Framework\TestCase; @@ -12,6 +11,7 @@ use UIAwesome\Html\Attribute\Values\{Aria, Data, Direction, GlobalAttribute, Language, Role, Translate}; use UIAwesome\Html\Core\Factory\SimpleFactory; use UIAwesome\Html\Form\InputRadio; +use UIAwesome\Html\Interop\Inline; use UIAwesome\Html\Tests\Provider\Form\CheckedProvider; use UIAwesome\Html\Tests\Support\Stub\{DefaultProvider, DefaultThemeProvider}; use UnitEnum; @@ -36,7 +36,6 @@ * @copyright Copyright (C) 2026 Terabytesoftw. * @license https://opensource.org/license/bsd-3-clause BSD 3-Clause License. */ -#[Group('html')] #[Group('form')] final class InputRadioTest extends TestCase { @@ -54,11 +53,11 @@ public function testRenderWithAccesskey(): void { self::assertSame( << + HTML, InputRadio::tag() ->accesskey('k') - ->id('inputradio-') + ->id('inputradio') ->render(), "Failed asserting that element renders correctly with 'accesskey' attribute.", ); @@ -68,11 +67,11 @@ public function testRenderWithAddAriaAttribute(): void { self::assertSame( << + HTML, InputRadio::tag() ->addAriaAttribute('label', 'Radio selector') - ->id('inputradio-') + ->id('inputradio') ->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method.", ); @@ -82,25 +81,126 @@ public function testRenderWithAddAriaAttributeUsingEnum(): void { self::assertSame( << + HTML, InputRadio::tag() ->addAriaAttribute(Aria::HIDDEN, true) - ->id('inputradio-') + ->id('inputradio') ->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method using enum.", ); } + public function testRenderWithAddAriaDescribedByString(): void + { + self::assertSame( + << + HTML, + InputRadio::tag() + ->addAriaAttribute('describedby', 'custom-help') + ->id('inputradio') + ->render(), + "Failed asserting that an explicit 'aria-describedby' string value is preserved.", + ); + } + + public function testRenderWithAddAriaDescribedByTrueBooleanValue(): void + { + self::assertSame( + << + HTML, + InputRadio::tag() + ->addAriaAttribute('describedby', true) + ->id('inputradio') + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to " + . "'true'.", + ); + } + + public function testRenderWithAddAriaDescribedByTrueBooleanValueAndIdNull(): void + { + self::assertSame( + << + HTML, + InputRadio::tag() + ->addAriaAttribute('describedby', true) + ->id(null) + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to " + . "'true' and 'id' is 'null'.", + ); + } + + public function testRenderWithAddAriaDescribedByTrueBooleanValueAndPrefixSuffix(): void + { + self::assertSame( + <<Prefix + + Suffix + HTML, + InputRadio::tag() + ->addAriaAttribute('describedby', true) + ->id('inputradio') + ->prefix('Prefix') + ->prefixTag(Inline::SPAN) + ->suffix('Suffix') + ->suffixTag(Inline::SPAN) + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to " + . "'true' and prefix/suffix.", + ); + } + + public function testRenderWithAddAriaDescribedByTrueBooleanValueString(): void + { + self::assertSame( + << + HTML, + InputRadio::tag() + ->addAriaAttribute('describedby', 'true') + ->id('inputradio') + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to " + . "'true'.", + ); + } + + public function testRenderWithAddAriaDescribedByTrueStringValueAndPrefixSuffix(): void + { + self::assertSame( + <<Prefix + + Suffix + HTML, + InputRadio::tag() + ->addAriaAttribute('describedby', 'true') + ->id('inputradio') + ->prefix('Prefix') + ->prefixTag(Inline::SPAN) + ->suffix('Suffix') + ->suffixTag(Inline::SPAN) + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to " + . "'true' and prefix/suffix.", + ); + } + public function testRenderWithAddAttribute(): void { self::assertSame( << + HTML, InputRadio::tag() ->addAttribute('data-test', 'value') - ->id('inputradio-') + ->id('inputradio') ->render(), "Failed asserting that element renders correctly with 'addAttribute()' method.", ); @@ -110,11 +210,11 @@ public function testRenderWithAddAttributeUsingEnum(): void { self::assertSame( << + HTML, InputRadio::tag() ->addAttribute(GlobalAttribute::TITLE, 'Select radio') - ->id('inputradio-') + ->id('inputradio') ->render(), "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", ); @@ -124,11 +224,11 @@ public function testRenderWithAddDataAttribute(): void { self::assertSame( << + HTML, InputRadio::tag() ->addDataAttribute('radio', 'value') - ->id('inputradio-') + ->id('inputradio') ->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method.", ); @@ -138,11 +238,11 @@ public function testRenderWithAddDataAttributeUsingEnum(): void { self::assertSame( << + HTML, InputRadio::tag() ->addDataAttribute(Data::VALUE, 'test') - ->id('inputradio-') + ->id('inputradio') ->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method using enum.", ); @@ -152,7 +252,7 @@ public function testRenderWithAriaAttributes(): void { self::assertSame( << + HTML, InputRadio::tag() ->ariaAttributes( @@ -161,35 +261,91 @@ public function testRenderWithAriaAttributes(): void 'label' => 'Select a radio', ], ) - ->id('inputradio-') + ->id('inputradio') ->render(), "Failed asserting that element renders correctly with 'ariaAttributes()' method.", ); } + public function testRenderWithAriaAttributesAndAriaDescribedByTrueBooleanValue(): void + { + self::assertSame( + << + HTML, + InputRadio::tag() + ->ariaAttributes(['describedby' => true]) + ->id('inputradio') + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to true.", + ); + } + + public function testRenderWithAriaAttributesAndAriaDescribedByTrueStringValue(): void + { + self::assertSame( + << + HTML, + InputRadio::tag() + ->ariaAttributes(['describedby' => 'true']) + ->id('inputradio') + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to true.", + ); + } + public function testRenderWithAttributes(): void { self::assertSame( << + HTML, InputRadio::tag() ->attributes(['class' => 'radio-input']) - ->id('inputradio-') + ->id('inputradio') ->render(), "Failed asserting that element renders correctly with 'attributes()' method.", ); } + public function testRenderWithAttributesAndAriaDescribedByTrueBooleanValue(): void + { + self::assertSame( + << + HTML, + InputRadio::tag() + ->attributes(['aria-describedby' => true]) + ->id('inputradio') + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to true.", + ); + } + + public function testRenderWithAttributesAndAriaDescribedByTrueStringValue(): void + { + self::assertSame( + << + HTML, + InputRadio::tag() + ->attributes(['aria-describedby' => 'true']) + ->id('inputradio') + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to true.", + ); + } + public function testRenderWithAutofocus(): void { self::assertSame( << + HTML, InputRadio::tag() ->autofocus(true) - ->id('inputradio-') + ->id('inputradio') ->render(), "Failed asserting that element renders correctly with 'autofocus' attribute.", ); @@ -199,11 +355,11 @@ public function testRenderWithChecked(): void { self::assertSame( << + HTML, InputRadio::tag() ->checked(true) - ->id('inputradio-') + ->id('inputradio') ->render(), "Failed asserting that element renders correctly with 'checked' attribute.", ); @@ -220,15 +376,15 @@ public function testRenderWithCheckedAndValue( ): void { // CheckedProvider returns checkbox-flavored expected HTML; adapt for radio. $expected = str_replace( - ['inputcheckbox-', 'type="checkbox"'], - ['inputradio-', 'type="radio"'], + ['inputcheckbox', 'type="checkbox"'], + ['inputradio', 'type="radio"'], $expected, ); self::assertSame( $expected, InputRadio::tag() - ->id('inputradio-') + ->id('inputradio') ->checked($checked) ->value($value) ->render(), @@ -240,11 +396,11 @@ public function testRenderWithClass(): void { self::assertSame( << + HTML, InputRadio::tag() ->class('radio-input') - ->id('inputradio-') + ->id('inputradio') ->render(), "Failed asserting that element renders correctly with 'class' attribute.", ); @@ -254,11 +410,11 @@ public function testRenderWithClassUsingEnum(): void { self::assertSame( << + HTML, InputRadio::tag() ->class(BackedString::VALUE) - ->id('inputradio-') + ->id('inputradio') ->render(), "Failed asserting that element renders correctly with 'class' attribute.", ); @@ -268,11 +424,11 @@ public function testRenderWithDataAttributes(): void { self::assertSame( << + HTML, InputRadio::tag() ->dataAttributes(['radio' => 'value']) - ->id('inputradio-') + ->id('inputradio') ->render(), "Failed asserting that element renders correctly with 'dataAttributes()' method.", ); @@ -282,10 +438,10 @@ public function testRenderWithDefaultConfigurationValues(): void { self::assertSame( << + HTML, InputRadio::tag(['class' => 'default-class']) - ->id('inputradio-') + ->id('inputradio') ->render(), 'Failed asserting that default configuration values are applied correctly.', ); @@ -295,11 +451,11 @@ public function testRenderWithDefaultProvider(): void { self::assertSame( << + HTML, InputRadio::tag() ->addDefaultProvider(DefaultProvider::class) - ->id('inputradio-') + ->id('inputradio') ->render(), 'Failed asserting that default provider is applied correctly.', ); @@ -309,10 +465,10 @@ public function testRenderWithDefaultValues(): void { self::assertSame( << + HTML, InputRadio::tag() - ->id('inputradio-') + ->id('inputradio') ->render(), 'Failed asserting that element renders correctly with default values.', ); @@ -322,11 +478,11 @@ public function testRenderWithDir(): void { self::assertSame( << + HTML, InputRadio::tag() ->dir('ltr') - ->id('inputradio-') + ->id('inputradio') ->render(), "Failed asserting that element renders correctly with 'dir' attribute.", ); @@ -336,11 +492,11 @@ public function testRenderWithDirUsingEnum(): void { self::assertSame( << + HTML, InputRadio::tag() ->dir(Direction::LTR) - ->id('inputradio-') + ->id('inputradio') ->render(), "Failed asserting that element renders correctly with 'dir' attribute using enum.", ); @@ -350,11 +506,11 @@ public function testRenderWithDisabled(): void { self::assertSame( << + HTML, InputRadio::tag() ->disabled(true) - ->id('inputradio-') + ->id('inputradio') ->render(), "Failed asserting that element renders correctly with 'disabled' attribute.", ); @@ -365,17 +521,15 @@ public function testRenderWithEnclosedByLabel(): void self::assertSame( << - + Label HTML, - LineEndingNormalizer::normalize( - InputRadio::tag() - ->enclosedByLabel(true) - ->id('inputradio-') - ->label('Label') - ->render(), - ), + InputRadio::tag() + ->enclosedByLabel(true) + ->id('inputradio') + ->label('Label') + ->render(), ); } @@ -385,19 +539,17 @@ public function testRenderWithEnclosedByLabelAndCustomTemplate(): void << HTML, - LineEndingNormalizer::normalize( - InputRadio::tag() - ->enclosedByLabel(true) - ->id('inputradio-') - ->label('Red') - ->template('
' . PHP_EOL . '{tag}' . PHP_EOL . '
') - ->render(), - ), + InputRadio::tag() + ->enclosedByLabel(true) + ->id('inputradio') + ->label('Red') + ->template('
' . PHP_EOL . '{tag}' . PHP_EOL . '
') + ->render(), ); } @@ -405,11 +557,11 @@ public function testRenderWithEnclosedByLabelAndLabelContentEmpty(): void { self::assertSame( << + HTML, InputRadio::tag() ->enclosedByLabel(true) - ->id('inputradio-') + ->id('inputradio') ->render(), ); } @@ -419,18 +571,16 @@ public function testRenderWithEnclosedByLabelAndLabelFor(): void self::assertSame( << - + Label HTML, - LineEndingNormalizer::normalize( - InputRadio::tag() - ->enclosedByLabel(true) - ->id('inputradio-') - ->label('Label') - ->labelFor('label-for') - ->render(), - ), + InputRadio::tag() + ->enclosedByLabel(true) + ->id('inputradio') + ->label('Label') + ->labelFor('label-for') + ->render(), ); } @@ -438,7 +588,7 @@ public function testRenderWithEnclosedByLabelIsIdempotent(): void { $radio = InputRadio::tag() ->enclosedByLabel(true) - ->id('inputradio-') + ->id('inputradio') ->label('Label'); $first = $radio->render(); @@ -460,13 +610,11 @@ public function testRenderWithEnclosedByLabelWithoutId(): void Red HTML, - LineEndingNormalizer::normalize( - InputRadio::tag() - ->enclosedByLabel(true) - ->id(null) - ->label('Red') - ->render(), - ), + InputRadio::tag() + ->enclosedByLabel(true) + ->id(null) + ->label('Red') + ->render(), ); } @@ -474,11 +622,11 @@ public function testRenderWithForm(): void { self::assertSame( << + HTML, InputRadio::tag() ->form('form-id') - ->id('inputradio-') + ->id('inputradio') ->render(), "Failed asserting that element renders correctly with 'form' attribute.", ); @@ -513,11 +661,11 @@ public function testRenderWithHidden(): void { self::assertSame( << + HTML, InputRadio::tag() ->hidden(true) - ->id('inputradio-') + ->id('inputradio') ->render(), "Failed asserting that element renders correctly with 'hidden' attribute.", ); @@ -540,11 +688,11 @@ public function testRenderWithLabel(): void { self::assertSame( << - + + HTML, InputRadio::tag() - ->id('inputradio-') + ->id('inputradio') ->label('Label') ->render(), ); @@ -554,11 +702,11 @@ public function testRenderWithLabelAttributes(): void { self::assertSame( << - + + HTML, InputRadio::tag() - ->id('inputradio-') + ->id('inputradio') ->label('Label') ->labelAttributes(['class' => 'value']) ->render(), @@ -569,11 +717,11 @@ public function testRenderWithLabelClass(): void { self::assertSame( << - + + HTML, InputRadio::tag() - ->id('inputradio-') + ->id('inputradio') ->label('Label') ->labelClass('value') ->render(), @@ -584,11 +732,11 @@ public function testRenderWithLabelClassNullValue(): void { self::assertSame( << - + + HTML, InputRadio::tag() - ->id('inputradio-') + ->id('inputradio') ->label('Label') ->labelAttributes(['class' => 'value']) ->labelClass(null) @@ -600,11 +748,11 @@ public function testRenderWithLabelClassOverridesFalse(): void { self::assertSame( << - + + HTML, InputRadio::tag() - ->id('inputradio-') + ->id('inputradio') ->label('Label') ->labelAttributes(['class' => 'value']) ->labelClass('value-override') @@ -616,11 +764,11 @@ public function testRenderWithLabelClassOverridesTrue(): void { self::assertSame( << - + + HTML, InputRadio::tag() - ->id('inputradio-') + ->id('inputradio') ->label('Label') ->labelAttributes(['class' => 'value']) ->labelClass('value-override', true) @@ -632,11 +780,11 @@ public function testRenderWithLabelClassUsingEnum(): void { self::assertSame( << - + + HTML, InputRadio::tag() - ->id('inputradio-') + ->id('inputradio') ->label('Label') ->labelClass(BackedString::VALUE) ->render(), @@ -647,11 +795,11 @@ public function testRenderWithLabelFor(): void { self::assertSame( << + HTML, InputRadio::tag() - ->id('inputradio-') + ->id('inputradio') ->label('Label') ->labelFor('value') ->render(), @@ -662,11 +810,11 @@ public function testRenderWithLabelForNullValue(): void { self::assertSame( << + HTML, InputRadio::tag() - ->id('inputradio-') + ->id('inputradio') ->label('Label') ->labelFor(null) ->render(), @@ -677,10 +825,10 @@ public function testRenderWithLang(): void { self::assertSame( << + HTML, InputRadio::tag() - ->id('inputradio-') + ->id('inputradio') ->lang('en') ->render(), "Failed asserting that element renders correctly with 'lang' attribute.", @@ -691,10 +839,10 @@ public function testRenderWithLangUsingEnum(): void { self::assertSame( << + HTML, InputRadio::tag() - ->id('inputradio-') + ->id('inputradio') ->lang(Language::ENGLISH) ->render(), "Failed asserting that element renders correctly with 'lang' attribute using enum.", @@ -705,10 +853,10 @@ public function testRenderWithName(): void { self::assertSame( << + HTML, InputRadio::tag() - ->id('inputradio-') + ->id('inputradio') ->name('agree') ->render(), "Failed asserting that element renders correctly with 'name' attribute.", @@ -719,10 +867,10 @@ public function testRenderWithNotLabel(): void { self::assertSame( << + HTML, InputRadio::tag() - ->id('inputradio-') + ->id('inputradio') ->label('Label') ->notLabel() ->render(), @@ -733,11 +881,11 @@ public function testRenderWithRemoveAriaAttribute(): void { self::assertSame( << + HTML, InputRadio::tag() ->addAriaAttribute('label', 'Close') - ->id('inputradio-') + ->id('inputradio') ->removeAriaAttribute('label') ->render(), "Failed asserting that element renders correctly with 'removeAriaAttribute()' method.", @@ -748,11 +896,11 @@ public function testRenderWithRemoveAttribute(): void { self::assertSame( << + HTML, InputRadio::tag() ->addAttribute('data-test', 'value') - ->id('inputradio-') + ->id('inputradio') ->removeAttribute('data-test') ->render(), "Failed asserting that element renders correctly with 'removeAttribute()' method.", @@ -763,11 +911,11 @@ public function testRenderWithRemoveDataAttribute(): void { self::assertSame( << + HTML, InputRadio::tag() ->addDataAttribute('value', 'test') - ->id('inputradio-') + ->id('inputradio') ->removeDataAttribute('value') ->render(), "Failed asserting that element renders correctly with 'removeDataAttribute()' method.", @@ -778,10 +926,10 @@ public function testRenderWithRequired(): void { self::assertSame( << + HTML, InputRadio::tag() - ->id('inputradio-') + ->id('inputradio') ->required(true) ->render(), "Failed asserting that element renders correctly with 'required' attribute.", @@ -792,10 +940,10 @@ public function testRenderWithRole(): void { self::assertSame( << + HTML, InputRadio::tag() - ->id('inputradio-') + ->id('inputradio') ->role('radio') ->render(), "Failed asserting that element renders correctly with 'role' attribute.", @@ -806,10 +954,10 @@ public function testRenderWithRoleUsingEnum(): void { self::assertSame( << + HTML, InputRadio::tag() - ->id('inputradio-') + ->id('inputradio') ->role(Role::RADIO) ->render(), "Failed asserting that element renders correctly with 'role' attribute using enum.", @@ -820,10 +968,10 @@ public function testRenderWithStyle(): void { self::assertSame( << + HTML, InputRadio::tag() - ->id('inputradio-') + ->id('inputradio') ->style('width: 20px;') ->render(), "Failed asserting that element renders correctly with 'style' attribute.", @@ -834,10 +982,10 @@ public function testRenderWithTabindex(): void { self::assertSame( << + HTML, InputRadio::tag() - ->id('inputradio-') + ->id('inputradio') ->tabIndex(1) ->render(), "Failed asserting that element renders correctly with 'tabindex' attribute.", @@ -848,11 +996,11 @@ public function testRenderWithThemeProvider(): void { self::assertSame( << + HTML, InputRadio::tag() ->addThemeProvider('muted', DefaultThemeProvider::class) - ->id('inputradio-') + ->id('inputradio') ->render(), "Failed asserting that element renders correctly with 'addThemeProvider()' method.", ); @@ -862,10 +1010,10 @@ public function testRenderWithTitle(): void { self::assertSame( << + HTML, InputRadio::tag() - ->id('inputradio-') + ->id('inputradio') ->title('Select a radio') ->render(), "Failed asserting that element renders correctly with 'title' attribute.", @@ -874,9 +1022,13 @@ public function testRenderWithTitle(): void public function testRenderWithToString(): void { - self::assertStringContainsString( - 'type="radio"', - (string) InputRadio::tag(), + self::assertSame( + << + HTML, + InputRadio::tag() + ->id(null) + ->render(), "Failed asserting that '__toString()' method renders correctly.", ); } @@ -885,10 +1037,10 @@ public function testRenderWithTranslate(): void { self::assertSame( << + HTML, InputRadio::tag() - ->id('inputradio-') + ->id('inputradio') ->translate(false) ->render(), "Failed asserting that element renders correctly with 'translate' attribute.", @@ -899,10 +1051,10 @@ public function testRenderWithTranslateUsingEnum(): void { self::assertSame( << + HTML, InputRadio::tag() - ->id('inputradio-') + ->id('inputradio') ->translate(Translate::NO) ->render(), "Failed asserting that element renders correctly with 'translate' attribute using enum.", @@ -914,10 +1066,10 @@ public function testRenderWithUncheckedValue(): void self::assertSame( << - + HTML, InputRadio::tag() - ->id('inputradio-') + ->id('inputradio') ->name('agree') ->uncheckedValue('0') ->value('1') @@ -932,20 +1084,18 @@ public function testRenderWithUncheckedValueAndEnclosedByLabel(): void << HTML, - LineEndingNormalizer::normalize( - InputRadio::tag() - ->enclosedByLabel(true) - ->id('inputradio-') - ->label('Label') - ->name('agree') - ->uncheckedValue('0') - ->value('1') - ->render(), - ), + InputRadio::tag() + ->enclosedByLabel(true) + ->id('inputradio') + ->label('Label') + ->name('agree') + ->uncheckedValue('0') + ->value('1') + ->render(), ); } @@ -965,10 +1115,10 @@ public function testRenderWithValue(): void { self::assertSame( << + HTML, InputRadio::tag() - ->id('inputradio-') + ->id('inputradio') ->value('accepted') ->render(), "Failed asserting that element renders correctly with 'value' attribute.", diff --git a/tests/Form/InputRangeTest.php b/tests/Form/InputRangeTest.php index 5bed3df..14bbc0d 100644 --- a/tests/Form/InputRangeTest.php +++ b/tests/Form/InputRangeTest.php @@ -4,12 +4,12 @@ namespace UIAwesome\Html\Tests\Form; -use PHPForge\Support\LineEndingNormalizer; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use UIAwesome\Html\Attribute\Values\{Aria, Autocomplete, Data, Direction, GlobalAttribute, Language, Role, Translate}; use UIAwesome\Html\Core\Factory\SimpleFactory; use UIAwesome\Html\Form\InputRange; +use UIAwesome\Html\Interop\Inline; use UIAwesome\Html\Tests\Support\Stub\{DefaultProvider, DefaultThemeProvider}; /** @@ -27,7 +27,6 @@ * @copyright Copyright (C) 2026 Terabytesoftw. * @license https://opensource.org/license/bsd-3-clause BSD 3-Clause License. */ -#[Group('html')] #[Group('form')] final class InputRangeTest extends TestCase { @@ -44,9 +43,9 @@ public function testRenderWithAccesskey(): void { self::assertSame( << + HTML, - InputRange::tag()->id('inputrange-')->accesskey('k')->render(), + InputRange::tag()->id('inputrange')->accesskey('k')->render(), "Failed asserting that element renders correctly with 'accesskey' attribute.", ); } @@ -55,9 +54,9 @@ public function testRenderWithAddAriaAttribute(): void { self::assertSame( << + HTML, - InputRange::tag()->id('inputrange-')->addAriaAttribute('label', 'Range selector')->render(), + InputRange::tag()->id('inputrange')->addAriaAttribute('label', 'Range selector')->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method.", ); } @@ -66,20 +65,121 @@ public function testRenderWithAddAriaAttributeUsingEnum(): void { self::assertSame( << + HTML, - InputRange::tag()->id('inputrange-')->addAriaAttribute(Aria::HIDDEN, true)->render(), + InputRange::tag()->id('inputrange')->addAriaAttribute(Aria::HIDDEN, true)->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method using enum.", ); } + public function testRenderWithAddAriaDescribedByString(): void + { + self::assertSame( + << + HTML, + InputRange::tag() + ->addAriaAttribute('describedby', 'custom-help') + ->id('inputrange') + ->render(), + "Failed asserting that an explicit 'aria-describedby' string value is preserved.", + ); + } + + public function testRenderWithAddAriaDescribedByTrueBooleanValue(): void + { + self::assertSame( + << + HTML, + InputRange::tag() + ->addAriaAttribute('describedby', true) + ->id('inputrange') + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to " + . "'true'.", + ); + } + + public function testRenderWithAddAriaDescribedByTrueBooleanValueAndIdNull(): void + { + self::assertSame( + << + HTML, + InputRange::tag() + ->addAriaAttribute('describedby', true) + ->id(null) + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to " + . "'true' and 'id' is 'null'.", + ); + } + + public function testRenderWithAddAriaDescribedByTrueBooleanValueAndPrefixSuffix(): void + { + self::assertSame( + <<Prefix + + Suffix + HTML, + InputRange::tag() + ->addAriaAttribute('describedby', true) + ->id('inputrange') + ->prefix('Prefix') + ->prefixTag(Inline::SPAN) + ->suffix('Suffix') + ->suffixTag(Inline::SPAN) + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to " + . "'true' and prefix/suffix.", + ); + } + + public function testRenderWithAddAriaDescribedByTrueBooleanValueString(): void + { + self::assertSame( + << + HTML, + InputRange::tag() + ->addAriaAttribute('describedby', 'true') + ->id('inputrange') + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to " + . "'true'.", + ); + } + + public function testRenderWithAddAriaDescribedByTrueStringValueAndPrefixSuffix(): void + { + self::assertSame( + <<Prefix + + Suffix + HTML, + InputRange::tag() + ->addAriaAttribute('describedby', 'true') + ->id('inputrange') + ->prefix('Prefix') + ->prefixTag(Inline::SPAN) + ->suffix('Suffix') + ->suffixTag(Inline::SPAN) + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to " + . "'true' and prefix/suffix.", + ); + } + public function testRenderWithAddAttribute(): void { self::assertSame( << + HTML, - InputRange::tag()->id('inputrange-')->addAttribute('data-test', 'value')->render(), + InputRange::tag()->id('inputrange')->addAttribute('data-test', 'value')->render(), "Failed asserting that element renders correctly with 'addAttribute()' method.", ); } @@ -88,9 +188,9 @@ public function testRenderWithAddAttributeUsingEnum(): void { self::assertSame( << + HTML, - InputRange::tag()->id('inputrange-')->addAttribute(GlobalAttribute::TITLE, 'Select range')->render(), + InputRange::tag()->id('inputrange')->addAttribute(GlobalAttribute::TITLE, 'Select range')->render(), "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", ); } @@ -99,9 +199,9 @@ public function testRenderWithAddDataAttribute(): void { self::assertSame( << + HTML, - InputRange::tag()->id('inputrange-')->addDataAttribute('range', 'value')->render(), + InputRange::tag()->id('inputrange')->addDataAttribute('range', 'value')->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method.", ); } @@ -110,9 +210,9 @@ public function testRenderWithAddDataAttributeUsingEnum(): void { self::assertSame( << + HTML, - InputRange::tag()->id('inputrange-')->addDataAttribute(Data::VALUE, 'test')->render(), + InputRange::tag()->id('inputrange')->addDataAttribute(Data::VALUE, 'test')->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method using enum.", ); } @@ -121,10 +221,10 @@ public function testRenderWithAriaAttributes(): void { self::assertSame( << + HTML, InputRange::tag() - ->id('inputrange-') + ->id('inputrange') ->ariaAttributes([ 'controls' => 'range-picker', 'label' => 'Select a range', @@ -134,24 +234,80 @@ public function testRenderWithAriaAttributes(): void ); } + public function testRenderWithAriaAttributesAndAriaDescribedByTrueBooleanValue(): void + { + self::assertSame( + << + HTML, + InputRange::tag() + ->ariaAttributes(['describedby' => true]) + ->id('inputrange') + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to true.", + ); + } + + public function testRenderWithAriaAttributesAndAriaDescribedByTrueStringValue(): void + { + self::assertSame( + << + HTML, + InputRange::tag() + ->ariaAttributes(['describedby' => 'true']) + ->id('inputrange') + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to true.", + ); + } + public function testRenderWithAttributes(): void { self::assertSame( << + HTML, - InputRange::tag()->id('inputrange-')->attributes(['class' => 'range-input'])->render(), + InputRange::tag()->id('inputrange')->attributes(['class' => 'range-input'])->render(), "Failed asserting that element renders correctly with 'attributes()' method.", ); } + public function testRenderWithAttributesAndAriaDescribedByTrueBooleanValue(): void + { + self::assertSame( + << + HTML, + InputRange::tag() + ->attributes(['aria-describedby' => true]) + ->id('inputrange') + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to true.", + ); + } + + public function testRenderWithAttributesAndAriaDescribedByTrueStringValue(): void + { + self::assertSame( + << + HTML, + InputRange::tag() + ->attributes(['aria-describedby' => 'true']) + ->id('inputrange') + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to true.", + ); + } + public function testRenderWithAutocomplete(): void { self::assertSame( << + HTML, - InputRange::tag()->autocomplete('on')->id('inputrange-')->render(), + InputRange::tag()->autocomplete('on')->id('inputrange')->render(), "Failed asserting that element renders correctly with 'autocomplete' attribute.", ); } @@ -160,9 +316,9 @@ public function testRenderWithAutocompleteUsingEnum(): void { self::assertSame( << + HTML, - InputRange::tag()->autocomplete(Autocomplete::ON)->id('inputrange-')->render(), + InputRange::tag()->autocomplete(Autocomplete::ON)->id('inputrange')->render(), "Failed asserting that element renders correctly with 'autocomplete' attribute using enum.", ); } @@ -171,9 +327,9 @@ public function testRenderWithAutofocus(): void { self::assertSame( << + HTML, - InputRange::tag()->autofocus(true)->id('inputrange-')->render(), + InputRange::tag()->autofocus(true)->id('inputrange')->render(), "Failed asserting that element renders correctly with 'autofocus' attribute.", ); } @@ -182,9 +338,9 @@ public function testRenderWithClass(): void { self::assertSame( << + HTML, - InputRange::tag()->id('inputrange-')->class('range-input')->render(), + InputRange::tag()->id('inputrange')->class('range-input')->render(), "Failed asserting that element renders correctly with 'class' attribute.", ); } @@ -193,9 +349,9 @@ public function testRenderWithDataAttributes(): void { self::assertSame( << + HTML, - InputRange::tag()->id('inputrange-')->dataAttributes(['range' => 'value'])->render(), + InputRange::tag()->id('inputrange')->dataAttributes(['range' => 'value'])->render(), "Failed asserting that element renders correctly with 'dataAttributes()' method.", ); } @@ -204,9 +360,9 @@ public function testRenderWithDefaultConfigurationValues(): void { self::assertSame( << + HTML, - InputRange::tag(['class' => 'default-class'])->id('inputrange-')->render(), + InputRange::tag(['class' => 'default-class'])->id('inputrange')->render(), 'Failed asserting that default configuration values are applied correctly.', ); } @@ -215,9 +371,9 @@ public function testRenderWithDefaultProvider(): void { self::assertSame( << + HTML, - InputRange::tag()->id('inputrange-')->addDefaultProvider(DefaultProvider::class)->render(), + InputRange::tag()->id('inputrange')->addDefaultProvider(DefaultProvider::class)->render(), 'Failed asserting that default provider is applied correctly.', ); } @@ -226,9 +382,9 @@ public function testRenderWithDefaultValues(): void { self::assertSame( << + HTML, - InputRange::tag()->id('inputrange-')->render(), + InputRange::tag()->id('inputrange')->render(), 'Failed asserting that element renders correctly with default values.', ); } @@ -237,9 +393,9 @@ public function testRenderWithDir(): void { self::assertSame( << + HTML, - InputRange::tag()->id('inputrange-')->dir('ltr')->render(), + InputRange::tag()->id('inputrange')->dir('ltr')->render(), "Failed asserting that element renders correctly with 'dir' attribute.", ); } @@ -248,9 +404,9 @@ public function testRenderWithDirUsingEnum(): void { self::assertSame( << + HTML, - InputRange::tag()->id('inputrange-')->dir(Direction::LTR)->render(), + InputRange::tag()->id('inputrange')->dir(Direction::LTR)->render(), "Failed asserting that element renders correctly with 'dir' attribute using enum.", ); } @@ -259,9 +415,9 @@ public function testRenderWithDisabled(): void { self::assertSame( << + HTML, - InputRange::tag()->id('inputrange-')->disabled(true)->render(), + InputRange::tag()->id('inputrange')->disabled(true)->render(), "Failed asserting that element renders correctly with 'disabled' attribute.", ); } @@ -270,13 +426,25 @@ public function testRenderWithForm(): void { self::assertSame( << + HTML, - InputRange::tag()->form('form-id')->id('inputrange-')->render(), + InputRange::tag()->form('form-id')->id('inputrange')->render(), "Failed asserting that element renders correctly with 'form' attribute.", ); } + public function testRenderWithGenerateId(): void + { + /** @phpstan-var string $id */ + $id = InputRange::tag()->getAttribute('id', ''); + + self::assertMatchesRegularExpression( + '/^inputrange-\w+$/', + $id, + 'Failed asserting that element generates an ID when not provided.', + ); + } + public function testRenderWithGlobalDefaultsAreApplied(): void { SimpleFactory::setDefaults(InputRange::class, ['class' => 'default-class']); @@ -294,9 +462,9 @@ public function testRenderWithHidden(): void { self::assertSame( << + HTML, - InputRange::tag()->id('inputrange-')->hidden(true)->render(), + InputRange::tag()->id('inputrange')->hidden(true)->render(), "Failed asserting that element renders correctly with 'hidden' attribute.", ); } @@ -316,9 +484,9 @@ public function testRenderWithLang(): void { self::assertSame( << + HTML, - InputRange::tag()->id('inputrange-')->lang('en')->render(), + InputRange::tag()->id('inputrange')->lang('en')->render(), "Failed asserting that element renders correctly with 'lang' attribute.", ); } @@ -327,9 +495,9 @@ public function testRenderWithLangUsingEnum(): void { self::assertSame( << + HTML, - InputRange::tag()->id('inputrange-')->lang(Language::ENGLISH)->render(), + InputRange::tag()->id('inputrange')->lang(Language::ENGLISH)->render(), "Failed asserting that element renders correctly with 'lang' attribute using enum.", ); } @@ -338,9 +506,9 @@ public function testRenderWithList(): void { self::assertSame( << + HTML, - InputRange::tag()->id('inputrange-')->list('ranges')->render(), + InputRange::tag()->id('inputrange')->list('ranges')->render(), "Failed asserting that element renders correctly with 'list' attribute.", ); } @@ -349,9 +517,9 @@ public function testRenderWithMax(): void { self::assertSame( << + HTML, - InputRange::tag()->id('inputrange-')->max(100)->render(), + InputRange::tag()->id('inputrange')->max(100)->render(), "Failed asserting that element renders correctly with 'max' attribute.", ); } @@ -360,9 +528,9 @@ public function testRenderWithMin(): void { self::assertSame( << + HTML, - InputRange::tag()->id('inputrange-')->min(10)->render(), + InputRange::tag()->id('inputrange')->min(10)->render(), "Failed asserting that element renders correctly with 'min' attribute.", ); } @@ -371,10 +539,10 @@ public function testRenderWithMinAndMax(): void { self::assertSame( << + HTML, InputRange::tag() - ->id('inputrange-') + ->id('inputrange') ->min(10) ->max(100) ->render(), @@ -386,9 +554,9 @@ public function testRenderWithName(): void { self::assertSame( << + HTML, - InputRange::tag()->id('inputrange-')->name('volume')->render(), + InputRange::tag()->id('inputrange')->name('volume')->render(), "Failed asserting that element renders correctly with 'name' attribute.", ); } @@ -397,10 +565,10 @@ public function testRenderWithRemoveAriaAttribute(): void { self::assertSame( << + HTML, InputRange::tag() - ->id('inputrange-') + ->id('inputrange') ->addAriaAttribute('label', 'Close') ->removeAriaAttribute('label') ->render(), @@ -412,10 +580,10 @@ public function testRenderWithRemoveAttribute(): void { self::assertSame( << + HTML, InputRange::tag() - ->id('inputrange-') + ->id('inputrange') ->addAttribute('data-test', 'value') ->removeAttribute('data-test') ->render(), @@ -427,10 +595,10 @@ public function testRenderWithRemoveDataAttribute(): void { self::assertSame( << + HTML, InputRange::tag() - ->id('inputrange-') + ->id('inputrange') ->addDataAttribute('value', 'test') ->removeDataAttribute('value') ->render(), @@ -442,9 +610,9 @@ public function testRenderWithRole(): void { self::assertSame( << + HTML, - InputRange::tag()->id('inputrange-')->role('slider')->render(), + InputRange::tag()->id('inputrange')->role('slider')->render(), "Failed asserting that element renders correctly with 'role' attribute.", ); } @@ -453,9 +621,9 @@ public function testRenderWithRoleUsingEnum(): void { self::assertSame( << + HTML, - InputRange::tag()->id('inputrange-')->role(Role::SLIDER)->render(), + InputRange::tag()->id('inputrange')->role(Role::SLIDER)->render(), "Failed asserting that element renders correctly with 'role' attribute using enum.", ); } @@ -464,9 +632,9 @@ public function testRenderWithStep(): void { self::assertSame( << + HTML, - InputRange::tag()->id('inputrange-')->step(2)->render(), + InputRange::tag()->id('inputrange')->step(2)->render(), "Failed asserting that element renders correctly with 'step' attribute.", ); } @@ -475,9 +643,9 @@ public function testRenderWithStepAny(): void { self::assertSame( << + HTML, - InputRange::tag()->id('inputrange-')->step('any')->render(), + InputRange::tag()->id('inputrange')->step('any')->render(), "Failed asserting that element renders correctly with 'step' attribute set to 'any'.", ); } @@ -486,9 +654,9 @@ public function testRenderWithStyle(): void { self::assertSame( << + HTML, - InputRange::tag()->id('inputrange-')->style('width: 200px;')->render(), + InputRange::tag()->id('inputrange')->style('width: 200px;')->render(), "Failed asserting that element renders correctly with 'style' attribute.", ); } @@ -497,9 +665,9 @@ public function testRenderWithTabindex(): void { self::assertSame( << + HTML, - InputRange::tag()->id('inputrange-')->tabIndex(1)->render(), + InputRange::tag()->id('inputrange')->tabIndex(1)->render(), "Failed asserting that element renders correctly with 'tabindex' attribute.", ); } @@ -508,9 +676,9 @@ public function testRenderWithThemeProvider(): void { self::assertSame( << + HTML, - InputRange::tag()->id('inputrange-')->addThemeProvider('muted', DefaultThemeProvider::class)->render(), + InputRange::tag()->id('inputrange')->addThemeProvider('muted', DefaultThemeProvider::class)->render(), "Failed asserting that element renders correctly with 'addThemeProvider()' method.", ); } @@ -519,18 +687,22 @@ public function testRenderWithTitle(): void { self::assertSame( << + HTML, - InputRange::tag()->id('inputrange-')->title('Select a range')->render(), + InputRange::tag()->id('inputrange')->title('Select a range')->render(), "Failed asserting that element renders correctly with 'title' attribute.", ); } public function testRenderWithToString(): void { - self::assertStringContainsString( - 'type="range"', - LineEndingNormalizer::normalize((string) InputRange::tag()), + self::assertSame( + << + HTML, + InputRange::tag() + ->id(null) + ->render(), "Failed asserting that '__toString()' method renders correctly.", ); } @@ -539,9 +711,9 @@ public function testRenderWithTranslate(): void { self::assertSame( << + HTML, - InputRange::tag()->id('inputrange-')->translate(false)->render(), + InputRange::tag()->id('inputrange')->translate(false)->render(), "Failed asserting that element renders correctly with 'translate' attribute.", ); } @@ -550,9 +722,9 @@ public function testRenderWithTranslateUsingEnum(): void { self::assertSame( << + HTML, - InputRange::tag()->id('inputrange-')->translate(Translate::NO)->render(), + InputRange::tag()->id('inputrange')->translate(Translate::NO)->render(), "Failed asserting that element renders correctly with 'translate' attribute using enum.", ); } @@ -573,9 +745,9 @@ public function testRenderWithValue(): void { self::assertSame( << + HTML, - InputRange::tag()->id('inputrange-')->value(50)->render(), + InputRange::tag()->id('inputrange')->value(50)->render(), "Failed asserting that element renders correctly with 'value' attribute.", ); } diff --git a/tests/Form/InputResetTest.php b/tests/Form/InputResetTest.php index b8cb0f0..06ccffb 100644 --- a/tests/Form/InputResetTest.php +++ b/tests/Form/InputResetTest.php @@ -4,12 +4,12 @@ namespace UIAwesome\Html\Tests\Form; -use PHPForge\Support\LineEndingNormalizer; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use UIAwesome\Html\Attribute\Values\{Aria, Data, Direction, GlobalAttribute, Language, Role, Translate}; use UIAwesome\Html\Core\Factory\SimpleFactory; use UIAwesome\Html\Form\InputReset; +use UIAwesome\Html\Interop\Inline; use UIAwesome\Html\Tests\Support\Stub\{DefaultProvider, DefaultThemeProvider}; /** @@ -27,7 +27,6 @@ * @copyright Copyright (C) 2026 Terabytesoftw. * @license https://opensource.org/license/bsd-3-clause BSD 3-Clause License. */ -#[Group('html')] #[Group('form')] final class InputResetTest extends TestCase { @@ -44,9 +43,9 @@ public function testRenderWithAccesskey(): void { self::assertSame( << + HTML, - InputReset::tag()->id('inputreset-')->accesskey('k')->render(), + InputReset::tag()->id('inputreset')->accesskey('k')->render(), "Failed asserting that element renders correctly with 'accesskey' attribute.", ); } @@ -55,9 +54,9 @@ public function testRenderWithAddAriaAttribute(): void { self::assertSame( << + HTML, - InputReset::tag()->id('inputreset-')->addAriaAttribute('label', 'Reset form')->render(), + InputReset::tag()->id('inputreset')->addAriaAttribute('label', 'Reset form')->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method.", ); } @@ -66,20 +65,121 @@ public function testRenderWithAddAriaAttributeUsingEnum(): void { self::assertSame( << + HTML, - InputReset::tag()->id('inputreset-')->addAriaAttribute(Aria::HIDDEN, true)->render(), + InputReset::tag()->id('inputreset')->addAriaAttribute(Aria::HIDDEN, true)->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method using enum.", ); } + public function testRenderWithAddAriaDescribedByString(): void + { + self::assertSame( + << + HTML, + InputReset::tag() + ->addAriaAttribute('describedby', 'custom-help') + ->id('inputreset') + ->render(), + "Failed asserting that an explicit 'aria-describedby' string value is preserved.", + ); + } + + public function testRenderWithAddAriaDescribedByTrueBooleanValue(): void + { + self::assertSame( + << + HTML, + InputReset::tag() + ->addAriaAttribute('describedby', true) + ->id('inputreset') + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to " + . "'true'.", + ); + } + + public function testRenderWithAddAriaDescribedByTrueBooleanValueAndIdNull(): void + { + self::assertSame( + << + HTML, + InputReset::tag() + ->addAriaAttribute('describedby', true) + ->id(null) + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to " + . "'true' and 'id' is 'null'.", + ); + } + + public function testRenderWithAddAriaDescribedByTrueBooleanValueAndPrefixSuffix(): void + { + self::assertSame( + <<Prefix + + Suffix + HTML, + InputReset::tag() + ->addAriaAttribute('describedby', true) + ->id('inputreset') + ->prefix('Prefix') + ->prefixTag(Inline::SPAN) + ->suffix('Suffix') + ->suffixTag(Inline::SPAN) + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to " + . "'true' and prefix/suffix.", + ); + } + + public function testRenderWithAddAriaDescribedByTrueBooleanValueString(): void + { + self::assertSame( + << + HTML, + InputReset::tag() + ->addAriaAttribute('describedby', 'true') + ->id('inputreset') + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to " + . "'true'.", + ); + } + + public function testRenderWithAddAriaDescribedByTrueStringValueAndPrefixSuffix(): void + { + self::assertSame( + <<Prefix + + Suffix + HTML, + InputReset::tag() + ->addAriaAttribute('describedby', 'true') + ->id('inputreset') + ->prefix('Prefix') + ->prefixTag(Inline::SPAN) + ->suffix('Suffix') + ->suffixTag(Inline::SPAN) + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to " + . "'true' and prefix/suffix.", + ); + } + public function testRenderWithAddAttribute(): void { self::assertSame( << + HTML, - InputReset::tag()->id('inputreset-')->addAttribute('data-test', 'value')->render(), + InputReset::tag()->id('inputreset')->addAttribute('data-test', 'value')->render(), "Failed asserting that element renders correctly with 'addAttribute()' method.", ); } @@ -88,9 +188,9 @@ public function testRenderWithAddAttributeUsingEnum(): void { self::assertSame( << + HTML, - InputReset::tag()->id('inputreset-')->addAttribute(GlobalAttribute::TITLE, 'Reset form')->render(), + InputReset::tag()->id('inputreset')->addAttribute(GlobalAttribute::TITLE, 'Reset form')->render(), "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", ); } @@ -99,9 +199,9 @@ public function testRenderWithAddDataAttribute(): void { self::assertSame( << + HTML, - InputReset::tag()->id('inputreset-')->addDataAttribute('reset', 'value')->render(), + InputReset::tag()->id('inputreset')->addDataAttribute('reset', 'value')->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method.", ); } @@ -110,9 +210,9 @@ public function testRenderWithAddDataAttributeUsingEnum(): void { self::assertSame( << + HTML, - InputReset::tag()->id('inputreset-')->addDataAttribute(Data::VALUE, 'test')->render(), + InputReset::tag()->id('inputreset')->addDataAttribute(Data::VALUE, 'test')->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method using enum.", ); } @@ -121,10 +221,10 @@ public function testRenderWithAriaAttributes(): void { self::assertSame( << + HTML, InputReset::tag() - ->id('inputreset-') + ->id('inputreset') ->ariaAttributes([ 'controls' => 'form-id', 'label' => 'Reset form', @@ -134,24 +234,80 @@ public function testRenderWithAriaAttributes(): void ); } + public function testRenderWithAriaAttributesAndAriaDescribedByTrueBooleanValue(): void + { + self::assertSame( + << + HTML, + InputReset::tag() + ->ariaAttributes(['describedby' => true]) + ->id('inputreset') + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to true.", + ); + } + + public function testRenderWithAriaAttributesAndAriaDescribedByTrueStringValue(): void + { + self::assertSame( + << + HTML, + InputReset::tag() + ->ariaAttributes(['describedby' => 'true']) + ->id('inputreset') + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to true.", + ); + } + public function testRenderWithAttributes(): void { self::assertSame( << + HTML, - InputReset::tag()->id('inputreset-')->attributes(['class' => 'reset-input'])->render(), + InputReset::tag()->id('inputreset')->attributes(['class' => 'reset-input'])->render(), "Failed asserting that element renders correctly with 'attributes()' method.", ); } + public function testRenderWithAttributesAndAriaDescribedByTrueBooleanValue(): void + { + self::assertSame( + << + HTML, + InputReset::tag() + ->attributes(['aria-describedby' => true]) + ->id('inputreset') + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to true.", + ); + } + + public function testRenderWithAttributesAndAriaDescribedByTrueStringValue(): void + { + self::assertSame( + << + HTML, + InputReset::tag() + ->attributes(['aria-describedby' => 'true']) + ->id('inputreset') + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to true.", + ); + } + public function testRenderWithAutofocus(): void { self::assertSame( << + HTML, - InputReset::tag()->autofocus(true)->id('inputreset-')->render(), + InputReset::tag()->autofocus(true)->id('inputreset')->render(), "Failed asserting that element renders correctly with 'autofocus' attribute.", ); } @@ -160,9 +316,9 @@ public function testRenderWithClass(): void { self::assertSame( << + HTML, - InputReset::tag()->id('inputreset-')->class('reset-input')->render(), + InputReset::tag()->id('inputreset')->class('reset-input')->render(), "Failed asserting that element renders correctly with 'class' attribute.", ); } @@ -171,9 +327,9 @@ public function testRenderWithDataAttributes(): void { self::assertSame( << + HTML, - InputReset::tag()->id('inputreset-')->dataAttributes(['reset' => 'value'])->render(), + InputReset::tag()->id('inputreset')->dataAttributes(['reset' => 'value'])->render(), "Failed asserting that element renders correctly with 'dataAttributes()' method.", ); } @@ -182,9 +338,9 @@ public function testRenderWithDefaultConfigurationValues(): void { self::assertSame( << + HTML, - InputReset::tag(['class' => 'default-class'])->id('inputreset-')->render(), + InputReset::tag(['class' => 'default-class'])->id('inputreset')->render(), 'Failed asserting that default configuration values are applied correctly.', ); } @@ -193,9 +349,9 @@ public function testRenderWithDefaultProvider(): void { self::assertSame( << + HTML, - InputReset::tag()->id('inputreset-')->addDefaultProvider(DefaultProvider::class)->render(), + InputReset::tag()->id('inputreset')->addDefaultProvider(DefaultProvider::class)->render(), 'Failed asserting that default provider is applied correctly.', ); } @@ -204,9 +360,9 @@ public function testRenderWithDefaultValues(): void { self::assertSame( << + HTML, - InputReset::tag()->id('inputreset-')->render(), + InputReset::tag()->id('inputreset')->render(), 'Failed asserting that element renders correctly with default values.', ); } @@ -215,9 +371,9 @@ public function testRenderWithDir(): void { self::assertSame( << + HTML, - InputReset::tag()->id('inputreset-')->dir('ltr')->render(), + InputReset::tag()->id('inputreset')->dir('ltr')->render(), "Failed asserting that element renders correctly with 'dir' attribute.", ); } @@ -226,9 +382,9 @@ public function testRenderWithDirUsingEnum(): void { self::assertSame( << + HTML, - InputReset::tag()->id('inputreset-')->dir(Direction::LTR)->render(), + InputReset::tag()->id('inputreset')->dir(Direction::LTR)->render(), "Failed asserting that element renders correctly with 'dir' attribute using enum.", ); } @@ -237,13 +393,25 @@ public function testRenderWithDisabled(): void { self::assertSame( << + HTML, - InputReset::tag()->id('inputreset-')->disabled(true)->render(), + InputReset::tag()->id('inputreset')->disabled(true)->render(), "Failed asserting that element renders correctly with 'disabled' attribute.", ); } + public function testRenderWithGenerateId(): void + { + /** @phpstan-var string $id */ + $id = InputReset::tag()->getAttribute('id', ''); + + self::assertMatchesRegularExpression( + '/^inputreset-\w+$/', + $id, + 'Failed asserting that element generates an ID when not provided.', + ); + } + public function testRenderWithGlobalDefaultsAreApplied(): void { SimpleFactory::setDefaults(InputReset::class, ['class' => 'default-class']); @@ -261,9 +429,9 @@ public function testRenderWithHidden(): void { self::assertSame( << + HTML, - InputReset::tag()->id('inputreset-')->hidden(true)->render(), + InputReset::tag()->id('inputreset')->hidden(true)->render(), "Failed asserting that element renders correctly with 'hidden' attribute.", ); } @@ -283,9 +451,9 @@ public function testRenderWithLang(): void { self::assertSame( << + HTML, - InputReset::tag()->id('inputreset-')->lang('en')->render(), + InputReset::tag()->id('inputreset')->lang('en')->render(), "Failed asserting that element renders correctly with 'lang' attribute.", ); } @@ -294,9 +462,9 @@ public function testRenderWithLangUsingEnum(): void { self::assertSame( << + HTML, - InputReset::tag()->id('inputreset-')->lang(Language::ENGLISH)->render(), + InputReset::tag()->id('inputreset')->lang(Language::ENGLISH)->render(), "Failed asserting that element renders correctly with 'lang' attribute using enum.", ); } @@ -305,9 +473,9 @@ public function testRenderWithName(): void { self::assertSame( << + HTML, - InputReset::tag()->id('inputreset-')->name('reset-form')->render(), + InputReset::tag()->id('inputreset')->name('reset-form')->render(), "Failed asserting that element renders correctly with 'name' attribute.", ); } @@ -316,10 +484,10 @@ public function testRenderWithRemoveAriaAttribute(): void { self::assertSame( << + HTML, InputReset::tag() - ->id('inputreset-') + ->id('inputreset') ->addAriaAttribute('label', 'Close') ->removeAriaAttribute('label') ->render(), @@ -331,10 +499,10 @@ public function testRenderWithRemoveAttribute(): void { self::assertSame( << + HTML, InputReset::tag() - ->id('inputreset-') + ->id('inputreset') ->addAttribute('data-test', 'value') ->removeAttribute('data-test') ->render(), @@ -346,10 +514,10 @@ public function testRenderWithRemoveDataAttribute(): void { self::assertSame( << + HTML, InputReset::tag() - ->id('inputreset-') + ->id('inputreset') ->addDataAttribute('value', 'test') ->removeDataAttribute('value') ->render(), @@ -361,9 +529,9 @@ public function testRenderWithRole(): void { self::assertSame( << + HTML, - InputReset::tag()->id('inputreset-')->role('button')->render(), + InputReset::tag()->id('inputreset')->role('button')->render(), "Failed asserting that element renders correctly with 'role' attribute.", ); } @@ -372,9 +540,9 @@ public function testRenderWithRoleUsingEnum(): void { self::assertSame( << + HTML, - InputReset::tag()->id('inputreset-')->role(Role::BUTTON)->render(), + InputReset::tag()->id('inputreset')->role(Role::BUTTON)->render(), "Failed asserting that element renders correctly with 'role' attribute using enum.", ); } @@ -383,9 +551,9 @@ public function testRenderWithStyle(): void { self::assertSame( << + HTML, - InputReset::tag()->id('inputreset-')->style('width: 200px;')->render(), + InputReset::tag()->id('inputreset')->style('width: 200px;')->render(), "Failed asserting that element renders correctly with 'style' attribute.", ); } @@ -394,9 +562,9 @@ public function testRenderWithTabindex(): void { self::assertSame( << + HTML, - InputReset::tag()->id('inputreset-')->tabIndex(1)->render(), + InputReset::tag()->id('inputreset')->tabIndex(1)->render(), "Failed asserting that element renders correctly with 'tabindex' attribute.", ); } @@ -405,9 +573,9 @@ public function testRenderWithThemeProvider(): void { self::assertSame( << + HTML, - InputReset::tag()->id('inputreset-')->addThemeProvider('muted', DefaultThemeProvider::class)->render(), + InputReset::tag()->id('inputreset')->addThemeProvider('muted', DefaultThemeProvider::class)->render(), "Failed asserting that element renders correctly with 'addThemeProvider()' method.", ); } @@ -416,18 +584,20 @@ public function testRenderWithTitle(): void { self::assertSame( << + HTML, - InputReset::tag()->id('inputreset-')->title('Reset form')->render(), + InputReset::tag()->id('inputreset')->title('Reset form')->render(), "Failed asserting that element renders correctly with 'title' attribute.", ); } public function testRenderWithToString(): void { - self::assertStringContainsString( - 'type="reset"', - LineEndingNormalizer::normalize((string) InputReset::tag()), + self::assertSame( + << + HTML, + (string) InputReset::tag()->id(null), "Failed asserting that '__toString()' method renders correctly.", ); } @@ -436,9 +606,9 @@ public function testRenderWithTranslate(): void { self::assertSame( << + HTML, - InputReset::tag()->id('inputreset-')->translate(false)->render(), + InputReset::tag()->id('inputreset')->translate(false)->render(), "Failed asserting that element renders correctly with 'translate' attribute.", ); } @@ -447,9 +617,9 @@ public function testRenderWithTranslateUsingEnum(): void { self::assertSame( << + HTML, - InputReset::tag()->id('inputreset-')->translate(Translate::NO)->render(), + InputReset::tag()->id('inputreset')->translate(Translate::NO)->render(), "Failed asserting that element renders correctly with 'translate' attribute using enum.", ); } @@ -470,9 +640,9 @@ public function testRenderWithValue(): void { self::assertSame( << + HTML, - InputReset::tag()->id('inputreset-')->value('Reset')->render(), + InputReset::tag()->id('inputreset')->value('Reset')->render(), "Failed asserting that element renders correctly with 'value' attribute.", ); } diff --git a/tests/Form/InputSearchTest.php b/tests/Form/InputSearchTest.php index d122799..5f260d6 100644 --- a/tests/Form/InputSearchTest.php +++ b/tests/Form/InputSearchTest.php @@ -4,12 +4,12 @@ namespace UIAwesome\Html\Tests\Form; -use PHPForge\Support\LineEndingNormalizer; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use UIAwesome\Html\Attribute\Values\{Aria, Autocomplete, Data, Direction, GlobalAttribute, Language, Role, Translate}; use UIAwesome\Html\Core\Factory\SimpleFactory; use UIAwesome\Html\Form\InputSearch; +use UIAwesome\Html\Interop\Inline; use UIAwesome\Html\Tests\Support\Stub\{DefaultProvider, DefaultThemeProvider}; /** @@ -28,7 +28,6 @@ * @copyright Copyright (C) 2026 Terabytesoftw. * @license https://opensource.org/license/bsd-3-clause BSD 3-Clause License. */ -#[Group('html')] #[Group('form')] final class InputSearchTest extends TestCase { @@ -45,9 +44,9 @@ public function testRenderWithAccesskey(): void { self::assertSame( << + HTML, - InputSearch::tag()->id('inputsearch-')->accesskey('k')->render(), + InputSearch::tag()->id('inputsearch')->accesskey('k')->render(), "Failed asserting that element renders correctly with 'accesskey' attribute.", ); } @@ -56,9 +55,9 @@ public function testRenderWithAddAriaAttribute(): void { self::assertSame( << + HTML, - InputSearch::tag()->id('inputsearch-')->addAriaAttribute('label', 'Search')->render(), + InputSearch::tag()->id('inputsearch')->addAriaAttribute('label', 'Search')->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method.", ); } @@ -67,20 +66,121 @@ public function testRenderWithAddAriaAttributeUsingEnum(): void { self::assertSame( << + HTML, - InputSearch::tag()->id('inputsearch-')->addAriaAttribute(Aria::HIDDEN, true)->render(), + InputSearch::tag()->id('inputsearch')->addAriaAttribute(Aria::HIDDEN, true)->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method using enum.", ); } + public function testRenderWithAddAriaDescribedByString(): void + { + self::assertSame( + << + HTML, + InputSearch::tag() + ->addAriaAttribute('describedby', 'custom-help') + ->id('inputsearch') + ->render(), + "Failed asserting that an explicit 'aria-describedby' string value is preserved.", + ); + } + + public function testRenderWithAddAriaDescribedByTrueBooleanValue(): void + { + self::assertSame( + << + HTML, + InputSearch::tag() + ->addAriaAttribute('describedby', true) + ->id('inputsearch') + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to " + . "'true'.", + ); + } + + public function testRenderWithAddAriaDescribedByTrueBooleanValueAndIdNull(): void + { + self::assertSame( + << + HTML, + InputSearch::tag() + ->addAriaAttribute('describedby', true) + ->id(null) + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to " + . "'true' and 'id' is 'null'.", + ); + } + + public function testRenderWithAddAriaDescribedByTrueBooleanValueAndPrefixSuffix(): void + { + self::assertSame( + <<Prefix + + Suffix + HTML, + InputSearch::tag() + ->addAriaAttribute('describedby', true) + ->id('inputsearch') + ->prefix('Prefix') + ->prefixTag(Inline::SPAN) + ->suffix('Suffix') + ->suffixTag(Inline::SPAN) + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to " + . "'true' and prefix/suffix.", + ); + } + + public function testRenderWithAddAriaDescribedByTrueBooleanValueString(): void + { + self::assertSame( + << + HTML, + InputSearch::tag() + ->addAriaAttribute('describedby', 'true') + ->id('inputsearch') + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to " + . "'true'.", + ); + } + + public function testRenderWithAddAriaDescribedByTrueStringValueAndPrefixSuffix(): void + { + self::assertSame( + <<Prefix + + Suffix + HTML, + InputSearch::tag() + ->addAriaAttribute('describedby', 'true') + ->id('inputsearch') + ->prefix('Prefix') + ->prefixTag(Inline::SPAN) + ->suffix('Suffix') + ->suffixTag(Inline::SPAN) + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to " + . "'true' and prefix/suffix.", + ); + } + public function testRenderWithAddAttribute(): void { self::assertSame( << + HTML, - InputSearch::tag()->id('inputsearch-')->addAttribute('data-test', 'value')->render(), + InputSearch::tag()->id('inputsearch')->addAttribute('data-test', 'value')->render(), "Failed asserting that element renders correctly with 'addAttribute()' method.", ); } @@ -89,9 +189,9 @@ public function testRenderWithAddAttributeUsingEnum(): void { self::assertSame( << + HTML, - InputSearch::tag()->id('inputsearch-')->addAttribute(GlobalAttribute::TITLE, 'Search here')->render(), + InputSearch::tag()->id('inputsearch')->addAttribute(GlobalAttribute::TITLE, 'Search here')->render(), "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", ); } @@ -100,9 +200,9 @@ public function testRenderWithAddDataAttribute(): void { self::assertSame( << + HTML, - InputSearch::tag()->id('inputsearch-')->addDataAttribute('search', 'value')->render(), + InputSearch::tag()->id('inputsearch')->addDataAttribute('search', 'value')->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method.", ); } @@ -111,9 +211,9 @@ public function testRenderWithAddDataAttributeUsingEnum(): void { self::assertSame( << + HTML, - InputSearch::tag()->id('inputsearch-')->addDataAttribute(Data::VALUE, 'test')->render(), + InputSearch::tag()->id('inputsearch')->addDataAttribute(Data::VALUE, 'test')->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method using enum.", ); } @@ -122,10 +222,10 @@ public function testRenderWithAriaAttributes(): void { self::assertSame( << + HTML, InputSearch::tag() - ->id('inputsearch-') + ->id('inputsearch') ->ariaAttributes([ 'controls' => 'search-results', 'label' => 'Search', @@ -135,24 +235,80 @@ public function testRenderWithAriaAttributes(): void ); } + public function testRenderWithAriaAttributesAndAriaDescribedByTrueBooleanValue(): void + { + self::assertSame( + << + HTML, + InputSearch::tag() + ->ariaAttributes(['describedby' => true]) + ->id('inputsearch') + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to true.", + ); + } + + public function testRenderWithAriaAttributesAndAriaDescribedByTrueStringValue(): void + { + self::assertSame( + << + HTML, + InputSearch::tag() + ->ariaAttributes(['describedby' => 'true']) + ->id('inputsearch') + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to true.", + ); + } + public function testRenderWithAttributes(): void { self::assertSame( << + HTML, - InputSearch::tag()->id('inputsearch-')->attributes(['class' => 'search-input'])->render(), + InputSearch::tag()->id('inputsearch')->attributes(['class' => 'search-input'])->render(), "Failed asserting that element renders correctly with 'attributes()' method.", ); } + public function testRenderWithAttributesAndAriaDescribedByTrueBooleanValue(): void + { + self::assertSame( + << + HTML, + InputSearch::tag() + ->attributes(['aria-describedby' => true]) + ->id('inputsearch') + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to true.", + ); + } + + public function testRenderWithAttributesAndAriaDescribedByTrueStringValue(): void + { + self::assertSame( + << + HTML, + InputSearch::tag() + ->attributes(['aria-describedby' => 'true']) + ->id('inputsearch') + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to true.", + ); + } + public function testRenderWithAutocomplete(): void { self::assertSame( << + HTML, - InputSearch::tag()->autocomplete('on')->id('inputsearch-')->render(), + InputSearch::tag()->autocomplete('on')->id('inputsearch')->render(), "Failed asserting that element renders correctly with 'autocomplete' attribute.", ); } @@ -161,9 +317,9 @@ public function testRenderWithAutocompleteUsingEnum(): void { self::assertSame( << + HTML, - InputSearch::tag()->autocomplete(Autocomplete::ON)->id('inputsearch-')->render(), + InputSearch::tag()->autocomplete(Autocomplete::ON)->id('inputsearch')->render(), "Failed asserting that element renders correctly with 'autocomplete' attribute using enum.", ); } @@ -172,9 +328,9 @@ public function testRenderWithAutofocus(): void { self::assertSame( << + HTML, - InputSearch::tag()->autofocus(true)->id('inputsearch-')->render(), + InputSearch::tag()->autofocus(true)->id('inputsearch')->render(), "Failed asserting that element renders correctly with 'autofocus' attribute.", ); } @@ -183,9 +339,9 @@ public function testRenderWithClass(): void { self::assertSame( << + HTML, - InputSearch::tag()->id('inputsearch-')->class('search-input')->render(), + InputSearch::tag()->id('inputsearch')->class('search-input')->render(), "Failed asserting that element renders correctly with 'class' attribute.", ); } @@ -194,9 +350,9 @@ public function testRenderWithDataAttributes(): void { self::assertSame( << + HTML, - InputSearch::tag()->id('inputsearch-')->dataAttributes(['search' => 'value'])->render(), + InputSearch::tag()->id('inputsearch')->dataAttributes(['search' => 'value'])->render(), "Failed asserting that element renders correctly with 'dataAttributes()' method.", ); } @@ -205,9 +361,9 @@ public function testRenderWithDefaultConfigurationValues(): void { self::assertSame( << + HTML, - InputSearch::tag(['class' => 'default-class'])->id('inputsearch-')->render(), + InputSearch::tag(['class' => 'default-class'])->id('inputsearch')->render(), 'Failed asserting that default configuration values are applied correctly.', ); } @@ -216,9 +372,9 @@ public function testRenderWithDefaultProvider(): void { self::assertSame( << + HTML, - InputSearch::tag()->id('inputsearch-')->addDefaultProvider(DefaultProvider::class)->render(), + InputSearch::tag()->id('inputsearch')->addDefaultProvider(DefaultProvider::class)->render(), 'Failed asserting that default provider is applied correctly.', ); } @@ -227,9 +383,9 @@ public function testRenderWithDefaultValues(): void { self::assertSame( << + HTML, - InputSearch::tag()->id('inputsearch-')->render(), + InputSearch::tag()->id('inputsearch')->render(), 'Failed asserting that element renders correctly with default values.', ); } @@ -238,9 +394,9 @@ public function testRenderWithDir(): void { self::assertSame( << + HTML, - InputSearch::tag()->id('inputsearch-')->dir('ltr')->render(), + InputSearch::tag()->id('inputsearch')->dir('ltr')->render(), "Failed asserting that element renders correctly with 'dir' attribute.", ); } @@ -249,9 +405,9 @@ public function testRenderWithDirname(): void { self::assertSame( << + HTML, - InputSearch::tag()->dirname('search.dir')->id('inputsearch-')->render(), + InputSearch::tag()->dirname('search.dir')->id('inputsearch')->render(), "Failed asserting that element renders correctly with 'dirname' attribute.", ); } @@ -260,9 +416,9 @@ public function testRenderWithDirUsingEnum(): void { self::assertSame( << + HTML, - InputSearch::tag()->id('inputsearch-')->dir(Direction::LTR)->render(), + InputSearch::tag()->id('inputsearch')->dir(Direction::LTR)->render(), "Failed asserting that element renders correctly with 'dir' attribute using enum.", ); } @@ -271,9 +427,9 @@ public function testRenderWithDisabled(): void { self::assertSame( << + HTML, - InputSearch::tag()->id('inputsearch-')->disabled(true)->render(), + InputSearch::tag()->id('inputsearch')->disabled(true)->render(), "Failed asserting that element renders correctly with 'disabled' attribute.", ); } @@ -282,13 +438,25 @@ public function testRenderWithForm(): void { self::assertSame( << + HTML, - InputSearch::tag()->form('form-id')->id('inputsearch-')->render(), + InputSearch::tag()->form('form-id')->id('inputsearch')->render(), "Failed asserting that element renders correctly with 'form' attribute.", ); } + public function testRenderWithGenerateId(): void + { + /** @phpstan-var string $id */ + $id = InputSearch::tag()->getAttribute('id', ''); + + self::assertMatchesRegularExpression( + '/^inputsearch-\w+$/', + $id, + 'Failed asserting that element generates an ID when not provided.', + ); + } + public function testRenderWithGlobalDefaultsAreApplied(): void { SimpleFactory::setDefaults(InputSearch::class, ['class' => 'default-class']); @@ -306,9 +474,9 @@ public function testRenderWithHidden(): void { self::assertSame( << + HTML, - InputSearch::tag()->id('inputsearch-')->hidden(true)->render(), + InputSearch::tag()->id('inputsearch')->hidden(true)->render(), "Failed asserting that element renders correctly with 'hidden' attribute.", ); } @@ -328,9 +496,9 @@ public function testRenderWithLang(): void { self::assertSame( << + HTML, - InputSearch::tag()->id('inputsearch-')->lang('en')->render(), + InputSearch::tag()->id('inputsearch')->lang('en')->render(), "Failed asserting that element renders correctly with 'lang' attribute.", ); } @@ -339,9 +507,9 @@ public function testRenderWithLangUsingEnum(): void { self::assertSame( << + HTML, - InputSearch::tag()->id('inputsearch-')->lang(Language::ENGLISH)->render(), + InputSearch::tag()->id('inputsearch')->lang(Language::ENGLISH)->render(), "Failed asserting that element renders correctly with 'lang' attribute using enum.", ); } @@ -350,9 +518,9 @@ public function testRenderWithList(): void { self::assertSame( << + HTML, - InputSearch::tag()->id('inputsearch-')->list('search-list')->render(), + InputSearch::tag()->id('inputsearch')->list('search-list')->render(), "Failed asserting that element renders correctly with 'list' attribute.", ); } @@ -361,9 +529,9 @@ public function testRenderWithMaxlength(): void { self::assertSame( << + HTML, - InputSearch::tag()->id('inputsearch-')->maxlength(10)->render(), + InputSearch::tag()->id('inputsearch')->maxlength(10)->render(), "Failed asserting that element renders correctly with 'maxlength' attribute.", ); } @@ -372,9 +540,9 @@ public function testRenderWithMinlength(): void { self::assertSame( << + HTML, - InputSearch::tag()->id('inputsearch-')->minlength(3)->render(), + InputSearch::tag()->id('inputsearch')->minlength(3)->render(), "Failed asserting that element renders correctly with 'minlength' attribute.", ); } @@ -383,9 +551,9 @@ public function testRenderWithName(): void { self::assertSame( << + HTML, - InputSearch::tag()->id('inputsearch-')->name('search')->render(), + InputSearch::tag()->id('inputsearch')->name('search')->render(), "Failed asserting that element renders correctly with 'name' attribute.", ); } @@ -394,9 +562,9 @@ public function testRenderWithPattern(): void { self::assertSame( << + HTML, - InputSearch::tag()->id('inputsearch-')->pattern('search.*')->render(), + InputSearch::tag()->id('inputsearch')->pattern('search.*')->render(), "Failed asserting that element renders correctly with 'pattern' attribute.", ); } @@ -405,9 +573,9 @@ public function testRenderWithPlaceholder(): void { self::assertSame( << + HTML, - InputSearch::tag()->id('inputsearch-')->placeholder('Search...')->render(), + InputSearch::tag()->id('inputsearch')->placeholder('Search...')->render(), "Failed asserting that element renders correctly with 'placeholder' attribute.", ); } @@ -416,9 +584,9 @@ public function testRenderWithReadonly(): void { self::assertSame( << + HTML, - InputSearch::tag()->id('inputsearch-')->readonly(true)->render(), + InputSearch::tag()->id('inputsearch')->readonly(true)->render(), "Failed asserting that element renders correctly with 'readonly' attribute.", ); } @@ -427,10 +595,10 @@ public function testRenderWithRemoveAriaAttribute(): void { self::assertSame( << + HTML, InputSearch::tag() - ->id('inputsearch-') + ->id('inputsearch') ->addAriaAttribute('label', 'Close') ->removeAriaAttribute('label') ->render(), @@ -442,10 +610,10 @@ public function testRenderWithRemoveAttribute(): void { self::assertSame( << + HTML, InputSearch::tag() - ->id('inputsearch-') + ->id('inputsearch') ->addAttribute('data-test', 'value') ->removeAttribute('data-test') ->render(), @@ -457,10 +625,10 @@ public function testRenderWithRemoveDataAttribute(): void { self::assertSame( << + HTML, InputSearch::tag() - ->id('inputsearch-') + ->id('inputsearch') ->addDataAttribute('value', 'test') ->removeDataAttribute('value') ->render(), @@ -472,9 +640,9 @@ public function testRenderWithRequired(): void { self::assertSame( << + HTML, - InputSearch::tag()->id('inputsearch-')->required(true)->render(), + InputSearch::tag()->id('inputsearch')->required(true)->render(), "Failed asserting that element renders correctly with 'required' attribute.", ); } @@ -483,9 +651,9 @@ public function testRenderWithRole(): void { self::assertSame( << + HTML, - InputSearch::tag()->id('inputsearch-')->role('searchbox')->render(), + InputSearch::tag()->id('inputsearch')->role('searchbox')->render(), "Failed asserting that element renders correctly with 'role' attribute.", ); } @@ -494,9 +662,9 @@ public function testRenderWithRoleUsingEnum(): void { self::assertSame( << + HTML, - InputSearch::tag()->id('inputsearch-')->role(Role::SEARCHBOX)->render(), + InputSearch::tag()->id('inputsearch')->role(Role::SEARCHBOX)->render(), "Failed asserting that element renders correctly with 'role' attribute using enum.", ); } @@ -505,9 +673,9 @@ public function testRenderWithSize(): void { self::assertSame( << + HTML, - InputSearch::tag()->id('inputsearch-')->size(20)->render(), + InputSearch::tag()->id('inputsearch')->size(20)->render(), "Failed asserting that element renders correctly with 'size' attribute.", ); } @@ -516,9 +684,9 @@ public function testRenderWithSpellcheck(): void { self::assertSame( << + HTML, - InputSearch::tag()->id('inputsearch-')->spellcheck(true)->render(), + InputSearch::tag()->id('inputsearch')->spellcheck(true)->render(), "Failed asserting that element renders correctly with 'spellcheck' attribute.", ); } @@ -527,9 +695,9 @@ public function testRenderWithStyle(): void { self::assertSame( << + HTML, - InputSearch::tag()->id('inputsearch-')->style('width: 200px;')->render(), + InputSearch::tag()->id('inputsearch')->style('width: 200px;')->render(), "Failed asserting that element renders correctly with 'style' attribute.", ); } @@ -538,9 +706,9 @@ public function testRenderWithTabindex(): void { self::assertSame( << + HTML, - InputSearch::tag()->id('inputsearch-')->tabIndex(1)->render(), + InputSearch::tag()->id('inputsearch')->tabIndex(1)->render(), "Failed asserting that element renders correctly with 'tabindex' attribute.", ); } @@ -549,9 +717,9 @@ public function testRenderWithThemeProvider(): void { self::assertSame( << + HTML, - InputSearch::tag()->id('inputsearch-')->addThemeProvider('muted', DefaultThemeProvider::class)->render(), + InputSearch::tag()->id('inputsearch')->addThemeProvider('muted', DefaultThemeProvider::class)->render(), "Failed asserting that element renders correctly with 'addThemeProvider()' method.", ); } @@ -560,18 +728,22 @@ public function testRenderWithTitle(): void { self::assertSame( << + HTML, - InputSearch::tag()->id('inputsearch-')->title('Search here')->render(), + InputSearch::tag()->id('inputsearch')->title('Search here')->render(), "Failed asserting that element renders correctly with 'title' attribute.", ); } public function testRenderWithToString(): void { - self::assertStringContainsString( - 'type="search"', - LineEndingNormalizer::normalize((string) InputSearch::tag()), + self::assertSame( + << + HTML, + InputSearch::tag() + ->id(null) + ->render(), "Failed asserting that '__toString()' method renders correctly.", ); } @@ -580,9 +752,9 @@ public function testRenderWithTranslate(): void { self::assertSame( << + HTML, - InputSearch::tag()->id('inputsearch-')->translate(false)->render(), + InputSearch::tag()->id('inputsearch')->translate(false)->render(), "Failed asserting that element renders correctly with 'translate' attribute.", ); } @@ -591,9 +763,9 @@ public function testRenderWithTranslateUsingEnum(): void { self::assertSame( << + HTML, - InputSearch::tag()->id('inputsearch-')->translate(Translate::NO)->render(), + InputSearch::tag()->id('inputsearch')->translate(Translate::NO)->render(), "Failed asserting that element renders correctly with 'translate' attribute using enum.", ); } @@ -614,9 +786,9 @@ public function testRenderWithValue(): void { self::assertSame( << + HTML, - InputSearch::tag()->id('inputsearch-')->value('PHP')->render(), + InputSearch::tag()->id('inputsearch')->value('PHP')->render(), "Failed asserting that element renders correctly with 'value' attribute.", ); } diff --git a/tests/Form/InputSubmitTest.php b/tests/Form/InputSubmitTest.php index c356e0b..1cbcd0b 100644 --- a/tests/Form/InputSubmitTest.php +++ b/tests/Form/InputSubmitTest.php @@ -4,12 +4,12 @@ namespace UIAwesome\Html\Tests\Form; -use PHPForge\Support\LineEndingNormalizer; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use UIAwesome\Html\Attribute\Values\{Aria, Data, Direction, GlobalAttribute, Language, Role, Translate}; use UIAwesome\Html\Core\Factory\SimpleFactory; use UIAwesome\Html\Form\InputSubmit; +use UIAwesome\Html\Interop\Inline; use UIAwesome\Html\Tests\Support\Stub\{DefaultProvider, DefaultThemeProvider}; /** @@ -27,7 +27,6 @@ * @copyright Copyright (C) 2026 Terabytesoftw. * @license https://opensource.org/license/bsd-3-clause BSD 3-Clause License. */ -#[Group('html')] #[Group('form')] final class InputSubmitTest extends TestCase { @@ -44,9 +43,9 @@ public function testRenderWithAccesskey(): void { self::assertSame( << + HTML, - InputSubmit::tag()->id('inputsubmit-')->accesskey('k')->render(), + InputSubmit::tag()->id('inputsubmit')->accesskey('k')->render(), "Failed asserting that element renders correctly with 'accesskey' attribute.", ); } @@ -55,9 +54,9 @@ public function testRenderWithAddAriaAttribute(): void { self::assertSame( << + HTML, - InputSubmit::tag()->id('inputsubmit-')->addAriaAttribute('label', 'Submit form')->render(), + InputSubmit::tag()->id('inputsubmit')->addAriaAttribute('label', 'Submit form')->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method.", ); } @@ -66,20 +65,121 @@ public function testRenderWithAddAriaAttributeUsingEnum(): void { self::assertSame( << + HTML, - InputSubmit::tag()->id('inputsubmit-')->addAriaAttribute(Aria::HIDDEN, true)->render(), + InputSubmit::tag()->id('inputsubmit')->addAriaAttribute(Aria::HIDDEN, true)->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method using enum.", ); } + public function testRenderWithAddAriaDescribedByString(): void + { + self::assertSame( + << + HTML, + InputSubmit::tag() + ->addAriaAttribute('describedby', 'custom-help') + ->id('inputsubmit') + ->render(), + "Failed asserting that an explicit 'aria-describedby' string value is preserved.", + ); + } + + public function testRenderWithAddAriaDescribedByTrueBooleanValue(): void + { + self::assertSame( + << + HTML, + InputSubmit::tag() + ->addAriaAttribute('describedby', true) + ->id('inputsubmit') + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to " + . "'true'.", + ); + } + + public function testRenderWithAddAriaDescribedByTrueBooleanValueAndIdNull(): void + { + self::assertSame( + << + HTML, + InputSubmit::tag() + ->addAriaAttribute('describedby', true) + ->id(null) + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to " + . "'true' and 'id' is 'null'.", + ); + } + + public function testRenderWithAddAriaDescribedByTrueBooleanValueAndPrefixSuffix(): void + { + self::assertSame( + <<Prefix + + Suffix + HTML, + InputSubmit::tag() + ->addAriaAttribute('describedby', true) + ->id('inputsubmit') + ->prefix('Prefix') + ->prefixTag(Inline::SPAN) + ->suffix('Suffix') + ->suffixTag(Inline::SPAN) + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to " + . "'true' and prefix/suffix.", + ); + } + + public function testRenderWithAddAriaDescribedByTrueBooleanValueString(): void + { + self::assertSame( + << + HTML, + InputSubmit::tag() + ->addAriaAttribute('describedby', 'true') + ->id('inputsubmit') + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to " + . "'true'.", + ); + } + + public function testRenderWithAddAriaDescribedByTrueStringValueAndPrefixSuffix(): void + { + self::assertSame( + <<Prefix + + Suffix + HTML, + InputSubmit::tag() + ->addAriaAttribute('describedby', 'true') + ->id('inputsubmit') + ->prefix('Prefix') + ->prefixTag(Inline::SPAN) + ->suffix('Suffix') + ->suffixTag(Inline::SPAN) + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to " + . "'true' and prefix/suffix.", + ); + } + public function testRenderWithAddAttribute(): void { self::assertSame( << + HTML, - InputSubmit::tag()->id('inputsubmit-')->addAttribute('data-test', 'value')->render(), + InputSubmit::tag()->id('inputsubmit')->addAttribute('data-test', 'value')->render(), "Failed asserting that element renders correctly with 'addAttribute()' method.", ); } @@ -88,9 +188,9 @@ public function testRenderWithAddAttributeUsingEnum(): void { self::assertSame( << + HTML, - InputSubmit::tag()->id('inputsubmit-')->addAttribute(GlobalAttribute::TITLE, 'Submit action')->render(), + InputSubmit::tag()->id('inputsubmit')->addAttribute(GlobalAttribute::TITLE, 'Submit action')->render(), "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", ); } @@ -99,9 +199,9 @@ public function testRenderWithAddDataAttribute(): void { self::assertSame( << + HTML, - InputSubmit::tag()->id('inputsubmit-')->addDataAttribute('submit', 'value')->render(), + InputSubmit::tag()->id('inputsubmit')->addDataAttribute('submit', 'value')->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method.", ); } @@ -110,9 +210,9 @@ public function testRenderWithAddDataAttributeUsingEnum(): void { self::assertSame( << + HTML, - InputSubmit::tag()->id('inputsubmit-')->addDataAttribute(Data::VALUE, 'test')->render(), + InputSubmit::tag()->id('inputsubmit')->addDataAttribute(Data::VALUE, 'test')->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method using enum.", ); } @@ -121,10 +221,10 @@ public function testRenderWithAriaAttributes(): void { self::assertSame( << + HTML, InputSubmit::tag() - ->id('inputsubmit-') + ->id('inputsubmit') ->ariaAttributes([ 'controls' => 'submit-region', 'label' => 'Submit now', @@ -134,24 +234,80 @@ public function testRenderWithAriaAttributes(): void ); } + public function testRenderWithAriaAttributesAndAriaDescribedByTrueBooleanValue(): void + { + self::assertSame( + << + HTML, + InputSubmit::tag() + ->ariaAttributes(['describedby' => true]) + ->id('inputsubmit') + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to true.", + ); + } + + public function testRenderWithAriaAttributesAndAriaDescribedByTrueStringValue(): void + { + self::assertSame( + << + HTML, + InputSubmit::tag() + ->ariaAttributes(['describedby' => 'true']) + ->id('inputsubmit') + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to true.", + ); + } + public function testRenderWithAttributes(): void { self::assertSame( << + HTML, - InputSubmit::tag()->id('inputsubmit-')->attributes(['class' => 'submit-input'])->render(), + InputSubmit::tag()->id('inputsubmit')->attributes(['class' => 'submit-input'])->render(), "Failed asserting that element renders correctly with 'attributes()' method.", ); } + public function testRenderWithAttributesAndAriaDescribedByTrueBooleanValue(): void + { + self::assertSame( + << + HTML, + InputSubmit::tag() + ->attributes(['aria-describedby' => true]) + ->id('inputsubmit') + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to true.", + ); + } + + public function testRenderWithAttributesAndAriaDescribedByTrueStringValue(): void + { + self::assertSame( + << + HTML, + InputSubmit::tag() + ->attributes(['aria-describedby' => 'true']) + ->id('inputsubmit') + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to true.", + ); + } + public function testRenderWithAutofocus(): void { self::assertSame( << + HTML, - InputSubmit::tag()->autofocus(true)->id('inputsubmit-')->render(), + InputSubmit::tag()->autofocus(true)->id('inputsubmit')->render(), "Failed asserting that element renders correctly with 'autofocus' attribute.", ); } @@ -160,9 +316,9 @@ public function testRenderWithClass(): void { self::assertSame( << + HTML, - InputSubmit::tag()->id('inputsubmit-')->class('submit-input')->render(), + InputSubmit::tag()->id('inputsubmit')->class('submit-input')->render(), "Failed asserting that element renders correctly with 'class' attribute.", ); } @@ -171,9 +327,9 @@ public function testRenderWithDataAttributes(): void { self::assertSame( << + HTML, - InputSubmit::tag()->id('inputsubmit-')->dataAttributes(['submit' => 'value'])->render(), + InputSubmit::tag()->id('inputsubmit')->dataAttributes(['submit' => 'value'])->render(), "Failed asserting that element renders correctly with 'dataAttributes()' method.", ); } @@ -182,9 +338,9 @@ public function testRenderWithDefaultConfigurationValues(): void { self::assertSame( << + HTML, - InputSubmit::tag(['class' => 'default-class'])->id('inputsubmit-')->render(), + InputSubmit::tag(['class' => 'default-class'])->id('inputsubmit')->render(), 'Failed asserting that default configuration values are applied correctly.', ); } @@ -193,9 +349,9 @@ public function testRenderWithDefaultProvider(): void { self::assertSame( << + HTML, - InputSubmit::tag()->id('inputsubmit-')->addDefaultProvider(DefaultProvider::class)->render(), + InputSubmit::tag()->id('inputsubmit')->addDefaultProvider(DefaultProvider::class)->render(), 'Failed asserting that default provider is applied correctly.', ); } @@ -204,9 +360,9 @@ public function testRenderWithDefaultValues(): void { self::assertSame( << + HTML, - InputSubmit::tag()->id('inputsubmit-')->render(), + InputSubmit::tag()->id('inputsubmit')->render(), 'Failed asserting that element renders correctly with default values.', ); } @@ -215,9 +371,9 @@ public function testRenderWithDir(): void { self::assertSame( << + HTML, - InputSubmit::tag()->id('inputsubmit-')->dir('ltr')->render(), + InputSubmit::tag()->id('inputsubmit')->dir('ltr')->render(), "Failed asserting that element renders correctly with 'dir' attribute.", ); } @@ -226,9 +382,9 @@ public function testRenderWithDirUsingEnum(): void { self::assertSame( << + HTML, - InputSubmit::tag()->id('inputsubmit-')->dir(Direction::LTR)->render(), + InputSubmit::tag()->id('inputsubmit')->dir(Direction::LTR)->render(), "Failed asserting that element renders correctly with 'dir' attribute using enum.", ); } @@ -237,9 +393,9 @@ public function testRenderWithDisabled(): void { self::assertSame( << + HTML, - InputSubmit::tag()->id('inputsubmit-')->disabled(true)->render(), + InputSubmit::tag()->id('inputsubmit')->disabled(true)->render(), "Failed asserting that element renders correctly with 'disabled' attribute.", ); } @@ -248,9 +404,9 @@ public function testRenderWithForm(): void { self::assertSame( << + HTML, - InputSubmit::tag()->form('form-id')->id('inputsubmit-')->render(), + InputSubmit::tag()->form('form-id')->id('inputsubmit')->render(), "Failed asserting that element renders correctly with 'form' attribute.", ); } @@ -259,9 +415,9 @@ public function testRenderWithFormaction(): void { self::assertSame( << + HTML, - InputSubmit::tag()->id('inputsubmit-')->formaction('/submit-handler')->render(), + InputSubmit::tag()->id('inputsubmit')->formaction('/submit-handler')->render(), "Failed asserting that element renders correctly with 'formaction' attribute.", ); } @@ -270,9 +426,9 @@ public function testRenderWithFormenctype(): void { self::assertSame( << + HTML, - InputSubmit::tag()->id('inputsubmit-')->formenctype('multipart/form-data')->render(), + InputSubmit::tag()->id('inputsubmit')->formenctype('multipart/form-data')->render(), "Failed asserting that element renders correctly with 'formenctype' attribute.", ); } @@ -281,9 +437,9 @@ public function testRenderWithFormmethod(): void { self::assertSame( << + HTML, - InputSubmit::tag()->id('inputsubmit-')->formmethod('post')->render(), + InputSubmit::tag()->id('inputsubmit')->formmethod('post')->render(), "Failed asserting that element renders correctly with 'formmethod' attribute.", ); } @@ -292,9 +448,9 @@ public function testRenderWithFormnovalidate(): void { self::assertSame( << + HTML, - InputSubmit::tag()->id('inputsubmit-')->formnovalidate(true)->render(), + InputSubmit::tag()->id('inputsubmit')->formnovalidate(true)->render(), "Failed asserting that element renders correctly with 'formnovalidate' attribute.", ); } @@ -303,9 +459,9 @@ public function testRenderWithFormnovalidateValueFalse(): void { self::assertSame( << + HTML, - InputSubmit::tag()->id('inputsubmit-')->formnovalidate(false)->render(), + InputSubmit::tag()->id('inputsubmit')->formnovalidate(false)->render(), "Failed asserting that element renders correctly with 'formnovalidate' set to false.", ); } @@ -314,9 +470,9 @@ public function testRenderWithFormnovalidateValueNull(): void { self::assertSame( << + HTML, - InputSubmit::tag()->id('inputsubmit-')->formnovalidate(null)->render(), + InputSubmit::tag()->id('inputsubmit')->formnovalidate(null)->render(), "Failed asserting that element renders correctly with 'formnovalidate' set to null.", ); } @@ -325,13 +481,25 @@ public function testRenderWithFormtarget(): void { self::assertSame( << + HTML, - InputSubmit::tag()->id('inputsubmit-')->formtarget('_blank')->render(), + InputSubmit::tag()->id('inputsubmit')->formtarget('_blank')->render(), "Failed asserting that element renders correctly with 'formtarget' attribute.", ); } + public function testRenderWithGenerateId(): void + { + /** @phpstan-var string $id */ + $id = InputSubmit::tag()->getAttribute('id', ''); + + self::assertMatchesRegularExpression( + '/^inputsubmit-\w+$/', + $id, + 'Failed asserting that element generates an ID when not provided.', + ); + } + public function testRenderWithGlobalDefaultsAreApplied(): void { SimpleFactory::setDefaults(InputSubmit::class, ['class' => 'default-class']); @@ -349,9 +517,9 @@ public function testRenderWithHidden(): void { self::assertSame( << + HTML, - InputSubmit::tag()->id('inputsubmit-')->hidden(true)->render(), + InputSubmit::tag()->id('inputsubmit')->hidden(true)->render(), "Failed asserting that element renders correctly with 'hidden' attribute.", ); } @@ -371,9 +539,9 @@ public function testRenderWithLang(): void { self::assertSame( << + HTML, - InputSubmit::tag()->id('inputsubmit-')->lang('en')->render(), + InputSubmit::tag()->id('inputsubmit')->lang('en')->render(), "Failed asserting that element renders correctly with 'lang' attribute.", ); } @@ -382,9 +550,9 @@ public function testRenderWithLangUsingEnum(): void { self::assertSame( << + HTML, - InputSubmit::tag()->id('inputsubmit-')->lang(Language::ENGLISH)->render(), + InputSubmit::tag()->id('inputsubmit')->lang(Language::ENGLISH)->render(), "Failed asserting that element renders correctly with 'lang' attribute using enum.", ); } @@ -393,9 +561,9 @@ public function testRenderWithName(): void { self::assertSame( << + HTML, - InputSubmit::tag()->id('inputsubmit-')->name('save')->render(), + InputSubmit::tag()->id('inputsubmit')->name('save')->render(), "Failed asserting that element renders correctly with 'name' attribute.", ); } @@ -404,10 +572,10 @@ public function testRenderWithRemoveAriaAttribute(): void { self::assertSame( << + HTML, InputSubmit::tag() - ->id('inputsubmit-') + ->id('inputsubmit') ->addAriaAttribute('label', 'Close') ->removeAriaAttribute('label') ->render(), @@ -419,10 +587,10 @@ public function testRenderWithRemoveAttribute(): void { self::assertSame( << + HTML, InputSubmit::tag() - ->id('inputsubmit-') + ->id('inputsubmit') ->addAttribute('data-test', 'value') ->removeAttribute('data-test') ->render(), @@ -434,10 +602,10 @@ public function testRenderWithRemoveDataAttribute(): void { self::assertSame( << + HTML, InputSubmit::tag() - ->id('inputsubmit-') + ->id('inputsubmit') ->addDataAttribute('value', 'test') ->removeDataAttribute('value') ->render(), @@ -449,9 +617,9 @@ public function testRenderWithRole(): void { self::assertSame( << + HTML, - InputSubmit::tag()->id('inputsubmit-')->role('button')->render(), + InputSubmit::tag()->id('inputsubmit')->role('button')->render(), "Failed asserting that element renders correctly with 'role' attribute.", ); } @@ -460,9 +628,9 @@ public function testRenderWithRoleUsingEnum(): void { self::assertSame( << + HTML, - InputSubmit::tag()->id('inputsubmit-')->role(Role::BUTTON)->render(), + InputSubmit::tag()->id('inputsubmit')->role(Role::BUTTON)->render(), "Failed asserting that element renders correctly with 'role' attribute using enum.", ); } @@ -471,9 +639,9 @@ public function testRenderWithStyle(): void { self::assertSame( << + HTML, - InputSubmit::tag()->id('inputsubmit-')->style('width: 200px;')->render(), + InputSubmit::tag()->id('inputsubmit')->style('width: 200px;')->render(), "Failed asserting that element renders correctly with 'style' attribute.", ); } @@ -482,9 +650,9 @@ public function testRenderWithTabindex(): void { self::assertSame( << + HTML, - InputSubmit::tag()->id('inputsubmit-')->tabIndex(1)->render(), + InputSubmit::tag()->id('inputsubmit')->tabIndex(1)->render(), "Failed asserting that element renders correctly with 'tabindex' attribute.", ); } @@ -493,9 +661,9 @@ public function testRenderWithThemeProvider(): void { self::assertSame( << + HTML, - InputSubmit::tag()->id('inputsubmit-')->addThemeProvider('muted', DefaultThemeProvider::class)->render(), + InputSubmit::tag()->id('inputsubmit')->addThemeProvider('muted', DefaultThemeProvider::class)->render(), "Failed asserting that element renders correctly with 'addThemeProvider()' method.", ); } @@ -504,18 +672,22 @@ public function testRenderWithTitle(): void { self::assertSame( << + HTML, - InputSubmit::tag()->id('inputsubmit-')->title('Submit form')->render(), + InputSubmit::tag()->id('inputsubmit')->title('Submit form')->render(), "Failed asserting that element renders correctly with 'title' attribute.", ); } public function testRenderWithToString(): void { - self::assertStringContainsString( - 'type="submit"', - LineEndingNormalizer::normalize((string) InputSubmit::tag()), + self::assertSame( + << + HTML, + InputSubmit::tag() + ->id(null) + ->render(), "Failed asserting that '__toString()' method renders correctly.", ); } @@ -524,9 +696,9 @@ public function testRenderWithTranslate(): void { self::assertSame( << + HTML, - InputSubmit::tag()->id('inputsubmit-')->translate(false)->render(), + InputSubmit::tag()->id('inputsubmit')->translate(false)->render(), "Failed asserting that element renders correctly with 'translate' attribute.", ); } @@ -535,9 +707,9 @@ public function testRenderWithTranslateUsingEnum(): void { self::assertSame( << + HTML, - InputSubmit::tag()->id('inputsubmit-')->translate(Translate::NO)->render(), + InputSubmit::tag()->id('inputsubmit')->translate(Translate::NO)->render(), "Failed asserting that element renders correctly with 'translate' attribute using enum.", ); } @@ -558,9 +730,9 @@ public function testRenderWithValue(): void { self::assertSame( << + HTML, - InputSubmit::tag()->id('inputsubmit-')->value('Save')->render(), + InputSubmit::tag()->id('inputsubmit')->value('Save')->render(), "Failed asserting that element renders correctly with 'value' attribute.", ); } diff --git a/tests/Form/InputTelTest.php b/tests/Form/InputTelTest.php index 447004d..2c6ea56 100644 --- a/tests/Form/InputTelTest.php +++ b/tests/Form/InputTelTest.php @@ -4,12 +4,12 @@ namespace UIAwesome\Html\Tests\Form; -use PHPForge\Support\LineEndingNormalizer; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use UIAwesome\Html\Attribute\Values\{Aria, Autocomplete, Data, Direction, GlobalAttribute, Language, Role, Translate}; use UIAwesome\Html\Core\Factory\SimpleFactory; use UIAwesome\Html\Form\InputTel; +use UIAwesome\Html\Interop\Inline; use UIAwesome\Html\Tests\Support\Stub\{DefaultProvider, DefaultThemeProvider}; /** @@ -29,7 +29,6 @@ * @copyright Copyright (C) 2026 Terabytesoftw. * @license https://opensource.org/license/bsd-3-clause BSD 3-Clause License. */ -#[Group('html')] #[Group('form')] final class InputTelTest extends TestCase { @@ -46,9 +45,9 @@ public function testRenderWithAccesskey(): void { self::assertSame( << + HTML, - InputTel::tag()->id('inputtel-')->accesskey('k')->render(), + InputTel::tag()->id('inputtel')->accesskey('k')->render(), "Failed asserting that element renders correctly with 'accesskey' attribute.", ); } @@ -57,9 +56,9 @@ public function testRenderWithAddAriaAttribute(): void { self::assertSame( << + HTML, - InputTel::tag()->id('inputtel-')->addAriaAttribute('label', 'Phone selector')->render(), + InputTel::tag()->id('inputtel')->addAriaAttribute('label', 'Phone selector')->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method.", ); } @@ -68,20 +67,121 @@ public function testRenderWithAddAriaAttributeUsingEnum(): void { self::assertSame( << + HTML, - InputTel::tag()->id('inputtel-')->addAriaAttribute(Aria::HIDDEN, true)->render(), + InputTel::tag()->id('inputtel')->addAriaAttribute(Aria::HIDDEN, true)->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method using enum.", ); } + public function testRenderWithAddAriaDescribedByString(): void + { + self::assertSame( + << + HTML, + InputTel::tag() + ->addAriaAttribute('describedby', 'custom-help') + ->id('inputtel') + ->render(), + "Failed asserting that an explicit 'aria-describedby' string value is preserved.", + ); + } + + public function testRenderWithAddAriaDescribedByTrueBooleanValue(): void + { + self::assertSame( + << + HTML, + InputTel::tag() + ->addAriaAttribute('describedby', true) + ->id('inputtel') + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to " + . "'true'.", + ); + } + + public function testRenderWithAddAriaDescribedByTrueBooleanValueAndIdNull(): void + { + self::assertSame( + << + HTML, + InputTel::tag() + ->addAriaAttribute('describedby', true) + ->id(null) + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to " + . "'true' and 'id' is 'null'.", + ); + } + + public function testRenderWithAddAriaDescribedByTrueBooleanValueAndPrefixSuffix(): void + { + self::assertSame( + <<Prefix + + Suffix + HTML, + InputTel::tag() + ->addAriaAttribute('describedby', true) + ->id('inputtel') + ->prefix('Prefix') + ->prefixTag(Inline::SPAN) + ->suffix('Suffix') + ->suffixTag(Inline::SPAN) + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to " + . "'true' and prefix/suffix.", + ); + } + + public function testRenderWithAddAriaDescribedByTrueBooleanValueString(): void + { + self::assertSame( + << + HTML, + InputTel::tag() + ->addAriaAttribute('describedby', 'true') + ->id('inputtel') + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to " + . "'true'.", + ); + } + + public function testRenderWithAddAriaDescribedByTrueStringValueAndPrefixSuffix(): void + { + self::assertSame( + <<Prefix + + Suffix + HTML, + InputTel::tag() + ->addAriaAttribute('describedby', 'true') + ->id('inputtel') + ->prefix('Prefix') + ->prefixTag(Inline::SPAN) + ->suffix('Suffix') + ->suffixTag(Inline::SPAN) + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to " + . "'true' and prefix/suffix.", + ); + } + public function testRenderWithAddAttribute(): void { self::assertSame( << + HTML, - InputTel::tag()->id('inputtel-')->addAttribute('data-test', 'value')->render(), + InputTel::tag()->id('inputtel')->addAttribute('data-test', 'value')->render(), "Failed asserting that element renders correctly with 'addAttribute()' method.", ); } @@ -90,9 +190,9 @@ public function testRenderWithAddAttributeUsingEnum(): void { self::assertSame( << + HTML, - InputTel::tag()->id('inputtel-')->addAttribute(GlobalAttribute::TITLE, 'Select phone')->render(), + InputTel::tag()->id('inputtel')->addAttribute(GlobalAttribute::TITLE, 'Select phone')->render(), "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", ); } @@ -101,9 +201,9 @@ public function testRenderWithAddDataAttribute(): void { self::assertSame( << + HTML, - InputTel::tag()->id('inputtel-')->addDataAttribute('tel', 'value')->render(), + InputTel::tag()->id('inputtel')->addDataAttribute('tel', 'value')->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method.", ); } @@ -112,9 +212,9 @@ public function testRenderWithAddDataAttributeUsingEnum(): void { self::assertSame( << + HTML, - InputTel::tag()->id('inputtel-')->addDataAttribute(Data::VALUE, 'test')->render(), + InputTel::tag()->id('inputtel')->addDataAttribute(Data::VALUE, 'test')->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method using enum.", ); } @@ -123,10 +223,10 @@ public function testRenderWithAriaAttributes(): void { self::assertSame( << + HTML, InputTel::tag() - ->id('inputtel-') + ->id('inputtel') ->ariaAttributes([ 'controls' => 'phone-picker', 'label' => 'Select a phone', @@ -136,24 +236,80 @@ public function testRenderWithAriaAttributes(): void ); } + public function testRenderWithAriaAttributesAndAriaDescribedByTrueBooleanValue(): void + { + self::assertSame( + << + HTML, + InputTel::tag() + ->ariaAttributes(['describedby' => true]) + ->id('inputtel') + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to true.", + ); + } + + public function testRenderWithAriaAttributesAndAriaDescribedByTrueStringValue(): void + { + self::assertSame( + << + HTML, + InputTel::tag() + ->ariaAttributes(['describedby' => 'true']) + ->id('inputtel') + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to true.", + ); + } + public function testRenderWithAttributes(): void { self::assertSame( << + HTML, - InputTel::tag()->id('inputtel-')->attributes(['class' => 'tel-input'])->render(), + InputTel::tag()->id('inputtel')->attributes(['class' => 'tel-input'])->render(), "Failed asserting that element renders correctly with 'attributes()' method.", ); } + public function testRenderWithAttributesAndAriaDescribedByTrueBooleanValue(): void + { + self::assertSame( + << + HTML, + InputTel::tag() + ->attributes(['aria-describedby' => true]) + ->id('inputtel') + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to true.", + ); + } + + public function testRenderWithAttributesAndAriaDescribedByTrueStringValue(): void + { + self::assertSame( + << + HTML, + InputTel::tag() + ->attributes(['aria-describedby' => 'true']) + ->id('inputtel') + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to true.", + ); + } + public function testRenderWithAutocomplete(): void { self::assertSame( << + HTML, - InputTel::tag()->autocomplete('on')->id('inputtel-')->render(), + InputTel::tag()->autocomplete('on')->id('inputtel')->render(), "Failed asserting that element renders correctly with 'autocomplete' attribute.", ); } @@ -162,9 +318,9 @@ public function testRenderWithAutocompleteUsingEnum(): void { self::assertSame( << + HTML, - InputTel::tag()->autocomplete(Autocomplete::ON)->id('inputtel-')->render(), + InputTel::tag()->autocomplete(Autocomplete::ON)->id('inputtel')->render(), "Failed asserting that element renders correctly with 'autocomplete' attribute using enum.", ); } @@ -173,9 +329,9 @@ public function testRenderWithAutofocus(): void { self::assertSame( << + HTML, - InputTel::tag()->autofocus(true)->id('inputtel-')->render(), + InputTel::tag()->autofocus(true)->id('inputtel')->render(), "Failed asserting that element renders correctly with 'autofocus' attribute.", ); } @@ -184,9 +340,9 @@ public function testRenderWithClass(): void { self::assertSame( << + HTML, - InputTel::tag()->id('inputtel-')->class('tel-input')->render(), + InputTel::tag()->id('inputtel')->class('tel-input')->render(), "Failed asserting that element renders correctly with 'class' attribute.", ); } @@ -195,9 +351,9 @@ public function testRenderWithDataAttributes(): void { self::assertSame( << + HTML, - InputTel::tag()->id('inputtel-')->dataAttributes(['tel' => 'value'])->render(), + InputTel::tag()->id('inputtel')->dataAttributes(['tel' => 'value'])->render(), "Failed asserting that element renders correctly with 'dataAttributes()' method.", ); } @@ -206,9 +362,9 @@ public function testRenderWithDefaultConfigurationValues(): void { self::assertSame( << + HTML, - InputTel::tag(['class' => 'default-class'])->id('inputtel-')->render(), + InputTel::tag(['class' => 'default-class'])->id('inputtel')->render(), 'Failed asserting that default configuration values are applied correctly.', ); } @@ -217,9 +373,9 @@ public function testRenderWithDefaultProvider(): void { self::assertSame( << + HTML, - InputTel::tag()->id('inputtel-')->addDefaultProvider(DefaultProvider::class)->render(), + InputTel::tag()->id('inputtel')->addDefaultProvider(DefaultProvider::class)->render(), 'Failed asserting that default provider is applied correctly.', ); } @@ -228,9 +384,9 @@ public function testRenderWithDefaultValues(): void { self::assertSame( << + HTML, - InputTel::tag()->id('inputtel-')->render(), + InputTel::tag()->id('inputtel')->render(), 'Failed asserting that element renders correctly with default values.', ); } @@ -239,9 +395,9 @@ public function testRenderWithDir(): void { self::assertSame( << + HTML, - InputTel::tag()->id('inputtel-')->dir('ltr')->render(), + InputTel::tag()->id('inputtel')->dir('ltr')->render(), "Failed asserting that element renders correctly with 'dir' attribute.", ); } @@ -250,9 +406,9 @@ public function testRenderWithDirUsingEnum(): void { self::assertSame( << + HTML, - InputTel::tag()->id('inputtel-')->dir(Direction::LTR)->render(), + InputTel::tag()->id('inputtel')->dir(Direction::LTR)->render(), "Failed asserting that element renders correctly with 'dir' attribute using enum.", ); } @@ -261,9 +417,9 @@ public function testRenderWithDisabled(): void { self::assertSame( << + HTML, - InputTel::tag()->id('inputtel-')->disabled(true)->render(), + InputTel::tag()->id('inputtel')->disabled(true)->render(), "Failed asserting that element renders correctly with 'disabled' attribute.", ); } @@ -272,13 +428,25 @@ public function testRenderWithForm(): void { self::assertSame( << + HTML, - InputTel::tag()->form('form-id')->id('inputtel-')->render(), + InputTel::tag()->form('form-id')->id('inputtel')->render(), "Failed asserting that element renders correctly with 'form' attribute.", ); } + public function testRenderWithGenerateId(): void + { + /** @phpstan-var string $id */ + $id = InputTel::tag()->getAttribute('id', ''); + + self::assertMatchesRegularExpression( + '/^inputtel-\w+$/', + $id, + 'Failed asserting that element generates an ID when not provided.', + ); + } + public function testRenderWithGlobalDefaultsAreApplied(): void { SimpleFactory::setDefaults(InputTel::class, ['class' => 'default-class']); @@ -296,9 +464,9 @@ public function testRenderWithHidden(): void { self::assertSame( << + HTML, - InputTel::tag()->id('inputtel-')->hidden(true)->render(), + InputTel::tag()->id('inputtel')->hidden(true)->render(), "Failed asserting that element renders correctly with 'hidden' attribute.", ); } @@ -318,9 +486,9 @@ public function testRenderWithLang(): void { self::assertSame( << + HTML, - InputTel::tag()->id('inputtel-')->lang('en')->render(), + InputTel::tag()->id('inputtel')->lang('en')->render(), "Failed asserting that element renders correctly with 'lang' attribute.", ); } @@ -329,9 +497,9 @@ public function testRenderWithLangUsingEnum(): void { self::assertSame( << + HTML, - InputTel::tag()->id('inputtel-')->lang(Language::ENGLISH)->render(), + InputTel::tag()->id('inputtel')->lang(Language::ENGLISH)->render(), "Failed asserting that element renders correctly with 'lang' attribute using enum.", ); } @@ -340,9 +508,9 @@ public function testRenderWithList(): void { self::assertSame( << + HTML, - InputTel::tag()->id('inputtel-')->list('phones')->render(), + InputTel::tag()->id('inputtel')->list('phones')->render(), "Failed asserting that element renders correctly with 'list' attribute.", ); } @@ -351,9 +519,9 @@ public function testRenderWithMaxlength(): void { self::assertSame( << + HTML, - InputTel::tag()->id('inputtel-')->maxlength(10)->render(), + InputTel::tag()->id('inputtel')->maxlength(10)->render(), "Failed asserting that element renders correctly with 'maxlength' attribute.", ); } @@ -362,9 +530,9 @@ public function testRenderWithMinlength(): void { self::assertSame( << + HTML, - InputTel::tag()->id('inputtel-')->minlength(5)->render(), + InputTel::tag()->id('inputtel')->minlength(5)->render(), "Failed asserting that element renders correctly with 'minlength' attribute.", ); } @@ -373,9 +541,9 @@ public function testRenderWithName(): void { self::assertSame( << + HTML, - InputTel::tag()->id('inputtel-')->name('phone')->render(), + InputTel::tag()->id('inputtel')->name('phone')->render(), "Failed asserting that element renders correctly with 'name' attribute.", ); } @@ -384,9 +552,9 @@ public function testRenderWithPattern(): void { self::assertSame( << + HTML, - InputTel::tag()->id('inputtel-')->pattern('[0-9]{3}-[0-9]{3}-[0-9]{4}')->render(), + InputTel::tag()->id('inputtel')->pattern('[0-9]{3}-[0-9]{3}-[0-9]{4}')->render(), "Failed asserting that element renders correctly with 'pattern' attribute.", ); } @@ -395,9 +563,9 @@ public function testRenderWithPlaceholder(): void { self::assertSame( << + HTML, - InputTel::tag()->id('inputtel-')->placeholder('123-456-7890')->render(), + InputTel::tag()->id('inputtel')->placeholder('123-456-7890')->render(), "Failed asserting that element renders correctly with 'placeholder' attribute.", ); } @@ -406,9 +574,9 @@ public function testRenderWithReadonly(): void { self::assertSame( << + HTML, - InputTel::tag()->id('inputtel-')->readonly(true)->render(), + InputTel::tag()->id('inputtel')->readonly(true)->render(), "Failed asserting that element renders correctly with 'readonly' attribute.", ); } @@ -417,10 +585,10 @@ public function testRenderWithRemoveAriaAttribute(): void { self::assertSame( << + HTML, InputTel::tag() - ->id('inputtel-') + ->id('inputtel') ->addAriaAttribute('label', 'Close') ->removeAriaAttribute('label') ->render(), @@ -432,10 +600,10 @@ public function testRenderWithRemoveAttribute(): void { self::assertSame( << + HTML, InputTel::tag() - ->id('inputtel-') + ->id('inputtel') ->addAttribute('data-test', 'value') ->removeAttribute('data-test') ->render(), @@ -447,10 +615,10 @@ public function testRenderWithRemoveDataAttribute(): void { self::assertSame( << + HTML, InputTel::tag() - ->id('inputtel-') + ->id('inputtel') ->addDataAttribute('value', 'test') ->removeDataAttribute('value') ->render(), @@ -462,9 +630,9 @@ public function testRenderWithRequired(): void { self::assertSame( << + HTML, - InputTel::tag()->id('inputtel-')->required(true)->render(), + InputTel::tag()->id('inputtel')->required(true)->render(), "Failed asserting that element renders correctly with 'required' attribute.", ); } @@ -473,9 +641,9 @@ public function testRenderWithRole(): void { self::assertSame( << + HTML, - InputTel::tag()->id('inputtel-')->role('textbox')->render(), + InputTel::tag()->id('inputtel')->role('textbox')->render(), "Failed asserting that element renders correctly with 'role' attribute.", ); } @@ -484,9 +652,9 @@ public function testRenderWithRoleUsingEnum(): void { self::assertSame( << + HTML, - InputTel::tag()->id('inputtel-')->role(Role::TEXTBOX)->render(), + InputTel::tag()->id('inputtel')->role(Role::TEXTBOX)->render(), "Failed asserting that element renders correctly with 'role' attribute using enum.", ); } @@ -495,9 +663,9 @@ public function testRenderWithSize(): void { self::assertSame( << + HTML, - InputTel::tag()->id('inputtel-')->size(30)->render(), + InputTel::tag()->id('inputtel')->size(30)->render(), "Failed asserting that element renders correctly with 'size' attribute.", ); } @@ -506,9 +674,9 @@ public function testRenderWithSpellcheck(): void { self::assertSame( << + HTML, - InputTel::tag()->id('inputtel-')->spellcheck(true)->render(), + InputTel::tag()->id('inputtel')->spellcheck(true)->render(), "Failed asserting that element renders correctly with 'spellcheck' attribute.", ); } @@ -517,9 +685,9 @@ public function testRenderWithStyle(): void { self::assertSame( << + HTML, - InputTel::tag()->id('inputtel-')->style('width: 200px;')->render(), + InputTel::tag()->id('inputtel')->style('width: 200px;')->render(), "Failed asserting that element renders correctly with 'style' attribute.", ); } @@ -528,9 +696,9 @@ public function testRenderWithTabindex(): void { self::assertSame( << + HTML, - InputTel::tag()->id('inputtel-')->tabIndex(1)->render(), + InputTel::tag()->id('inputtel')->tabIndex(1)->render(), "Failed asserting that element renders correctly with 'tabindex' attribute.", ); } @@ -539,9 +707,9 @@ public function testRenderWithThemeProvider(): void { self::assertSame( << + HTML, - InputTel::tag()->id('inputtel-')->addThemeProvider('muted', DefaultThemeProvider::class)->render(), + InputTel::tag()->id('inputtel')->addThemeProvider('muted', DefaultThemeProvider::class)->render(), "Failed asserting that element renders correctly with 'addThemeProvider()' method.", ); } @@ -550,18 +718,22 @@ public function testRenderWithTitle(): void { self::assertSame( << + HTML, - InputTel::tag()->id('inputtel-')->title('Select a phone')->render(), + InputTel::tag()->id('inputtel')->title('Select a phone')->render(), "Failed asserting that element renders correctly with 'title' attribute.", ); } public function testRenderWithToString(): void { - self::assertStringContainsString( - 'type="tel"', - LineEndingNormalizer::normalize((string) InputTel::tag()), + self::assertSame( + << + HTML, + InputTel::tag() + ->id(null) + ->render(), "Failed asserting that '__toString()' method renders correctly.", ); } @@ -570,9 +742,9 @@ public function testRenderWithTranslate(): void { self::assertSame( << + HTML, - InputTel::tag()->id('inputtel-')->translate(false)->render(), + InputTel::tag()->id('inputtel')->translate(false)->render(), "Failed asserting that element renders correctly with 'translate' attribute.", ); } @@ -581,9 +753,9 @@ public function testRenderWithTranslateUsingEnum(): void { self::assertSame( << + HTML, - InputTel::tag()->id('inputtel-')->translate(Translate::NO)->render(), + InputTel::tag()->id('inputtel')->translate(Translate::NO)->render(), "Failed asserting that element renders correctly with 'translate' attribute using enum.", ); } @@ -604,9 +776,9 @@ public function testRenderWithValue(): void { self::assertSame( << + HTML, - InputTel::tag()->id('inputtel-')->value('123-456-7890')->render(), + InputTel::tag()->id('inputtel')->value('123-456-7890')->render(), "Failed asserting that element renders correctly with 'value' attribute.", ); } diff --git a/tests/Form/InputTextTest.php b/tests/Form/InputTextTest.php index b92ae63..fdc4c79 100644 --- a/tests/Form/InputTextTest.php +++ b/tests/Form/InputTextTest.php @@ -4,12 +4,12 @@ namespace UIAwesome\Html\Tests\Form; -use PHPForge\Support\LineEndingNormalizer; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use UIAwesome\Html\Attribute\Values\{Aria, Autocomplete, Data, Direction, GlobalAttribute, Language, Role, Translate}; use UIAwesome\Html\Core\Factory\SimpleFactory; use UIAwesome\Html\Form\InputText; +use UIAwesome\Html\Interop\Inline; use UIAwesome\Html\Tests\Support\Stub\{DefaultProvider, DefaultThemeProvider}; /** @@ -28,7 +28,6 @@ * @copyright Copyright (C) 2026 Terabytesoftw. * @license https://opensource.org/license/bsd-3-clause BSD 3-Clause License. */ -#[Group('html')] #[Group('form')] final class InputTextTest extends TestCase { @@ -45,9 +44,9 @@ public function testRenderWithAccesskey(): void { self::assertSame( << + HTML, - InputText::tag()->id('inputtext-')->accesskey('k')->render(), + InputText::tag()->id('inputtext')->accesskey('k')->render(), "Failed asserting that element renders correctly with 'accesskey' attribute.", ); } @@ -56,9 +55,9 @@ public function testRenderWithAddAriaAttribute(): void { self::assertSame( << + HTML, - InputText::tag()->id('inputtext-')->addAriaAttribute('label', 'Text input')->render(), + InputText::tag()->id('inputtext')->addAriaAttribute('label', 'Text input')->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method.", ); } @@ -67,20 +66,121 @@ public function testRenderWithAddAriaAttributeUsingEnum(): void { self::assertSame( << + HTML, - InputText::tag()->id('inputtext-')->addAriaAttribute(Aria::HIDDEN, true)->render(), + InputText::tag()->id('inputtext')->addAriaAttribute(Aria::HIDDEN, true)->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method using enum.", ); } + public function testRenderWithAddAriaDescribedByString(): void + { + self::assertSame( + << + HTML, + InputText::tag() + ->addAriaAttribute('describedby', 'custom-help') + ->id('inputtext') + ->render(), + "Failed asserting that an explicit 'aria-describedby' string value is preserved.", + ); + } + + public function testRenderWithAddAriaDescribedByTrueBooleanValue(): void + { + self::assertSame( + << + HTML, + InputText::tag() + ->addAriaAttribute('describedby', true) + ->id('inputtext') + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to " + . "'true'.", + ); + } + + public function testRenderWithAddAriaDescribedByTrueBooleanValueAndIdNull(): void + { + self::assertSame( + << + HTML, + InputText::tag() + ->addAriaAttribute('describedby', true) + ->id(null) + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to " + . "'true' and 'id' is 'null'.", + ); + } + + public function testRenderWithAddAriaDescribedByTrueBooleanValueAndPrefixSuffix(): void + { + self::assertSame( + <<Prefix + + Suffix + HTML, + InputText::tag() + ->addAriaAttribute('describedby', true) + ->id('inputtext') + ->prefix('Prefix') + ->prefixTag(Inline::SPAN) + ->suffix('Suffix') + ->suffixTag(Inline::SPAN) + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to " + . "'true' and prefix/suffix.", + ); + } + + public function testRenderWithAddAriaDescribedByTrueBooleanValueString(): void + { + self::assertSame( + << + HTML, + InputText::tag() + ->addAriaAttribute('describedby', 'true') + ->id('inputtext') + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to " + . "'true'.", + ); + } + + public function testRenderWithAddAriaDescribedByTrueStringValueAndPrefixSuffix(): void + { + self::assertSame( + <<Prefix + + Suffix + HTML, + InputText::tag() + ->addAriaAttribute('describedby', 'true') + ->id('inputtext') + ->prefix('Prefix') + ->prefixTag(Inline::SPAN) + ->suffix('Suffix') + ->suffixTag(Inline::SPAN) + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to " + . "'true' and prefix/suffix.", + ); + } + public function testRenderWithAddAttribute(): void { self::assertSame( << + HTML, - InputText::tag()->id('inputtext-')->addAttribute('data-test', 'value')->render(), + InputText::tag()->id('inputtext')->addAttribute('data-test', 'value')->render(), "Failed asserting that element renders correctly with 'addAttribute()' method.", ); } @@ -89,9 +189,9 @@ public function testRenderWithAddAttributeUsingEnum(): void { self::assertSame( << + HTML, - InputText::tag()->id('inputtext-')->addAttribute(GlobalAttribute::TITLE, 'Enter text')->render(), + InputText::tag()->id('inputtext')->addAttribute(GlobalAttribute::TITLE, 'Enter text')->render(), "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", ); } @@ -100,9 +200,9 @@ public function testRenderWithAddDataAttribute(): void { self::assertSame( << + HTML, - InputText::tag()->id('inputtext-')->addDataAttribute('text', 'value')->render(), + InputText::tag()->id('inputtext')->addDataAttribute('text', 'value')->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method.", ); } @@ -111,9 +211,9 @@ public function testRenderWithAddDataAttributeUsingEnum(): void { self::assertSame( << + HTML, - InputText::tag()->id('inputtext-')->addDataAttribute(Data::VALUE, 'test')->render(), + InputText::tag()->id('inputtext')->addDataAttribute(Data::VALUE, 'test')->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method using enum.", ); } @@ -122,10 +222,10 @@ public function testRenderWithAriaAttributes(): void { self::assertSame( << + HTML, InputText::tag() - ->id('inputtext-') + ->id('inputtext') ->ariaAttributes([ 'controls' => 'text-picker', 'label' => 'Enter text', @@ -135,24 +235,80 @@ public function testRenderWithAriaAttributes(): void ); } + public function testRenderWithAriaAttributesAndAriaDescribedByTrueBooleanValue(): void + { + self::assertSame( + << + HTML, + InputText::tag() + ->ariaAttributes(['describedby' => true]) + ->id('inputtext') + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to true.", + ); + } + + public function testRenderWithAriaAttributesAndAriaDescribedByTrueStringValue(): void + { + self::assertSame( + << + HTML, + InputText::tag() + ->ariaAttributes(['describedby' => 'true']) + ->id('inputtext') + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to true.", + ); + } + public function testRenderWithAttributes(): void { self::assertSame( << + HTML, - InputText::tag()->id('inputtext-')->attributes(['class' => 'text-input'])->render(), + InputText::tag()->id('inputtext')->attributes(['class' => 'text-input'])->render(), "Failed asserting that element renders correctly with 'attributes()' method.", ); } + public function testRenderWithAttributesAndAriaDescribedByTrueBooleanValue(): void + { + self::assertSame( + << + HTML, + InputText::tag() + ->attributes(['aria-describedby' => true]) + ->id('inputtext') + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to true.", + ); + } + + public function testRenderWithAttributesAndAriaDescribedByTrueStringValue(): void + { + self::assertSame( + << + HTML, + InputText::tag() + ->attributes(['aria-describedby' => 'true']) + ->id('inputtext') + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to true.", + ); + } + public function testRenderWithAutocomplete(): void { self::assertSame( << + HTML, - InputText::tag()->autocomplete('on')->id('inputtext-')->render(), + InputText::tag()->autocomplete('on')->id('inputtext')->render(), "Failed asserting that element renders correctly with 'autocomplete' attribute.", ); } @@ -161,9 +317,9 @@ public function testRenderWithAutocompleteUsingEnum(): void { self::assertSame( << + HTML, - InputText::tag()->autocomplete(Autocomplete::ON)->id('inputtext-')->render(), + InputText::tag()->autocomplete(Autocomplete::ON)->id('inputtext')->render(), "Failed asserting that element renders correctly with 'autocomplete' attribute using enum.", ); } @@ -172,9 +328,9 @@ public function testRenderWithAutofocus(): void { self::assertSame( << + HTML, - InputText::tag()->autofocus(true)->id('inputtext-')->render(), + InputText::tag()->autofocus(true)->id('inputtext')->render(), "Failed asserting that element renders correctly with 'autofocus' attribute.", ); } @@ -183,9 +339,9 @@ public function testRenderWithClass(): void { self::assertSame( << + HTML, - InputText::tag()->id('inputtext-')->class('text-input')->render(), + InputText::tag()->id('inputtext')->class('text-input')->render(), "Failed asserting that element renders correctly with 'class' attribute.", ); } @@ -194,9 +350,9 @@ public function testRenderWithDataAttributes(): void { self::assertSame( << + HTML, - InputText::tag()->id('inputtext-')->dataAttributes(['text' => 'value'])->render(), + InputText::tag()->id('inputtext')->dataAttributes(['text' => 'value'])->render(), "Failed asserting that element renders correctly with 'dataAttributes()' method.", ); } @@ -205,9 +361,9 @@ public function testRenderWithDefaultConfigurationValues(): void { self::assertSame( << + HTML, - InputText::tag(['class' => 'default-class'])->id('inputtext-')->render(), + InputText::tag(['class' => 'default-class'])->id('inputtext')->render(), 'Failed asserting that default configuration values are applied correctly.', ); } @@ -216,9 +372,9 @@ public function testRenderWithDefaultProvider(): void { self::assertSame( << + HTML, - InputText::tag()->id('inputtext-')->addDefaultProvider(DefaultProvider::class)->render(), + InputText::tag()->id('inputtext')->addDefaultProvider(DefaultProvider::class)->render(), 'Failed asserting that default provider is applied correctly.', ); } @@ -227,9 +383,9 @@ public function testRenderWithDefaultValues(): void { self::assertSame( << + HTML, - InputText::tag()->id('inputtext-')->render(), + InputText::tag()->id('inputtext')->render(), 'Failed asserting that element renders correctly with default values.', ); } @@ -238,9 +394,9 @@ public function testRenderWithDir(): void { self::assertSame( << + HTML, - InputText::tag()->id('inputtext-')->dir('ltr')->render(), + InputText::tag()->id('inputtext')->dir('ltr')->render(), "Failed asserting that element renders correctly with 'dir' attribute.", ); } @@ -249,9 +405,9 @@ public function testRenderWithDirname(): void { self::assertSame( << + HTML, - InputText::tag()->dirname('comment.dir')->id('inputtext-')->render(), + InputText::tag()->dirname('comment.dir')->id('inputtext')->render(), "Failed asserting that element renders correctly with 'dirname' attribute.", ); } @@ -260,9 +416,9 @@ public function testRenderWithDirUsingEnum(): void { self::assertSame( << + HTML, - InputText::tag()->id('inputtext-')->dir(Direction::LTR)->render(), + InputText::tag()->id('inputtext')->dir(Direction::LTR)->render(), "Failed asserting that element renders correctly with 'dir' attribute using enum.", ); } @@ -271,9 +427,9 @@ public function testRenderWithDisabled(): void { self::assertSame( << + HTML, - InputText::tag()->id('inputtext-')->disabled(true)->render(), + InputText::tag()->id('inputtext')->disabled(true)->render(), "Failed asserting that element renders correctly with 'disabled' attribute.", ); } @@ -282,13 +438,25 @@ public function testRenderWithForm(): void { self::assertSame( << + HTML, - InputText::tag()->form('form-id')->id('inputtext-')->render(), + InputText::tag()->form('form-id')->id('inputtext')->render(), "Failed asserting that element renders correctly with 'form' attribute.", ); } + public function testRenderWithGenerateId(): void + { + /** @phpstan-var string $id */ + $id = InputText::tag()->getAttribute('id', ''); + + self::assertMatchesRegularExpression( + '/^inputtext-\w+$/', + $id, + 'Failed asserting that element generates an ID when not provided.', + ); + } + public function testRenderWithGlobalDefaultsAreApplied(): void { SimpleFactory::setDefaults(InputText::class, ['class' => 'default-class']); @@ -306,9 +474,9 @@ public function testRenderWithHidden(): void { self::assertSame( << + HTML, - InputText::tag()->id('inputtext-')->hidden(true)->render(), + InputText::tag()->id('inputtext')->hidden(true)->render(), "Failed asserting that element renders correctly with 'hidden' attribute.", ); } @@ -328,9 +496,9 @@ public function testRenderWithLang(): void { self::assertSame( << + HTML, - InputText::tag()->id('inputtext-')->lang('en')->render(), + InputText::tag()->id('inputtext')->lang('en')->render(), "Failed asserting that element renders correctly with 'lang' attribute.", ); } @@ -339,9 +507,9 @@ public function testRenderWithLangUsingEnum(): void { self::assertSame( << + HTML, - InputText::tag()->id('inputtext-')->lang(Language::ENGLISH)->render(), + InputText::tag()->id('inputtext')->lang(Language::ENGLISH)->render(), "Failed asserting that element renders correctly with 'lang' attribute using enum.", ); } @@ -350,9 +518,9 @@ public function testRenderWithList(): void { self::assertSame( << + HTML, - InputText::tag()->id('inputtext-')->list('texts')->render(), + InputText::tag()->id('inputtext')->list('texts')->render(), "Failed asserting that element renders correctly with 'list' attribute.", ); } @@ -361,9 +529,9 @@ public function testRenderWithMaxlength(): void { self::assertSame( << + HTML, - InputText::tag()->id('inputtext-')->maxlength(10)->render(), + InputText::tag()->id('inputtext')->maxlength(10)->render(), "Failed asserting that element renders correctly with 'maxlength' attribute.", ); } @@ -372,9 +540,9 @@ public function testRenderWithMinlength(): void { self::assertSame( << + HTML, - InputText::tag()->id('inputtext-')->minlength(5)->render(), + InputText::tag()->id('inputtext')->minlength(5)->render(), "Failed asserting that element renders correctly with 'minlength' attribute.", ); } @@ -383,9 +551,9 @@ public function testRenderWithName(): void { self::assertSame( << + HTML, - InputText::tag()->id('inputtext-')->name('username')->render(), + InputText::tag()->id('inputtext')->name('username')->render(), "Failed asserting that element renders correctly with 'name' attribute.", ); } @@ -394,9 +562,9 @@ public function testRenderWithPattern(): void { self::assertSame( << + HTML, - InputText::tag()->id('inputtext-')->pattern('[A-Za-z]{3}')->render(), + InputText::tag()->id('inputtext')->pattern('[A-Za-z]{3}')->render(), "Failed asserting that element renders correctly with 'pattern' attribute.", ); } @@ -405,9 +573,9 @@ public function testRenderWithPlaceholder(): void { self::assertSame( << + HTML, - InputText::tag()->id('inputtext-')->placeholder('Enter text')->render(), + InputText::tag()->id('inputtext')->placeholder('Enter text')->render(), "Failed asserting that element renders correctly with 'placeholder' attribute.", ); } @@ -416,9 +584,9 @@ public function testRenderWithReadonly(): void { self::assertSame( << + HTML, - InputText::tag()->id('inputtext-')->readonly(true)->render(), + InputText::tag()->id('inputtext')->readonly(true)->render(), "Failed asserting that element renders correctly with 'readonly' attribute.", ); } @@ -427,10 +595,10 @@ public function testRenderWithRemoveAriaAttribute(): void { self::assertSame( << + HTML, InputText::tag() - ->id('inputtext-') + ->id('inputtext') ->addAriaAttribute('label', 'Close') ->removeAriaAttribute('label') ->render(), @@ -442,10 +610,10 @@ public function testRenderWithRemoveAttribute(): void { self::assertSame( << + HTML, InputText::tag() - ->id('inputtext-') + ->id('inputtext') ->addAttribute('data-test', 'value') ->removeAttribute('data-test') ->render(), @@ -457,10 +625,10 @@ public function testRenderWithRemoveDataAttribute(): void { self::assertSame( << + HTML, InputText::tag() - ->id('inputtext-') + ->id('inputtext') ->addDataAttribute('value', 'test') ->removeDataAttribute('value') ->render(), @@ -472,9 +640,9 @@ public function testRenderWithRequired(): void { self::assertSame( << + HTML, - InputText::tag()->id('inputtext-')->required(true)->render(), + InputText::tag()->id('inputtext')->required(true)->render(), "Failed asserting that element renders correctly with 'required' attribute.", ); } @@ -483,9 +651,9 @@ public function testRenderWithRole(): void { self::assertSame( << + HTML, - InputText::tag()->id('inputtext-')->role('textbox')->render(), + InputText::tag()->id('inputtext')->role('textbox')->render(), "Failed asserting that element renders correctly with 'role' attribute.", ); } @@ -494,9 +662,9 @@ public function testRenderWithRoleUsingEnum(): void { self::assertSame( << + HTML, - InputText::tag()->id('inputtext-')->role(Role::TEXTBOX)->render(), + InputText::tag()->id('inputtext')->role(Role::TEXTBOX)->render(), "Failed asserting that element renders correctly with 'role' attribute using enum.", ); } @@ -505,9 +673,9 @@ public function testRenderWithSize(): void { self::assertSame( << + HTML, - InputText::tag()->id('inputtext-')->size(20)->render(), + InputText::tag()->id('inputtext')->size(20)->render(), "Failed asserting that element renders correctly with 'size' attribute.", ); } @@ -516,9 +684,9 @@ public function testRenderWithSpellcheck(): void { self::assertSame( << + HTML, - InputText::tag()->id('inputtext-')->spellcheck(true)->render(), + InputText::tag()->id('inputtext')->spellcheck(true)->render(), "Failed asserting that element renders correctly with 'spellcheck' attribute.", ); } @@ -527,9 +695,9 @@ public function testRenderWithStyle(): void { self::assertSame( << + HTML, - InputText::tag()->id('inputtext-')->style('width: 200px;')->render(), + InputText::tag()->id('inputtext')->style('width: 200px;')->render(), "Failed asserting that element renders correctly with 'style' attribute.", ); } @@ -538,9 +706,9 @@ public function testRenderWithTabindex(): void { self::assertSame( << + HTML, - InputText::tag()->id('inputtext-')->tabIndex(1)->render(), + InputText::tag()->id('inputtext')->tabIndex(1)->render(), "Failed asserting that element renders correctly with 'tabindex' attribute.", ); } @@ -549,9 +717,9 @@ public function testRenderWithThemeProvider(): void { self::assertSame( << + HTML, - InputText::tag()->id('inputtext-')->addThemeProvider('muted', DefaultThemeProvider::class)->render(), + InputText::tag()->id('inputtext')->addThemeProvider('muted', DefaultThemeProvider::class)->render(), "Failed asserting that element renders correctly with 'addThemeProvider()' method.", ); } @@ -560,18 +728,22 @@ public function testRenderWithTitle(): void { self::assertSame( << + HTML, - InputText::tag()->id('inputtext-')->title('Enter text')->render(), + InputText::tag()->id('inputtext')->title('Enter text')->render(), "Failed asserting that element renders correctly with 'title' attribute.", ); } public function testRenderWithToString(): void { - self::assertStringContainsString( - 'type="text"', - LineEndingNormalizer::normalize((string) InputText::tag()), + self::assertSame( + << + HTML, + InputText::tag() + ->id(null) + ->render(), "Failed asserting that '__toString()' method renders correctly.", ); } @@ -580,9 +752,9 @@ public function testRenderWithTranslate(): void { self::assertSame( << + HTML, - InputText::tag()->id('inputtext-')->translate(false)->render(), + InputText::tag()->id('inputtext')->translate(false)->render(), "Failed asserting that element renders correctly with 'translate' attribute.", ); } @@ -591,9 +763,9 @@ public function testRenderWithTranslateUsingEnum(): void { self::assertSame( << + HTML, - InputText::tag()->id('inputtext-')->translate(Translate::NO)->render(), + InputText::tag()->id('inputtext')->translate(Translate::NO)->render(), "Failed asserting that element renders correctly with 'translate' attribute using enum.", ); } @@ -614,9 +786,9 @@ public function testRenderWithValue(): void { self::assertSame( << + HTML, - InputText::tag()->id('inputtext-')->value('test')->render(), + InputText::tag()->id('inputtext')->value('test')->render(), "Failed asserting that element renders correctly with 'value' attribute.", ); } diff --git a/tests/Form/InputTimeTest.php b/tests/Form/InputTimeTest.php index 2608ef6..47fa737 100644 --- a/tests/Form/InputTimeTest.php +++ b/tests/Form/InputTimeTest.php @@ -4,12 +4,12 @@ namespace UIAwesome\Html\Tests\Form; -use PHPForge\Support\LineEndingNormalizer; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use UIAwesome\Html\Attribute\Values\{Aria, Autocomplete, Data, Direction, GlobalAttribute, Language, Role, Translate}; use UIAwesome\Html\Core\Factory\SimpleFactory; use UIAwesome\Html\Form\InputTime; +use UIAwesome\Html\Interop\Inline; use UIAwesome\Html\Tests\Support\Stub\{DefaultProvider, DefaultThemeProvider}; /** @@ -27,7 +27,6 @@ * @copyright Copyright (C) 2026 Terabytesoftw. * @license https://opensource.org/license/bsd-3-clause BSD 3-Clause License. */ -#[Group('html')] #[Group('form')] final class InputTimeTest extends TestCase { @@ -44,9 +43,9 @@ public function testRenderWithAccesskey(): void { self::assertSame( << + HTML, - InputTime::tag()->id('inputtime-')->accesskey('k')->render(), + InputTime::tag()->id('inputtime')->accesskey('k')->render(), "Failed asserting that element renders correctly with 'accesskey' attribute.", ); } @@ -55,9 +54,9 @@ public function testRenderWithAddAriaAttribute(): void { self::assertSame( << + HTML, - InputTime::tag()->id('inputtime-')->addAriaAttribute('label', 'Time selector')->render(), + InputTime::tag()->id('inputtime')->addAriaAttribute('label', 'Time selector')->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method.", ); } @@ -66,20 +65,121 @@ public function testRenderWithAddAriaAttributeUsingEnum(): void { self::assertSame( << + HTML, - InputTime::tag()->id('inputtime-')->addAriaAttribute(Aria::HIDDEN, true)->render(), + InputTime::tag()->id('inputtime')->addAriaAttribute(Aria::HIDDEN, true)->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method using enum.", ); } + public function testRenderWithAddAriaDescribedByString(): void + { + self::assertSame( + << + HTML, + InputTime::tag() + ->addAriaAttribute('describedby', 'custom-help') + ->id('inputtime') + ->render(), + "Failed asserting that an explicit 'aria-describedby' string value is preserved.", + ); + } + + public function testRenderWithAddAriaDescribedByTrueBooleanValue(): void + { + self::assertSame( + << + HTML, + InputTime::tag() + ->addAriaAttribute('describedby', true) + ->id('inputtime') + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to " + . "'true'.", + ); + } + + public function testRenderWithAddAriaDescribedByTrueBooleanValueAndIdNull(): void + { + self::assertSame( + << + HTML, + InputTime::tag() + ->addAriaAttribute('describedby', true) + ->id(null) + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to " + . "'true' and 'id' is 'null'.", + ); + } + + public function testRenderWithAddAriaDescribedByTrueBooleanValueAndPrefixSuffix(): void + { + self::assertSame( + <<Prefix + + Suffix + HTML, + InputTime::tag() + ->addAriaAttribute('describedby', true) + ->id('inputtime') + ->prefix('Prefix') + ->prefixTag(Inline::SPAN) + ->suffix('Suffix') + ->suffixTag(Inline::SPAN) + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to " + . "'true' and prefix/suffix.", + ); + } + + public function testRenderWithAddAriaDescribedByTrueBooleanValueString(): void + { + self::assertSame( + << + HTML, + InputTime::tag() + ->addAriaAttribute('describedby', 'true') + ->id('inputtime') + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to " + . "'true'.", + ); + } + + public function testRenderWithAddAriaDescribedByTrueStringValueAndPrefixSuffix(): void + { + self::assertSame( + <<Prefix + + Suffix + HTML, + InputTime::tag() + ->addAriaAttribute('describedby', 'true') + ->id('inputtime') + ->prefix('Prefix') + ->prefixTag(Inline::SPAN) + ->suffix('Suffix') + ->suffixTag(Inline::SPAN) + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to " + . "'true' and prefix/suffix.", + ); + } + public function testRenderWithAddAttribute(): void { self::assertSame( << + HTML, - InputTime::tag()->id('inputtime-')->addAttribute('data-test', 'value')->render(), + InputTime::tag()->id('inputtime')->addAttribute('data-test', 'value')->render(), "Failed asserting that element renders correctly with 'addAttribute()' method.", ); } @@ -88,9 +188,9 @@ public function testRenderWithAddAttributeUsingEnum(): void { self::assertSame( << + HTML, - InputTime::tag()->id('inputtime-')->addAttribute(GlobalAttribute::TITLE, 'Select time')->render(), + InputTime::tag()->id('inputtime')->addAttribute(GlobalAttribute::TITLE, 'Select time')->render(), "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", ); } @@ -99,9 +199,9 @@ public function testRenderWithAddDataAttribute(): void { self::assertSame( << + HTML, - InputTime::tag()->id('inputtime-')->addDataAttribute('time', 'value')->render(), + InputTime::tag()->id('inputtime')->addDataAttribute('time', 'value')->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method.", ); } @@ -110,9 +210,9 @@ public function testRenderWithAddDataAttributeUsingEnum(): void { self::assertSame( << + HTML, - InputTime::tag()->id('inputtime-')->addDataAttribute(Data::VALUE, 'test')->render(), + InputTime::tag()->id('inputtime')->addDataAttribute(Data::VALUE, 'test')->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method using enum.", ); } @@ -121,10 +221,10 @@ public function testRenderWithAriaAttributes(): void { self::assertSame( << + HTML, InputTime::tag() - ->id('inputtime-') + ->id('inputtime') ->ariaAttributes([ 'controls' => 'time-picker', 'label' => 'Select a time', @@ -134,24 +234,80 @@ public function testRenderWithAriaAttributes(): void ); } + public function testRenderWithAriaAttributesAndAriaDescribedByTrueBooleanValue(): void + { + self::assertSame( + << + HTML, + InputTime::tag() + ->ariaAttributes(['describedby' => true]) + ->id('inputtime') + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to true.", + ); + } + + public function testRenderWithAriaAttributesAndAriaDescribedByTrueStringValue(): void + { + self::assertSame( + << + HTML, + InputTime::tag() + ->ariaAttributes(['describedby' => 'true']) + ->id('inputtime') + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to true.", + ); + } + public function testRenderWithAttributes(): void { self::assertSame( << + HTML, - InputTime::tag()->id('inputtime-')->attributes(['class' => 'time-input'])->render(), + InputTime::tag()->id('inputtime')->attributes(['class' => 'time-input'])->render(), "Failed asserting that element renders correctly with 'attributes()' method.", ); } + public function testRenderWithAttributesAndAriaDescribedByTrueBooleanValue(): void + { + self::assertSame( + << + HTML, + InputTime::tag() + ->attributes(['aria-describedby' => true]) + ->id('inputtime') + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to true.", + ); + } + + public function testRenderWithAttributesAndAriaDescribedByTrueStringValue(): void + { + self::assertSame( + << + HTML, + InputTime::tag() + ->attributes(['aria-describedby' => 'true']) + ->id('inputtime') + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to true.", + ); + } + public function testRenderWithAutocomplete(): void { self::assertSame( << + HTML, - InputTime::tag()->autocomplete('on')->id('inputtime-')->render(), + InputTime::tag()->autocomplete('on')->id('inputtime')->render(), "Failed asserting that element renders correctly with 'autocomplete' attribute.", ); } @@ -160,9 +316,9 @@ public function testRenderWithAutocompleteUsingEnum(): void { self::assertSame( << + HTML, - InputTime::tag()->autocomplete(Autocomplete::ON)->id('inputtime-')->render(), + InputTime::tag()->autocomplete(Autocomplete::ON)->id('inputtime')->render(), "Failed asserting that element renders correctly with 'autocomplete' attribute using enum.", ); } @@ -171,9 +327,9 @@ public function testRenderWithAutofocus(): void { self::assertSame( << + HTML, - InputTime::tag()->autofocus(true)->id('inputtime-')->render(), + InputTime::tag()->autofocus(true)->id('inputtime')->render(), "Failed asserting that element renders correctly with 'autofocus' attribute.", ); } @@ -182,9 +338,9 @@ public function testRenderWithClass(): void { self::assertSame( << + HTML, - InputTime::tag()->id('inputtime-')->class('time-input')->render(), + InputTime::tag()->id('inputtime')->class('time-input')->render(), "Failed asserting that element renders correctly with 'class' attribute.", ); } @@ -193,9 +349,9 @@ public function testRenderWithDataAttributes(): void { self::assertSame( << + HTML, - InputTime::tag()->id('inputtime-')->dataAttributes(['time' => 'value'])->render(), + InputTime::tag()->id('inputtime')->dataAttributes(['time' => 'value'])->render(), "Failed asserting that element renders correctly with 'dataAttributes()' method.", ); } @@ -204,9 +360,9 @@ public function testRenderWithDefaultConfigurationValues(): void { self::assertSame( << + HTML, - InputTime::tag(['class' => 'default-class'])->id('inputtime-')->render(), + InputTime::tag(['class' => 'default-class'])->id('inputtime')->render(), 'Failed asserting that default configuration values are applied correctly.', ); } @@ -215,9 +371,9 @@ public function testRenderWithDefaultProvider(): void { self::assertSame( << + HTML, - InputTime::tag()->id('inputtime-')->addDefaultProvider(DefaultProvider::class)->render(), + InputTime::tag()->id('inputtime')->addDefaultProvider(DefaultProvider::class)->render(), 'Failed asserting that default provider is applied correctly.', ); } @@ -226,9 +382,9 @@ public function testRenderWithDefaultValues(): void { self::assertSame( << + HTML, - InputTime::tag()->id('inputtime-')->render(), + InputTime::tag()->id('inputtime')->render(), 'Failed asserting that element renders correctly with default values.', ); } @@ -237,9 +393,9 @@ public function testRenderWithDir(): void { self::assertSame( << + HTML, - InputTime::tag()->id('inputtime-')->dir('ltr')->render(), + InputTime::tag()->id('inputtime')->dir('ltr')->render(), "Failed asserting that element renders correctly with 'dir' attribute.", ); } @@ -248,9 +404,9 @@ public function testRenderWithDirUsingEnum(): void { self::assertSame( << + HTML, - InputTime::tag()->id('inputtime-')->dir(Direction::LTR)->render(), + InputTime::tag()->id('inputtime')->dir(Direction::LTR)->render(), "Failed asserting that element renders correctly with 'dir' attribute using enum.", ); } @@ -259,9 +415,9 @@ public function testRenderWithDisabled(): void { self::assertSame( << + HTML, - InputTime::tag()->id('inputtime-')->disabled(true)->render(), + InputTime::tag()->id('inputtime')->disabled(true)->render(), "Failed asserting that element renders correctly with 'disabled' attribute.", ); } @@ -270,13 +426,25 @@ public function testRenderWithForm(): void { self::assertSame( << + HTML, - InputTime::tag()->form('form-id')->id('inputtime-')->render(), + InputTime::tag()->form('form-id')->id('inputtime')->render(), "Failed asserting that element renders correctly with 'form' attribute.", ); } + public function testRenderWithGenerateId(): void + { + /** @phpstan-var string $id */ + $id = InputTime::tag()->getAttribute('id', ''); + + self::assertMatchesRegularExpression( + '/^inputtime-\w+$/', + $id, + 'Failed asserting that element generates an ID when not provided.', + ); + } + public function testRenderWithGlobalDefaultsAreApplied(): void { SimpleFactory::setDefaults(InputTime::class, ['class' => 'default-class']); @@ -294,9 +462,9 @@ public function testRenderWithHidden(): void { self::assertSame( << + HTML, - InputTime::tag()->id('inputtime-')->hidden(true)->render(), + InputTime::tag()->id('inputtime')->hidden(true)->render(), "Failed asserting that element renders correctly with 'hidden' attribute.", ); } @@ -316,9 +484,9 @@ public function testRenderWithLang(): void { self::assertSame( << + HTML, - InputTime::tag()->id('inputtime-')->lang('en')->render(), + InputTime::tag()->id('inputtime')->lang('en')->render(), "Failed asserting that element renders correctly with 'lang' attribute.", ); } @@ -327,9 +495,9 @@ public function testRenderWithLangUsingEnum(): void { self::assertSame( << + HTML, - InputTime::tag()->id('inputtime-')->lang(Language::ENGLISH)->render(), + InputTime::tag()->id('inputtime')->lang(Language::ENGLISH)->render(), "Failed asserting that element renders correctly with 'lang' attribute using enum.", ); } @@ -338,9 +506,9 @@ public function testRenderWithList(): void { self::assertSame( << + HTML, - InputTime::tag()->id('inputtime-')->list('times')->render(), + InputTime::tag()->id('inputtime')->list('times')->render(), "Failed asserting that element renders correctly with 'list' attribute.", ); } @@ -349,9 +517,9 @@ public function testRenderWithMax(): void { self::assertSame( << + HTML, - InputTime::tag()->id('inputtime-')->max('18:00')->render(), + InputTime::tag()->id('inputtime')->max('18:00')->render(), "Failed asserting that element renders correctly with 'max' attribute.", ); } @@ -360,9 +528,9 @@ public function testRenderWithMin(): void { self::assertSame( << + HTML, - InputTime::tag()->id('inputtime-')->min('09:00')->render(), + InputTime::tag()->id('inputtime')->min('09:00')->render(), "Failed asserting that element renders correctly with 'min' attribute.", ); } @@ -371,10 +539,10 @@ public function testRenderWithMinAndMax(): void { self::assertSame( << + HTML, InputTime::tag() - ->id('inputtime-') + ->id('inputtime') ->min('09:00') ->max('18:00') ->render(), @@ -386,9 +554,9 @@ public function testRenderWithName(): void { self::assertSame( << + HTML, - InputTime::tag()->id('inputtime-')->name('alarm')->render(), + InputTime::tag()->id('inputtime')->name('alarm')->render(), "Failed asserting that element renders correctly with 'name' attribute.", ); } @@ -397,9 +565,9 @@ public function testRenderWithReadonly(): void { self::assertSame( << + HTML, - InputTime::tag()->id('inputtime-')->readonly(true)->render(), + InputTime::tag()->id('inputtime')->readonly(true)->render(), "Failed asserting that element renders correctly with 'readonly' attribute.", ); } @@ -408,10 +576,10 @@ public function testRenderWithRemoveAriaAttribute(): void { self::assertSame( << + HTML, InputTime::tag() - ->id('inputtime-') + ->id('inputtime') ->addAriaAttribute('label', 'Close') ->removeAriaAttribute('label') ->render(), @@ -423,10 +591,10 @@ public function testRenderWithRemoveAttribute(): void { self::assertSame( << + HTML, InputTime::tag() - ->id('inputtime-') + ->id('inputtime') ->addAttribute('data-test', 'value') ->removeAttribute('data-test') ->render(), @@ -438,10 +606,10 @@ public function testRenderWithRemoveDataAttribute(): void { self::assertSame( << + HTML, InputTime::tag() - ->id('inputtime-') + ->id('inputtime') ->addDataAttribute('value', 'test') ->removeDataAttribute('value') ->render(), @@ -453,9 +621,9 @@ public function testRenderWithRequired(): void { self::assertSame( << + HTML, - InputTime::tag()->id('inputtime-')->required(true)->render(), + InputTime::tag()->id('inputtime')->required(true)->render(), "Failed asserting that element renders correctly with 'required' attribute.", ); } @@ -464,9 +632,9 @@ public function testRenderWithRole(): void { self::assertSame( << + HTML, - InputTime::tag()->id('inputtime-')->role('textbox')->render(), + InputTime::tag()->id('inputtime')->role('textbox')->render(), "Failed asserting that element renders correctly with 'role' attribute.", ); } @@ -475,9 +643,9 @@ public function testRenderWithRoleUsingEnum(): void { self::assertSame( << + HTML, - InputTime::tag()->id('inputtime-')->role(Role::TEXTBOX)->render(), + InputTime::tag()->id('inputtime')->role(Role::TEXTBOX)->render(), "Failed asserting that element renders correctly with 'role' attribute using enum.", ); } @@ -486,9 +654,9 @@ public function testRenderWithStep(): void { self::assertSame( << + HTML, - InputTime::tag()->id('inputtime-')->step(2)->render(), + InputTime::tag()->id('inputtime')->step(2)->render(), "Failed asserting that element renders correctly with 'step' attribute.", ); } @@ -497,9 +665,9 @@ public function testRenderWithStepAny(): void { self::assertSame( << + HTML, - InputTime::tag()->id('inputtime-')->step('any')->render(), + InputTime::tag()->id('inputtime')->step('any')->render(), "Failed asserting that element renders correctly with 'step' attribute set to 'any'.", ); } @@ -508,9 +676,9 @@ public function testRenderWithStyle(): void { self::assertSame( << + HTML, - InputTime::tag()->id('inputtime-')->style('width: 200px;')->render(), + InputTime::tag()->id('inputtime')->style('width: 200px;')->render(), "Failed asserting that element renders correctly with 'style' attribute.", ); } @@ -519,9 +687,9 @@ public function testRenderWithTabindex(): void { self::assertSame( << + HTML, - InputTime::tag()->id('inputtime-')->tabIndex(1)->render(), + InputTime::tag()->id('inputtime')->tabIndex(1)->render(), "Failed asserting that element renders correctly with 'tabindex' attribute.", ); } @@ -530,9 +698,9 @@ public function testRenderWithThemeProvider(): void { self::assertSame( << + HTML, - InputTime::tag()->id('inputtime-')->addThemeProvider('muted', DefaultThemeProvider::class)->render(), + InputTime::tag()->id('inputtime')->addThemeProvider('muted', DefaultThemeProvider::class)->render(), "Failed asserting that element renders correctly with 'addThemeProvider()' method.", ); } @@ -541,18 +709,22 @@ public function testRenderWithTitle(): void { self::assertSame( << + HTML, - InputTime::tag()->id('inputtime-')->title('Select a time')->render(), + InputTime::tag()->id('inputtime')->title('Select a time')->render(), "Failed asserting that element renders correctly with 'title' attribute.", ); } public function testRenderWithToString(): void { - self::assertStringContainsString( - 'type="time"', - LineEndingNormalizer::normalize((string) InputTime::tag()), + self::assertSame( + << + HTML, + InputTime::tag() + ->id(null) + ->render(), "Failed asserting that '__toString()' method renders correctly.", ); } @@ -561,9 +733,9 @@ public function testRenderWithTranslate(): void { self::assertSame( << + HTML, - InputTime::tag()->id('inputtime-')->translate(false)->render(), + InputTime::tag()->id('inputtime')->translate(false)->render(), "Failed asserting that element renders correctly with 'translate' attribute.", ); } @@ -572,9 +744,9 @@ public function testRenderWithTranslateUsingEnum(): void { self::assertSame( << + HTML, - InputTime::tag()->id('inputtime-')->translate(Translate::NO)->render(), + InputTime::tag()->id('inputtime')->translate(Translate::NO)->render(), "Failed asserting that element renders correctly with 'translate' attribute using enum.", ); } @@ -595,9 +767,9 @@ public function testRenderWithValue(): void { self::assertSame( << + HTML, - InputTime::tag()->id('inputtime-')->value('14:30')->render(), + InputTime::tag()->id('inputtime')->value('14:30')->render(), "Failed asserting that element renders correctly with 'value' attribute.", ); } diff --git a/tests/Form/InputUrlTest.php b/tests/Form/InputUrlTest.php index 298b830..b941eb3 100644 --- a/tests/Form/InputUrlTest.php +++ b/tests/Form/InputUrlTest.php @@ -4,12 +4,12 @@ namespace UIAwesome\Html\Tests\Form; -use PHPForge\Support\LineEndingNormalizer; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use UIAwesome\Html\Attribute\Values\{Aria, Autocomplete, Data, Direction, GlobalAttribute, Language, Role, Translate}; use UIAwesome\Html\Core\Factory\SimpleFactory; use UIAwesome\Html\Form\InputUrl; +use UIAwesome\Html\Interop\Inline; use UIAwesome\Html\Tests\Support\Stub\{DefaultProvider, DefaultThemeProvider}; /** @@ -29,7 +29,6 @@ * @copyright Copyright (C) 2026 Terabytesoftw. * @license https://opensource.org/license/bsd-3-clause BSD 3-Clause License. */ -#[Group('html')] #[Group('form')] final class InputUrlTest extends TestCase { @@ -46,9 +45,9 @@ public function testRenderWithAccesskey(): void { self::assertSame( << + HTML, - InputUrl::tag()->id('inputurl-')->accesskey('k')->render(), + InputUrl::tag()->id('inputurl')->accesskey('k')->render(), "Failed asserting that element renders correctly with 'accesskey' attribute.", ); } @@ -57,9 +56,9 @@ public function testRenderWithAddAriaAttribute(): void { self::assertSame( << + HTML, - InputUrl::tag()->id('inputurl-')->addAriaAttribute('label', 'Url selector')->render(), + InputUrl::tag()->id('inputurl')->addAriaAttribute('label', 'Url selector')->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method.", ); } @@ -68,20 +67,121 @@ public function testRenderWithAddAriaAttributeUsingEnum(): void { self::assertSame( << + HTML, - InputUrl::tag()->id('inputurl-')->addAriaAttribute(Aria::HIDDEN, true)->render(), + InputUrl::tag()->id('inputurl')->addAriaAttribute(Aria::HIDDEN, true)->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method using enum.", ); } + public function testRenderWithAddAriaDescribedByString(): void + { + self::assertSame( + << + HTML, + InputUrl::tag() + ->addAriaAttribute('describedby', 'custom-help') + ->id('inputurl') + ->render(), + "Failed asserting that an explicit 'aria-describedby' string value is preserved.", + ); + } + + public function testRenderWithAddAriaDescribedByTrueBooleanValue(): void + { + self::assertSame( + << + HTML, + InputUrl::tag() + ->addAriaAttribute('describedby', true) + ->id('inputurl') + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to " + . "'true'.", + ); + } + + public function testRenderWithAddAriaDescribedByTrueBooleanValueAndIdNull(): void + { + self::assertSame( + << + HTML, + InputUrl::tag() + ->addAriaAttribute('describedby', true) + ->id(null) + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to " + . "'true' and 'id' is 'null'.", + ); + } + + public function testRenderWithAddAriaDescribedByTrueBooleanValueAndPrefixSuffix(): void + { + self::assertSame( + <<Prefix + + Suffix + HTML, + InputUrl::tag() + ->addAriaAttribute('describedby', true) + ->id('inputurl') + ->prefix('Prefix') + ->prefixTag(Inline::SPAN) + ->suffix('Suffix') + ->suffixTag(Inline::SPAN) + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to " + . "'true' and prefix/suffix.", + ); + } + + public function testRenderWithAddAriaDescribedByTrueBooleanValueString(): void + { + self::assertSame( + << + HTML, + InputUrl::tag() + ->addAriaAttribute('describedby', 'true') + ->id('inputurl') + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to " + . "'true'.", + ); + } + + public function testRenderWithAddAriaDescribedByTrueStringValueAndPrefixSuffix(): void + { + self::assertSame( + <<Prefix + + Suffix + HTML, + InputUrl::tag() + ->addAriaAttribute('describedby', 'true') + ->id('inputurl') + ->prefix('Prefix') + ->prefixTag(Inline::SPAN) + ->suffix('Suffix') + ->suffixTag(Inline::SPAN) + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to " + . "'true' and prefix/suffix.", + ); + } + public function testRenderWithAddAttribute(): void { self::assertSame( << + HTML, - InputUrl::tag()->id('inputurl-')->addAttribute('data-test', 'value')->render(), + InputUrl::tag()->id('inputurl')->addAttribute('data-test', 'value')->render(), "Failed asserting that element renders correctly with 'addAttribute()' method.", ); } @@ -90,9 +190,9 @@ public function testRenderWithAddAttributeUsingEnum(): void { self::assertSame( << + HTML, - InputUrl::tag()->id('inputurl-')->addAttribute(GlobalAttribute::TITLE, 'Select url')->render(), + InputUrl::tag()->id('inputurl')->addAttribute(GlobalAttribute::TITLE, 'Select url')->render(), "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", ); } @@ -101,9 +201,9 @@ public function testRenderWithAddDataAttribute(): void { self::assertSame( << + HTML, - InputUrl::tag()->id('inputurl-')->addDataAttribute('url', 'value')->render(), + InputUrl::tag()->id('inputurl')->addDataAttribute('url', 'value')->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method.", ); } @@ -112,9 +212,9 @@ public function testRenderWithAddDataAttributeUsingEnum(): void { self::assertSame( << + HTML, - InputUrl::tag()->id('inputurl-')->addDataAttribute(Data::VALUE, 'test')->render(), + InputUrl::tag()->id('inputurl')->addDataAttribute(Data::VALUE, 'test')->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method using enum.", ); } @@ -123,10 +223,10 @@ public function testRenderWithAriaAttributes(): void { self::assertSame( << + HTML, InputUrl::tag() - ->id('inputurl-') + ->id('inputurl') ->ariaAttributes([ 'controls' => 'url-picker', 'label' => 'Select a url', @@ -136,24 +236,80 @@ public function testRenderWithAriaAttributes(): void ); } + public function testRenderWithAriaAttributesAndAriaDescribedByTrueBooleanValue(): void + { + self::assertSame( + << + HTML, + InputUrl::tag() + ->ariaAttributes(['describedby' => true]) + ->id('inputurl') + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to true.", + ); + } + + public function testRenderWithAriaAttributesAndAriaDescribedByTrueStringValue(): void + { + self::assertSame( + << + HTML, + InputUrl::tag() + ->ariaAttributes(['describedby' => 'true']) + ->id('inputurl') + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to true.", + ); + } + public function testRenderWithAttributes(): void { self::assertSame( << + HTML, - InputUrl::tag()->id('inputurl-')->attributes(['class' => 'url-input'])->render(), + InputUrl::tag()->id('inputurl')->attributes(['class' => 'url-input'])->render(), "Failed asserting that element renders correctly with 'attributes()' method.", ); } + public function testRenderWithAttributesAndAriaDescribedByTrueBooleanValue(): void + { + self::assertSame( + << + HTML, + InputUrl::tag() + ->attributes(['aria-describedby' => true]) + ->id('inputurl') + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to true.", + ); + } + + public function testRenderWithAttributesAndAriaDescribedByTrueStringValue(): void + { + self::assertSame( + << + HTML, + InputUrl::tag() + ->attributes(['aria-describedby' => 'true']) + ->id('inputurl') + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to true.", + ); + } + public function testRenderWithAutocomplete(): void { self::assertSame( << + HTML, - InputUrl::tag()->autocomplete('on')->id('inputurl-')->render(), + InputUrl::tag()->autocomplete('on')->id('inputurl')->render(), "Failed asserting that element renders correctly with 'autocomplete' attribute.", ); } @@ -162,9 +318,9 @@ public function testRenderWithAutocompleteUsingEnum(): void { self::assertSame( << + HTML, - InputUrl::tag()->autocomplete(Autocomplete::ON)->id('inputurl-')->render(), + InputUrl::tag()->autocomplete(Autocomplete::ON)->id('inputurl')->render(), "Failed asserting that element renders correctly with 'autocomplete' attribute using enum.", ); } @@ -173,9 +329,9 @@ public function testRenderWithAutofocus(): void { self::assertSame( << + HTML, - InputUrl::tag()->autofocus(true)->id('inputurl-')->render(), + InputUrl::tag()->autofocus(true)->id('inputurl')->render(), "Failed asserting that element renders correctly with 'autofocus' attribute.", ); } @@ -184,9 +340,9 @@ public function testRenderWithClass(): void { self::assertSame( << + HTML, - InputUrl::tag()->id('inputurl-')->class('url-input')->render(), + InputUrl::tag()->id('inputurl')->class('url-input')->render(), "Failed asserting that element renders correctly with 'class' attribute.", ); } @@ -195,9 +351,9 @@ public function testRenderWithDataAttributes(): void { self::assertSame( << + HTML, - InputUrl::tag()->id('inputurl-')->dataAttributes(['url' => 'value'])->render(), + InputUrl::tag()->id('inputurl')->dataAttributes(['url' => 'value'])->render(), "Failed asserting that element renders correctly with 'dataAttributes()' method.", ); } @@ -206,9 +362,9 @@ public function testRenderWithDefaultConfigurationValues(): void { self::assertSame( << + HTML, - InputUrl::tag(['class' => 'default-class'])->id('inputurl-')->render(), + InputUrl::tag(['class' => 'default-class'])->id('inputurl')->render(), 'Failed asserting that default configuration values are applied correctly.', ); } @@ -217,9 +373,9 @@ public function testRenderWithDefaultProvider(): void { self::assertSame( << + HTML, - InputUrl::tag()->id('inputurl-')->addDefaultProvider(DefaultProvider::class)->render(), + InputUrl::tag()->id('inputurl')->addDefaultProvider(DefaultProvider::class)->render(), 'Failed asserting that default provider is applied correctly.', ); } @@ -228,9 +384,9 @@ public function testRenderWithDefaultValues(): void { self::assertSame( << + HTML, - InputUrl::tag()->id('inputurl-')->render(), + InputUrl::tag()->id('inputurl')->render(), 'Failed asserting that element renders correctly with default values.', ); } @@ -239,9 +395,9 @@ public function testRenderWithDir(): void { self::assertSame( << + HTML, - InputUrl::tag()->id('inputurl-')->dir('ltr')->render(), + InputUrl::tag()->id('inputurl')->dir('ltr')->render(), "Failed asserting that element renders correctly with 'dir' attribute.", ); } @@ -250,9 +406,9 @@ public function testRenderWithDirUsingEnum(): void { self::assertSame( << + HTML, - InputUrl::tag()->id('inputurl-')->dir(Direction::LTR)->render(), + InputUrl::tag()->id('inputurl')->dir(Direction::LTR)->render(), "Failed asserting that element renders correctly with 'dir' attribute using enum.", ); } @@ -261,9 +417,9 @@ public function testRenderWithDisabled(): void { self::assertSame( << + HTML, - InputUrl::tag()->id('inputurl-')->disabled(true)->render(), + InputUrl::tag()->id('inputurl')->disabled(true)->render(), "Failed asserting that element renders correctly with 'disabled' attribute.", ); } @@ -272,13 +428,25 @@ public function testRenderWithForm(): void { self::assertSame( << + HTML, - InputUrl::tag()->form('form-id')->id('inputurl-')->render(), + InputUrl::tag()->form('form-id')->id('inputurl')->render(), "Failed asserting that element renders correctly with 'form' attribute.", ); } + public function testRenderWithGenerateId(): void + { + /** @phpstan-var string $id */ + $id = InputUrl::tag()->getAttribute('id', ''); + + self::assertMatchesRegularExpression( + '/^inputurl-\w+$/', + $id, + 'Failed asserting that element generates an ID when not provided.', + ); + } + public function testRenderWithGlobalDefaultsAreApplied(): void { SimpleFactory::setDefaults(InputUrl::class, ['class' => 'default-class']); @@ -296,9 +464,9 @@ public function testRenderWithHidden(): void { self::assertSame( << + HTML, - InputUrl::tag()->id('inputurl-')->hidden(true)->render(), + InputUrl::tag()->id('inputurl')->hidden(true)->render(), "Failed asserting that element renders correctly with 'hidden' attribute.", ); } @@ -318,9 +486,9 @@ public function testRenderWithLang(): void { self::assertSame( << + HTML, - InputUrl::tag()->id('inputurl-')->lang('en')->render(), + InputUrl::tag()->id('inputurl')->lang('en')->render(), "Failed asserting that element renders correctly with 'lang' attribute.", ); } @@ -329,9 +497,9 @@ public function testRenderWithLangUsingEnum(): void { self::assertSame( << + HTML, - InputUrl::tag()->id('inputurl-')->lang(Language::ENGLISH)->render(), + InputUrl::tag()->id('inputurl')->lang(Language::ENGLISH)->render(), "Failed asserting that element renders correctly with 'lang' attribute using enum.", ); } @@ -340,9 +508,9 @@ public function testRenderWithList(): void { self::assertSame( << + HTML, - InputUrl::tag()->id('inputurl-')->list('urls')->render(), + InputUrl::tag()->id('inputurl')->list('urls')->render(), "Failed asserting that element renders correctly with 'list' attribute.", ); } @@ -351,9 +519,9 @@ public function testRenderWithMaxlength(): void { self::assertSame( << + HTML, - InputUrl::tag()->id('inputurl-')->maxlength(10)->render(), + InputUrl::tag()->id('inputurl')->maxlength(10)->render(), "Failed asserting that element renders correctly with 'maxlength' attribute.", ); } @@ -362,9 +530,9 @@ public function testRenderWithMinlength(): void { self::assertSame( << + HTML, - InputUrl::tag()->id('inputurl-')->minlength(5)->render(), + InputUrl::tag()->id('inputurl')->minlength(5)->render(), "Failed asserting that element renders correctly with 'minlength' attribute.", ); } @@ -373,9 +541,9 @@ public function testRenderWithName(): void { self::assertSame( << + HTML, - InputUrl::tag()->id('inputurl-')->name('website')->render(), + InputUrl::tag()->id('inputurl')->name('website')->render(), "Failed asserting that element renders correctly with 'name' attribute.", ); } @@ -384,9 +552,9 @@ public function testRenderWithPattern(): void { self::assertSame( << + HTML, - InputUrl::tag()->id('inputurl-')->pattern('https://.*')->render(), + InputUrl::tag()->id('inputurl')->pattern('https://.*')->render(), "Failed asserting that element renders correctly with 'pattern' attribute.", ); } @@ -395,9 +563,9 @@ public function testRenderWithPlaceholder(): void { self::assertSame( << + HTML, - InputUrl::tag()->id('inputurl-')->placeholder('https://example.com')->render(), + InputUrl::tag()->id('inputurl')->placeholder('https://example.com')->render(), "Failed asserting that element renders correctly with 'placeholder' attribute.", ); } @@ -406,9 +574,9 @@ public function testRenderWithReadonly(): void { self::assertSame( << + HTML, - InputUrl::tag()->id('inputurl-')->readonly(true)->render(), + InputUrl::tag()->id('inputurl')->readonly(true)->render(), "Failed asserting that element renders correctly with 'readonly' attribute.", ); } @@ -417,10 +585,10 @@ public function testRenderWithRemoveAriaAttribute(): void { self::assertSame( << + HTML, InputUrl::tag() - ->id('inputurl-') + ->id('inputurl') ->addAriaAttribute('label', 'Close') ->removeAriaAttribute('label') ->render(), @@ -432,10 +600,10 @@ public function testRenderWithRemoveAttribute(): void { self::assertSame( << + HTML, InputUrl::tag() - ->id('inputurl-') + ->id('inputurl') ->addAttribute('data-test', 'value') ->removeAttribute('data-test') ->render(), @@ -447,10 +615,10 @@ public function testRenderWithRemoveDataAttribute(): void { self::assertSame( << + HTML, InputUrl::tag() - ->id('inputurl-') + ->id('inputurl') ->addDataAttribute('value', 'test') ->removeDataAttribute('value') ->render(), @@ -462,9 +630,9 @@ public function testRenderWithRequired(): void { self::assertSame( << + HTML, - InputUrl::tag()->id('inputurl-')->required(true)->render(), + InputUrl::tag()->id('inputurl')->required(true)->render(), "Failed asserting that element renders correctly with 'required' attribute.", ); } @@ -473,9 +641,9 @@ public function testRenderWithRole(): void { self::assertSame( << + HTML, - InputUrl::tag()->id('inputurl-')->role('textbox')->render(), + InputUrl::tag()->id('inputurl')->role('textbox')->render(), "Failed asserting that element renders correctly with 'role' attribute.", ); } @@ -484,9 +652,9 @@ public function testRenderWithRoleUsingEnum(): void { self::assertSame( << + HTML, - InputUrl::tag()->id('inputurl-')->role(Role::TEXTBOX)->render(), + InputUrl::tag()->id('inputurl')->role(Role::TEXTBOX)->render(), "Failed asserting that element renders correctly with 'role' attribute using enum.", ); } @@ -495,9 +663,9 @@ public function testRenderWithSize(): void { self::assertSame( << + HTML, - InputUrl::tag()->id('inputurl-')->size(30)->render(), + InputUrl::tag()->id('inputurl')->size(30)->render(), "Failed asserting that element renders correctly with 'size' attribute.", ); } @@ -506,9 +674,9 @@ public function testRenderWithSpellcheck(): void { self::assertSame( << + HTML, - InputUrl::tag()->id('inputurl-')->spellcheck(true)->render(), + InputUrl::tag()->id('inputurl')->spellcheck(true)->render(), "Failed asserting that element renders correctly with 'spellcheck' attribute.", ); } @@ -517,9 +685,9 @@ public function testRenderWithStyle(): void { self::assertSame( << + HTML, - InputUrl::tag()->id('inputurl-')->style('width: 200px;')->render(), + InputUrl::tag()->id('inputurl')->style('width: 200px;')->render(), "Failed asserting that element renders correctly with 'style' attribute.", ); } @@ -528,9 +696,9 @@ public function testRenderWithTabindex(): void { self::assertSame( << + HTML, - InputUrl::tag()->id('inputurl-')->tabIndex(1)->render(), + InputUrl::tag()->id('inputurl')->tabIndex(1)->render(), "Failed asserting that element renders correctly with 'tabindex' attribute.", ); } @@ -539,9 +707,9 @@ public function testRenderWithThemeProvider(): void { self::assertSame( << + HTML, - InputUrl::tag()->id('inputurl-')->addThemeProvider('muted', DefaultThemeProvider::class)->render(), + InputUrl::tag()->id('inputurl')->addThemeProvider('muted', DefaultThemeProvider::class)->render(), "Failed asserting that element renders correctly with 'addThemeProvider()' method.", ); } @@ -550,18 +718,22 @@ public function testRenderWithTitle(): void { self::assertSame( << + HTML, - InputUrl::tag()->id('inputurl-')->title('Select a url')->render(), + InputUrl::tag()->id('inputurl')->title('Select a url')->render(), "Failed asserting that element renders correctly with 'title' attribute.", ); } public function testRenderWithToString(): void { - self::assertStringContainsString( - 'type="url"', - LineEndingNormalizer::normalize((string) InputUrl::tag()), + self::assertSame( + << + HTML, + InputUrl::tag() + ->id(null) + ->render(), "Failed asserting that '__toString()' method renders correctly.", ); } @@ -570,9 +742,9 @@ public function testRenderWithTranslate(): void { self::assertSame( << + HTML, - InputUrl::tag()->id('inputurl-')->translate(false)->render(), + InputUrl::tag()->id('inputurl')->translate(false)->render(), "Failed asserting that element renders correctly with 'translate' attribute.", ); } @@ -581,9 +753,9 @@ public function testRenderWithTranslateUsingEnum(): void { self::assertSame( << + HTML, - InputUrl::tag()->id('inputurl-')->translate(Translate::NO)->render(), + InputUrl::tag()->id('inputurl')->translate(Translate::NO)->render(), "Failed asserting that element renders correctly with 'translate' attribute using enum.", ); } @@ -604,9 +776,9 @@ public function testRenderWithValue(): void { self::assertSame( << + HTML, - InputUrl::tag()->id('inputurl-')->value('https://example.com')->render(), + InputUrl::tag()->id('inputurl')->value('https://example.com')->render(), "Failed asserting that element renders correctly with 'value' attribute.", ); } diff --git a/tests/Form/InputWeekTest.php b/tests/Form/InputWeekTest.php index 0f83cc0..282774b 100644 --- a/tests/Form/InputWeekTest.php +++ b/tests/Form/InputWeekTest.php @@ -4,12 +4,12 @@ namespace UIAwesome\Html\Tests\Form; -use PHPForge\Support\LineEndingNormalizer; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use UIAwesome\Html\Attribute\Values\{Aria, Autocomplete, Data, Direction, GlobalAttribute, Language, Role, Translate}; use UIAwesome\Html\Core\Factory\SimpleFactory; use UIAwesome\Html\Form\InputWeek; +use UIAwesome\Html\Interop\Inline; use UIAwesome\Html\Tests\Support\Stub\{DefaultProvider, DefaultThemeProvider}; /** @@ -27,7 +27,6 @@ * @copyright Copyright (C) 2026 Terabytesoftw. * @license https://opensource.org/license/bsd-3-clause BSD 3-Clause License. */ -#[Group('html')] #[Group('form')] final class InputWeekTest extends TestCase { @@ -44,9 +43,9 @@ public function testRenderWithAccesskey(): void { self::assertSame( << + HTML, - InputWeek::tag()->id('inputweek-')->accesskey('k')->render(), + InputWeek::tag()->id('inputweek')->accesskey('k')->render(), "Failed asserting that element renders correctly with 'accesskey' attribute.", ); } @@ -55,9 +54,9 @@ public function testRenderWithAddAriaAttribute(): void { self::assertSame( << + HTML, - InputWeek::tag()->id('inputweek-')->addAriaAttribute('label', 'Week selector')->render(), + InputWeek::tag()->id('inputweek')->addAriaAttribute('label', 'Week selector')->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method.", ); } @@ -66,20 +65,121 @@ public function testRenderWithAddAriaAttributeUsingEnum(): void { self::assertSame( << + HTML, - InputWeek::tag()->id('inputweek-')->addAriaAttribute(Aria::HIDDEN, true)->render(), + InputWeek::tag()->id('inputweek')->addAriaAttribute(Aria::HIDDEN, true)->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method using enum.", ); } + public function testRenderWithAddAriaDescribedByString(): void + { + self::assertSame( + << + HTML, + InputWeek::tag() + ->addAriaAttribute('describedby', 'custom-help') + ->id('inputweek') + ->render(), + "Failed asserting that an explicit 'aria-describedby' string value is preserved.", + ); + } + + public function testRenderWithAddAriaDescribedByTrueBooleanValue(): void + { + self::assertSame( + << + HTML, + InputWeek::tag() + ->addAriaAttribute('describedby', true) + ->id('inputweek') + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to " + . "'true'.", + ); + } + + public function testRenderWithAddAriaDescribedByTrueBooleanValueAndIdNull(): void + { + self::assertSame( + << + HTML, + InputWeek::tag() + ->addAriaAttribute('describedby', true) + ->id(null) + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to " + . "'true' and 'id' is 'null'.", + ); + } + + public function testRenderWithAddAriaDescribedByTrueBooleanValueAndPrefixSuffix(): void + { + self::assertSame( + <<Prefix + + Suffix + HTML, + InputWeek::tag() + ->addAriaAttribute('describedby', true) + ->id('inputweek') + ->prefix('Prefix') + ->prefixTag(Inline::SPAN) + ->suffix('Suffix') + ->suffixTag(Inline::SPAN) + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to " + . "'true' and prefix/suffix.", + ); + } + + public function testRenderWithAddAriaDescribedByTrueBooleanValueString(): void + { + self::assertSame( + << + HTML, + InputWeek::tag() + ->addAriaAttribute('describedby', 'true') + ->id('inputweek') + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to " + . "'true'.", + ); + } + + public function testRenderWithAddAriaDescribedByTrueStringValueAndPrefixSuffix(): void + { + self::assertSame( + <<Prefix + + Suffix + HTML, + InputWeek::tag() + ->addAriaAttribute('describedby', 'true') + ->id('inputweek') + ->prefix('Prefix') + ->prefixTag(Inline::SPAN) + ->suffix('Suffix') + ->suffixTag(Inline::SPAN) + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to " + . "'true' and prefix/suffix.", + ); + } + public function testRenderWithAddAttribute(): void { self::assertSame( << + HTML, - InputWeek::tag()->id('inputweek-')->addAttribute('data-test', 'value')->render(), + InputWeek::tag()->id('inputweek')->addAttribute('data-test', 'value')->render(), "Failed asserting that element renders correctly with 'addAttribute()' method.", ); } @@ -88,9 +188,9 @@ public function testRenderWithAddAttributeUsingEnum(): void { self::assertSame( << + HTML, - InputWeek::tag()->id('inputweek-')->addAttribute(GlobalAttribute::TITLE, 'Select week')->render(), + InputWeek::tag()->id('inputweek')->addAttribute(GlobalAttribute::TITLE, 'Select week')->render(), "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", ); } @@ -99,9 +199,9 @@ public function testRenderWithAddDataAttribute(): void { self::assertSame( << + HTML, - InputWeek::tag()->id('inputweek-')->addDataAttribute('week', 'value')->render(), + InputWeek::tag()->id('inputweek')->addDataAttribute('week', 'value')->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method.", ); } @@ -110,9 +210,9 @@ public function testRenderWithAddDataAttributeUsingEnum(): void { self::assertSame( << + HTML, - InputWeek::tag()->id('inputweek-')->addDataAttribute(Data::VALUE, 'test')->render(), + InputWeek::tag()->id('inputweek')->addDataAttribute(Data::VALUE, 'test')->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method using enum.", ); } @@ -121,10 +221,10 @@ public function testRenderWithAriaAttributes(): void { self::assertSame( << + HTML, InputWeek::tag() - ->id('inputweek-') + ->id('inputweek') ->ariaAttributes([ 'controls' => 'week-picker', 'label' => 'Select a week', @@ -134,24 +234,80 @@ public function testRenderWithAriaAttributes(): void ); } + public function testRenderWithAriaAttributesAndAriaDescribedByTrueBooleanValue(): void + { + self::assertSame( + << + HTML, + InputWeek::tag() + ->ariaAttributes(['describedby' => true]) + ->id('inputweek') + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to true.", + ); + } + + public function testRenderWithAriaAttributesAndAriaDescribedByTrueStringValue(): void + { + self::assertSame( + << + HTML, + InputWeek::tag() + ->ariaAttributes(['describedby' => 'true']) + ->id('inputweek') + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to true.", + ); + } + public function testRenderWithAttributes(): void { self::assertSame( << + HTML, - InputWeek::tag()->id('inputweek-')->attributes(['class' => 'week-input'])->render(), + InputWeek::tag()->id('inputweek')->attributes(['class' => 'week-input'])->render(), "Failed asserting that element renders correctly with 'attributes()' method.", ); } + public function testRenderWithAttributesAndAriaDescribedByTrueBooleanValue(): void + { + self::assertSame( + << + HTML, + InputWeek::tag() + ->attributes(['aria-describedby' => true]) + ->id('inputweek') + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to true.", + ); + } + + public function testRenderWithAttributesAndAriaDescribedByTrueStringValue(): void + { + self::assertSame( + << + HTML, + InputWeek::tag() + ->attributes(['aria-describedby' => 'true']) + ->id('inputweek') + ->render(), + "Failed asserting that element renders correctly with 'aria-describedby' attribute set to true.", + ); + } + public function testRenderWithAutocomplete(): void { self::assertSame( << + HTML, - InputWeek::tag()->autocomplete('on')->id('inputweek-')->render(), + InputWeek::tag()->autocomplete('on')->id('inputweek')->render(), "Failed asserting that element renders correctly with 'autocomplete' attribute.", ); } @@ -160,9 +316,9 @@ public function testRenderWithAutocompleteUsingEnum(): void { self::assertSame( << + HTML, - InputWeek::tag()->autocomplete(Autocomplete::ON)->id('inputweek-')->render(), + InputWeek::tag()->autocomplete(Autocomplete::ON)->id('inputweek')->render(), "Failed asserting that element renders correctly with 'autocomplete' attribute using enum.", ); } @@ -171,9 +327,9 @@ public function testRenderWithAutofocus(): void { self::assertSame( << + HTML, - InputWeek::tag()->autofocus(true)->id('inputweek-')->render(), + InputWeek::tag()->autofocus(true)->id('inputweek')->render(), "Failed asserting that element renders correctly with 'autofocus' attribute.", ); } @@ -182,9 +338,9 @@ public function testRenderWithClass(): void { self::assertSame( << + HTML, - InputWeek::tag()->id('inputweek-')->class('week-input')->render(), + InputWeek::tag()->id('inputweek')->class('week-input')->render(), "Failed asserting that element renders correctly with 'class' attribute.", ); } @@ -193,9 +349,9 @@ public function testRenderWithDataAttributes(): void { self::assertSame( << + HTML, - InputWeek::tag()->id('inputweek-')->dataAttributes(['week' => 'value'])->render(), + InputWeek::tag()->id('inputweek')->dataAttributes(['week' => 'value'])->render(), "Failed asserting that element renders correctly with 'dataAttributes()' method.", ); } @@ -204,9 +360,9 @@ public function testRenderWithDefaultConfigurationValues(): void { self::assertSame( << + HTML, - InputWeek::tag(['class' => 'default-class'])->id('inputweek-')->render(), + InputWeek::tag(['class' => 'default-class'])->id('inputweek')->render(), 'Failed asserting that default configuration values are applied correctly.', ); } @@ -215,9 +371,9 @@ public function testRenderWithDefaultProvider(): void { self::assertSame( << + HTML, - InputWeek::tag()->id('inputweek-')->addDefaultProvider(DefaultProvider::class)->render(), + InputWeek::tag()->id('inputweek')->addDefaultProvider(DefaultProvider::class)->render(), 'Failed asserting that default provider is applied correctly.', ); } @@ -226,9 +382,9 @@ public function testRenderWithDefaultValues(): void { self::assertSame( << + HTML, - InputWeek::tag()->id('inputweek-')->render(), + InputWeek::tag()->id('inputweek')->render(), 'Failed asserting that element renders correctly with default values.', ); } @@ -237,9 +393,9 @@ public function testRenderWithDir(): void { self::assertSame( << + HTML, - InputWeek::tag()->id('inputweek-')->dir('ltr')->render(), + InputWeek::tag()->id('inputweek')->dir('ltr')->render(), "Failed asserting that element renders correctly with 'dir' attribute.", ); } @@ -248,9 +404,9 @@ public function testRenderWithDirUsingEnum(): void { self::assertSame( << + HTML, - InputWeek::tag()->id('inputweek-')->dir(Direction::LTR)->render(), + InputWeek::tag()->id('inputweek')->dir(Direction::LTR)->render(), "Failed asserting that element renders correctly with 'dir' attribute using enum.", ); } @@ -259,9 +415,9 @@ public function testRenderWithDisabled(): void { self::assertSame( << + HTML, - InputWeek::tag()->id('inputweek-')->disabled(true)->render(), + InputWeek::tag()->id('inputweek')->disabled(true)->render(), "Failed asserting that element renders correctly with 'disabled' attribute.", ); } @@ -270,13 +426,25 @@ public function testRenderWithForm(): void { self::assertSame( << + HTML, - InputWeek::tag()->form('form-id')->id('inputweek-')->render(), + InputWeek::tag()->form('form-id')->id('inputweek')->render(), "Failed asserting that element renders correctly with 'form' attribute.", ); } + public function testRenderWithGenerateId(): void + { + /** @phpstan-var string $id */ + $id = InputWeek::tag()->getAttribute('id', ''); + + self::assertMatchesRegularExpression( + '/^inputweek-\w+$/', + $id, + 'Failed asserting that element generates an ID when not provided.', + ); + } + public function testRenderWithGlobalDefaultsAreApplied(): void { SimpleFactory::setDefaults(InputWeek::class, ['class' => 'default-class']); @@ -294,9 +462,9 @@ public function testRenderWithHidden(): void { self::assertSame( << + HTML, - InputWeek::tag()->id('inputweek-')->hidden(true)->render(), + InputWeek::tag()->id('inputweek')->hidden(true)->render(), "Failed asserting that element renders correctly with 'hidden' attribute.", ); } @@ -316,9 +484,9 @@ public function testRenderWithLang(): void { self::assertSame( << + HTML, - InputWeek::tag()->id('inputweek-')->lang('en')->render(), + InputWeek::tag()->id('inputweek')->lang('en')->render(), "Failed asserting that element renders correctly with 'lang' attribute.", ); } @@ -327,9 +495,9 @@ public function testRenderWithLangUsingEnum(): void { self::assertSame( << + HTML, - InputWeek::tag()->id('inputweek-')->lang(Language::ENGLISH)->render(), + InputWeek::tag()->id('inputweek')->lang(Language::ENGLISH)->render(), "Failed asserting that element renders correctly with 'lang' attribute using enum.", ); } @@ -338,9 +506,9 @@ public function testRenderWithList(): void { self::assertSame( << + HTML, - InputWeek::tag()->id('inputweek-')->list('weeks')->render(), + InputWeek::tag()->id('inputweek')->list('weeks')->render(), "Failed asserting that element renders correctly with 'list' attribute.", ); } @@ -349,9 +517,9 @@ public function testRenderWithMax(): void { self::assertSame( << + HTML, - InputWeek::tag()->id('inputweek-')->max('2018-W26')->render(), + InputWeek::tag()->id('inputweek')->max('2018-W26')->render(), "Failed asserting that element renders correctly with 'max' attribute.", ); } @@ -360,9 +528,9 @@ public function testRenderWithMin(): void { self::assertSame( << + HTML, - InputWeek::tag()->id('inputweek-')->min('2018-W18')->render(), + InputWeek::tag()->id('inputweek')->min('2018-W18')->render(), "Failed asserting that element renders correctly with 'min' attribute.", ); } @@ -371,10 +539,10 @@ public function testRenderWithMinAndMax(): void { self::assertSame( << + HTML, InputWeek::tag() - ->id('inputweek-') + ->id('inputweek') ->min('2018-W01') ->max('2018-W52') ->render(), @@ -386,9 +554,9 @@ public function testRenderWithName(): void { self::assertSame( << + HTML, - InputWeek::tag()->id('inputweek-')->name('camp-week')->render(), + InputWeek::tag()->id('inputweek')->name('camp-week')->render(), "Failed asserting that element renders correctly with 'name' attribute.", ); } @@ -397,9 +565,9 @@ public function testRenderWithReadonly(): void { self::assertSame( << + HTML, - InputWeek::tag()->id('inputweek-')->readonly(true)->render(), + InputWeek::tag()->id('inputweek')->readonly(true)->render(), "Failed asserting that element renders correctly with 'readonly' attribute.", ); } @@ -408,10 +576,10 @@ public function testRenderWithRemoveAriaAttribute(): void { self::assertSame( << + HTML, InputWeek::tag() - ->id('inputweek-') + ->id('inputweek') ->addAriaAttribute('label', 'Close') ->removeAriaAttribute('label') ->render(), @@ -423,10 +591,10 @@ public function testRenderWithRemoveAttribute(): void { self::assertSame( << + HTML, InputWeek::tag() - ->id('inputweek-') + ->id('inputweek') ->addAttribute('data-test', 'value') ->removeAttribute('data-test') ->render(), @@ -438,10 +606,10 @@ public function testRenderWithRemoveDataAttribute(): void { self::assertSame( << + HTML, InputWeek::tag() - ->id('inputweek-') + ->id('inputweek') ->addDataAttribute('value', 'test') ->removeDataAttribute('value') ->render(), @@ -453,9 +621,9 @@ public function testRenderWithRequired(): void { self::assertSame( << + HTML, - InputWeek::tag()->id('inputweek-')->required(true)->render(), + InputWeek::tag()->id('inputweek')->required(true)->render(), "Failed asserting that element renders correctly with 'required' attribute.", ); } @@ -464,9 +632,9 @@ public function testRenderWithRole(): void { self::assertSame( << + HTML, - InputWeek::tag()->id('inputweek-')->role('textbox')->render(), + InputWeek::tag()->id('inputweek')->role('textbox')->render(), "Failed asserting that element renders correctly with 'role' attribute.", ); } @@ -475,9 +643,9 @@ public function testRenderWithRoleUsingEnum(): void { self::assertSame( << + HTML, - InputWeek::tag()->id('inputweek-')->role(Role::TEXTBOX)->render(), + InputWeek::tag()->id('inputweek')->role(Role::TEXTBOX)->render(), "Failed asserting that element renders correctly with 'role' attribute using enum.", ); } @@ -486,9 +654,9 @@ public function testRenderWithStep(): void { self::assertSame( << + HTML, - InputWeek::tag()->id('inputweek-')->step(2)->render(), + InputWeek::tag()->id('inputweek')->step(2)->render(), "Failed asserting that element renders correctly with 'step' attribute.", ); } @@ -497,9 +665,9 @@ public function testRenderWithStepAny(): void { self::assertSame( << + HTML, - InputWeek::tag()->id('inputweek-')->step('any')->render(), + InputWeek::tag()->id('inputweek')->step('any')->render(), "Failed asserting that element renders correctly with 'step' attribute set to 'any'.", ); } @@ -508,9 +676,9 @@ public function testRenderWithStyle(): void { self::assertSame( << + HTML, - InputWeek::tag()->id('inputweek-')->style('width: 200px;')->render(), + InputWeek::tag()->id('inputweek')->style('width: 200px;')->render(), "Failed asserting that element renders correctly with 'style' attribute.", ); } @@ -519,9 +687,9 @@ public function testRenderWithTabindex(): void { self::assertSame( << + HTML, - InputWeek::tag()->id('inputweek-')->tabIndex(1)->render(), + InputWeek::tag()->id('inputweek')->tabIndex(1)->render(), "Failed asserting that element renders correctly with 'tabindex' attribute.", ); } @@ -530,9 +698,9 @@ public function testRenderWithThemeProvider(): void { self::assertSame( << + HTML, - InputWeek::tag()->id('inputweek-')->addThemeProvider('muted', DefaultThemeProvider::class)->render(), + InputWeek::tag()->id('inputweek')->addThemeProvider('muted', DefaultThemeProvider::class)->render(), "Failed asserting that element renders correctly with 'addThemeProvider()' method.", ); } @@ -541,18 +709,22 @@ public function testRenderWithTitle(): void { self::assertSame( << + HTML, - InputWeek::tag()->id('inputweek-')->title('Select a week')->render(), + InputWeek::tag()->id('inputweek')->title('Select a week')->render(), "Failed asserting that element renders correctly with 'title' attribute.", ); } public function testRenderWithToString(): void { - self::assertStringContainsString( - 'type="week"', - LineEndingNormalizer::normalize((string) InputWeek::tag()), + self::assertSame( + << + HTML, + InputWeek::tag() + ->id(null) + ->render(), "Failed asserting that '__toString()' method renders correctly.", ); } @@ -561,9 +733,9 @@ public function testRenderWithTranslate(): void { self::assertSame( << + HTML, - InputWeek::tag()->id('inputweek-')->translate(false)->render(), + InputWeek::tag()->id('inputweek')->translate(false)->render(), "Failed asserting that element renders correctly with 'translate' attribute.", ); } @@ -572,9 +744,9 @@ public function testRenderWithTranslateUsingEnum(): void { self::assertSame( << + HTML, - InputWeek::tag()->id('inputweek-')->translate(Translate::NO)->render(), + InputWeek::tag()->id('inputweek')->translate(Translate::NO)->render(), "Failed asserting that element renders correctly with 'translate' attribute using enum.", ); } @@ -595,9 +767,9 @@ public function testRenderWithValue(): void { self::assertSame( << + HTML, - InputWeek::tag()->id('inputweek-')->value('2017-W01')->render(), + InputWeek::tag()->id('inputweek')->value('2017-W01')->render(), "Failed asserting that element renders correctly with 'value' attribute.", ); } diff --git a/tests/Heading/H1Test.php b/tests/Heading/H1Test.php index a8c2463..ff07dc6 100644 --- a/tests/Heading/H1Test.php +++ b/tests/Heading/H1Test.php @@ -4,7 +4,6 @@ namespace UIAwesome\Html\Tests\Heading; -use PHPForge\Support\LineEndingNormalizer; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use UIAwesome\Html\Attribute\Values\{ @@ -34,17 +33,16 @@ * @copyright Copyright (C) 2026 Terabytesoftw. * @license https://opensource.org/license/bsd-3-clause BSD 3-Clause License. */ -#[Group('html')] #[Group('heading')] final class H1Test extends TestCase { public function testContentEncodesValues(): void { - $h1 = H1::tag()->content(''); - self::assertSame( '<value>', - $h1->getContent(), + H1::tag() + ->content('') + ->getContent(), "Failed asserting that 'content()' method encodes values correctly.", ); } @@ -62,7 +60,9 @@ public function testGetAttributesReturnsAssignedAttributes(): void { self::assertSame( ['data-test' => 'value'], - H1::tag()->addAttribute('data-test', 'value')->getAttributes(), + H1::tag() + ->addAttribute('data-test', 'value') + ->getAttributes(), "Failed asserting that 'getAttributes()' returns the assigned attributes.", ); } @@ -75,9 +75,9 @@ public function testHtmlDoesNotEncodeValues(): void HTML, - LineEndingNormalizer::normalize( - H1::tag()->html('')->render(), - ), + H1::tag() + ->html('') + ->render(), "Failed asserting that element renders correctly with 'html()' method.", ); } @@ -89,9 +89,9 @@ public function testRenderWithAccesskey(): void

HTML, - LineEndingNormalizer::normalize( - H1::tag()->accesskey('k')->render(), - ), + H1::tag() + ->accesskey('k') + ->render(), "Failed asserting that element renders correctly with 'accesskey' attribute.", ); } @@ -103,9 +103,9 @@ public function testRenderWithAddAriaAttribute(): void

HTML, - LineEndingNormalizer::normalize( - H1::tag()->addAriaAttribute('pressed', true)->render(), - ), + H1::tag() + ->addAriaAttribute('pressed', true) + ->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method.", ); } @@ -117,9 +117,9 @@ public function testRenderWithAddAriaAttributeUsingEnum(): void

HTML, - LineEndingNormalizer::normalize( - H1::tag()->addAriaAttribute(Aria::PRESSED, true)->render(), - ), + H1::tag() + ->addAriaAttribute(Aria::PRESSED, true) + ->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method.", ); } @@ -131,9 +131,9 @@ public function testRenderWithAddAttribute(): void

HTML, - LineEndingNormalizer::normalize( - H1::tag()->addAttribute('data-test', 'value')->render(), - ), + H1::tag() + ->addAttribute('data-test', 'value') + ->render(), "Failed asserting that element renders correctly with 'addAttribute()' method.", ); } @@ -145,9 +145,9 @@ public function testRenderWithAddAttributeUsingEnum(): void

HTML, - LineEndingNormalizer::normalize( - H1::tag()->addAttribute(GlobalAttribute::TITLE, 'value')->render(), - ), + H1::tag() + ->addAttribute(GlobalAttribute::TITLE, 'value') + ->render(), "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", ); } @@ -159,9 +159,9 @@ public function testRenderWithAddDataAttribute(): void

HTML, - LineEndingNormalizer::normalize( - H1::tag()->addDataAttribute('value', 'value')->render(), - ), + H1::tag() + ->addDataAttribute('value', 'value') + ->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method.", ); } @@ -173,9 +173,9 @@ public function testRenderWithAddDataAttributeUsingEnum(): void

HTML, - LineEndingNormalizer::normalize( - H1::tag()->addDataAttribute(Data::VALUE, 'value')->render(), - ), + H1::tag() + ->addDataAttribute(Data::VALUE, 'value') + ->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method.", ); } @@ -187,17 +187,15 @@ public function testRenderWithAriaAttributes(): void

HTML, - LineEndingNormalizer::normalize( - H1::tag() - ->ariaAttributes( - [ - 'controls' => static fn(): string => 'modal-1', - 'hidden' => false, - 'label' => 'Close', - ], - ) - ->render(), - ), + H1::tag() + ->ariaAttributes( + [ + 'controls' => static fn(): string => 'modal-1', + 'hidden' => false, + 'label' => 'Close', + ], + ) + ->render(), "Failed asserting that element renders correctly with 'ariaAttributes()' method.", ); } @@ -209,9 +207,9 @@ public function testRenderWithAttributes(): void

HTML, - LineEndingNormalizer::normalize( - H1::tag()->attributes(['class' => 'value'])->render(), - ), + H1::tag() + ->attributes(['class' => 'value']) + ->render(), "Failed asserting that element renders correctly with 'attributes()' method.", ); } @@ -223,9 +221,9 @@ public function testRenderWithAutofocus(): void

HTML, - LineEndingNormalizer::normalize( - H1::tag()->autofocus(true)->render(), - ), + H1::tag() + ->autofocus(true) + ->render(), "Failed asserting that element renders correctly with 'autofocus' attribute.", ); } @@ -238,9 +236,7 @@ public function testRenderWithBeginEnd(): void Content HTML, - LineEndingNormalizer::normalize( - H1::tag()->begin() . 'Content' . H1::end(), - ), + H1::tag()->begin() . 'Content' . H1::end(), "Failed asserting that element renders correctly with 'begin()' and 'end()' methods.", ); } @@ -252,9 +248,9 @@ public function testRenderWithClass(): void

HTML, - LineEndingNormalizer::normalize( - H1::tag()->class('value')->render(), - ), + H1::tag() + ->class('value') + ->render(), "Failed asserting that element renders correctly with 'class' attribute.", ); } @@ -267,9 +263,9 @@ public function testRenderWithContent(): void value HTML, - LineEndingNormalizer::normalize( - H1::tag()->content('value')->render(), - ), + H1::tag() + ->content('value') + ->render(), 'Failed asserting that element renders correctly with default values.', ); } @@ -281,9 +277,9 @@ public function testRenderWithContentEditable(): void

HTML, - LineEndingNormalizer::normalize( - H1::tag()->contentEditable(true)->render(), - ), + H1::tag() + ->contentEditable(true) + ->render(), "Failed asserting that element renders correctly with 'contentEditable' attribute.", ); } @@ -295,9 +291,9 @@ public function testRenderWithContentEditableUsingEnum(): void

HTML, - LineEndingNormalizer::normalize( - H1::tag()->contentEditable(ContentEditable::TRUE)->render(), - ), + H1::tag() + ->contentEditable(ContentEditable::TRUE) + ->render(), "Failed asserting that element renders correctly with 'contentEditable' attribute using enum.", ); } @@ -309,9 +305,9 @@ public function testRenderWithDataAttributes(): void

HTML, - LineEndingNormalizer::normalize( - H1::tag()->dataAttributes(['value' => 'value'])->render(), - ), + H1::tag() + ->dataAttributes(['value' => 'value']) + ->render(), "Failed asserting that element renders correctly with 'dataAttributes()' method.", ); } @@ -323,9 +319,7 @@ public function testRenderWithDefaultConfigurationValues(): void

HTML, - LineEndingNormalizer::normalize( - H1::tag(['class' => 'default-class'])->render(), - ), + H1::tag(['class' => 'default-class'])->render(), 'Failed asserting that default configuration values are applied correctly.', ); } @@ -337,9 +331,9 @@ public function testRenderWithDefaultProvider(): void

HTML, - LineEndingNormalizer::normalize( - H1::tag()->addDefaultProvider(DefaultProvider::class)->render(), - ), + H1::tag() + ->addDefaultProvider(DefaultProvider::class) + ->render(), 'Failed asserting that default provider is applied correctly.', ); } @@ -351,9 +345,9 @@ public function testRenderWithDir(): void

HTML, - LineEndingNormalizer::normalize( - H1::tag()->dir('ltr')->render(), - ), + H1::tag() + ->dir('ltr') + ->render(), "Failed asserting that element renders correctly with 'dir' attribute.", ); } @@ -365,9 +359,9 @@ public function testRenderWithDirUsingEnum(): void

HTML, - LineEndingNormalizer::normalize( - H1::tag()->dir(Direction::LTR)->render(), - ), + H1::tag() + ->dir(Direction::LTR) + ->render(), "Failed asserting that element renders correctly with 'dir' attribute using enum.", ); } @@ -379,9 +373,9 @@ public function testRenderWithDraggable(): void

HTML, - LineEndingNormalizer::normalize( - H1::tag()->draggable(true)->render(), - ), + H1::tag() + ->draggable(true) + ->render(), "Failed asserting that element renders correctly with 'draggable' attribute.", ); } @@ -393,9 +387,9 @@ public function testRenderWithDraggableUsingEnum(): void

HTML, - LineEndingNormalizer::normalize( - H1::tag()->draggable(Draggable::TRUE)->render(), - ), + H1::tag() + ->draggable(Draggable::TRUE) + ->render(), "Failed asserting that element renders correctly with 'draggable' attribute using enum.", ); } @@ -409,9 +403,7 @@ public function testRenderWithGlobalDefaultsAreApplied(): void

HTML, - LineEndingNormalizer::normalize( - H1::tag()->render(), - ), + H1::tag()->render(), 'Failed asserting that global defaults are applied correctly.', ); @@ -425,9 +417,9 @@ public function testRenderWithHidden(): void

HTML, - LineEndingNormalizer::normalize( - H1::tag()->hidden(true)->render(), - ), + H1::tag() + ->hidden(true) + ->render(), "Failed asserting that element renders correctly with 'hidden' attribute.", ); } @@ -439,9 +431,9 @@ public function testRenderWithId(): void

HTML, - LineEndingNormalizer::normalize( - H1::tag()->id('test-id')->render(), - ), + H1::tag() + ->id('test-id') + ->render(), "Failed asserting that element renders correctly with 'id' attribute.", ); } @@ -453,9 +445,9 @@ public function testRenderWithLang(): void

HTML, - LineEndingNormalizer::normalize( - H1::tag()->lang('es')->render(), - ), + H1::tag() + ->lang('es') + ->render(), "Failed asserting that element renders correctly with 'lang' attribute.", ); } @@ -467,9 +459,9 @@ public function testRenderWithLangUsingEnum(): void

HTML, - LineEndingNormalizer::normalize( - H1::tag()->lang(Language::SPANISH)->render(), - ), + H1::tag() + ->lang(Language::SPANISH) + ->render(), "Failed asserting that element renders correctly with 'lang' attribute using enum.", ); } @@ -481,15 +473,13 @@ public function testRenderWithMicroData(): void

HTML, - LineEndingNormalizer::normalize( - H1::tag() - ->itemId('https://example.com/item') - ->itemProp('name') - ->itemRef('info') - ->itemScope(true) - ->itemType('https://schema.org/Thing') - ->render(), - ), + H1::tag() + ->itemId('https://example.com/item') + ->itemProp('name') + ->itemRef('info') + ->itemScope(true) + ->itemType('https://schema.org/Thing') + ->render(), 'Failed asserting that element renders correctly with microdata attributes.', ); } @@ -501,12 +491,10 @@ public function testRenderWithRemoveAriaAttribute(): void

HTML, - LineEndingNormalizer::normalize( - H1::tag() - ->addAriaAttribute('label', 'Close') - ->removeAriaAttribute('label') - ->render(), - ), + H1::tag() + ->addAriaAttribute('label', 'Close') + ->removeAriaAttribute('label') + ->render(), "Failed asserting that element renders correctly with 'removeAriaAttribute()' method.", ); } @@ -518,12 +506,10 @@ public function testRenderWithRemoveAttribute(): void

HTML, - LineEndingNormalizer::normalize( - H1::tag() - ->addAttribute('data-test', 'value') - ->removeAttribute('data-test') - ->render(), - ), + H1::tag() + ->addAttribute('data-test', 'value') + ->removeAttribute('data-test') + ->render(), "Failed asserting that element renders correctly with 'removeAttribute()' method.", ); } @@ -535,12 +521,10 @@ public function testRenderWithRemoveDataAttribute(): void

HTML, - LineEndingNormalizer::normalize( - H1::tag() - ->addDataAttribute('value', 'test') - ->removeDataAttribute('value') - ->render(), - ), + H1::tag() + ->addDataAttribute('value', 'test') + ->removeDataAttribute('value') + ->render(), "Failed asserting that element renders correctly with 'removeDataAttribute()' method.", ); } @@ -552,9 +536,9 @@ public function testRenderWithRole(): void

HTML, - LineEndingNormalizer::normalize( - H1::tag()->role('banner')->render(), - ), + H1::tag() + ->role('banner') + ->render(), "Failed asserting that element renders correctly with 'role' attribute.", ); } @@ -566,9 +550,9 @@ public function testRenderWithRoleUsingEnum(): void

HTML, - LineEndingNormalizer::normalize( - H1::tag()->role(Role::BANNER)->render(), - ), + H1::tag() + ->role(Role::BANNER) + ->render(), "Failed asserting that element renders correctly with 'role' attribute using enum.", ); } @@ -580,9 +564,9 @@ public function testRenderWithSpellcheck(): void

HTML, - LineEndingNormalizer::normalize( - H1::tag()->spellcheck(true)->render(), - ), + H1::tag() + ->spellcheck(true) + ->render(), "Failed asserting that element renders correctly with 'spellcheck' attribute.", ); } @@ -594,9 +578,9 @@ public function testRenderWithStyle(): void

HTML, - LineEndingNormalizer::normalize( - H1::tag()->style('value')->render(), - ), + H1::tag() + ->style('value') + ->render(), "Failed asserting that element renders correctly with 'style' attribute.", ); } @@ -608,9 +592,9 @@ public function testRenderWithTabindex(): void

HTML, - LineEndingNormalizer::normalize( - H1::tag()->tabIndex(3)->render(), - ), + H1::tag() + ->tabIndex(3) + ->render(), "Failed asserting that element renders correctly with 'tabindex' attribute.", ); } @@ -622,9 +606,9 @@ public function testRenderWithThemeProvider(): void

HTML, - LineEndingNormalizer::normalize( - H1::tag()->addThemeProvider('muted', DefaultThemeProvider::class)->render(), - ), + H1::tag() + ->addThemeProvider('muted', DefaultThemeProvider::class) + ->render(), "Failed asserting that element renders correctly with 'addThemeProvider()' method.", ); } @@ -636,7 +620,9 @@ public function testRenderWithTitle(): void

HTML, - H1::tag()->title('value')->render(), + H1::tag() + ->title('value') + ->render(), "Failed asserting that element renders correctly with 'title' attribute.", ); } @@ -648,9 +634,7 @@ public function testRenderWithToString(): void

HTML, - LineEndingNormalizer::normalize( - (string) H1::tag(), - ), + (string) H1::tag(), "Failed asserting that '__toString()' method renders correctly.", ); } @@ -662,9 +646,9 @@ public function testRenderWithTranslate(): void

HTML, - LineEndingNormalizer::normalize( - H1::tag()->translate(false)->render(), - ), + H1::tag() + ->translate(false) + ->render(), "Failed asserting that element renders correctly with 'translate' attribute.", ); } @@ -676,9 +660,9 @@ public function testRenderWithTranslateUsingEnum(): void

HTML, - LineEndingNormalizer::normalize( - H1::tag()->translate(Translate::NO)->render(), - ), + H1::tag() + ->translate(Translate::NO) + ->render(), "Failed asserting that element renders correctly with 'translate' attribute using enum.", ); } @@ -692,9 +676,7 @@ public function testRenderWithUserOverridesGlobalDefaults(): void

HTML, - LineEndingNormalizer::normalize( - H1::tag(['id' => 'id-user'])->render(), - ), + H1::tag(['id' => 'id-user'])->render(), 'Failed asserting that user-defined attributes override global defaults correctly.', ); diff --git a/tests/Heading/H2Test.php b/tests/Heading/H2Test.php index 90d83d6..9520107 100644 --- a/tests/Heading/H2Test.php +++ b/tests/Heading/H2Test.php @@ -4,7 +4,6 @@ namespace UIAwesome\Html\Tests\Heading; -use PHPForge\Support\LineEndingNormalizer; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use UIAwesome\Html\Attribute\Values\{ @@ -34,17 +33,16 @@ * @copyright Copyright (C) 2026 Terabytesoftw. * @license https://opensource.org/license/bsd-3-clause BSD 3-Clause License. */ -#[Group('html')] #[Group('heading')] final class H2Test extends TestCase { public function testContentEncodesValues(): void { - $h2 = H2::tag()->content(''); - self::assertSame( '<value>', - $h2->getContent(), + H2::tag() + ->content('') + ->getContent(), "Failed asserting that 'content()' method encodes values correctly.", ); } @@ -62,7 +60,9 @@ public function testGetAttributesReturnsAssignedAttributes(): void { self::assertSame( ['data-test' => 'value'], - H2::tag()->addAttribute('data-test', 'value')->getAttributes(), + H2::tag() + ->addAttribute('data-test', 'value') + ->getAttributes(), "Failed asserting that 'getAttributes()' returns the assigned attributes.", ); } @@ -75,9 +75,9 @@ public function testHtmlDoesNotEncodeValues(): void HTML, - LineEndingNormalizer::normalize( - H2::tag()->html('')->render(), - ), + H2::tag() + ->html('') + ->render(), "Failed asserting that element renders correctly with 'html()' method.", ); } @@ -89,9 +89,9 @@ public function testRenderWithAccesskey(): void

HTML, - LineEndingNormalizer::normalize( - H2::tag()->accesskey('k')->render(), - ), + H2::tag() + ->accesskey('k') + ->render(), "Failed asserting that element renders correctly with 'accesskey' attribute.", ); } @@ -103,9 +103,9 @@ public function testRenderWithAddAriaAttribute(): void

HTML, - LineEndingNormalizer::normalize( - H2::tag()->addAriaAttribute('pressed', true)->render(), - ), + H2::tag() + ->addAriaAttribute('pressed', true) + ->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method.", ); } @@ -117,9 +117,9 @@ public function testRenderWithAddAriaAttributeUsingEnum(): void

HTML, - LineEndingNormalizer::normalize( - H2::tag()->addAriaAttribute(Aria::PRESSED, true)->render(), - ), + H2::tag() + ->addAriaAttribute(Aria::PRESSED, true) + ->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method.", ); } @@ -131,9 +131,9 @@ public function testRenderWithAddAttribute(): void

HTML, - LineEndingNormalizer::normalize( - H2::tag()->addAttribute('data-test', 'value')->render(), - ), + H2::tag() + ->addAttribute('data-test', 'value') + ->render(), "Failed asserting that element renders correctly with 'addAttribute()' method.", ); } @@ -145,9 +145,9 @@ public function testRenderWithAddAttributeUsingEnum(): void

HTML, - LineEndingNormalizer::normalize( - H2::tag()->addAttribute(GlobalAttribute::TITLE, 'value')->render(), - ), + H2::tag() + ->addAttribute(GlobalAttribute::TITLE, 'value') + ->render(), "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", ); } @@ -159,9 +159,9 @@ public function testRenderWithAddDataAttribute(): void

HTML, - LineEndingNormalizer::normalize( - H2::tag()->addDataAttribute('value', 'value')->render(), - ), + H2::tag() + ->addDataAttribute('value', 'value') + ->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method.", ); } @@ -173,9 +173,9 @@ public function testRenderWithAddDataAttributeUsingEnum(): void

HTML, - LineEndingNormalizer::normalize( - H2::tag()->addDataAttribute(Data::VALUE, 'value')->render(), - ), + H2::tag() + ->addDataAttribute(Data::VALUE, 'value') + ->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method.", ); } @@ -187,17 +187,15 @@ public function testRenderWithAriaAttributes(): void

HTML, - LineEndingNormalizer::normalize( - H2::tag() - ->ariaAttributes( - [ - 'controls' => static fn(): string => 'modal-1', - 'hidden' => false, - 'label' => 'Close', - ], - ) - ->render(), - ), + H2::tag() + ->ariaAttributes( + [ + 'controls' => static fn(): string => 'modal-1', + 'hidden' => false, + 'label' => 'Close', + ], + ) + ->render(), "Failed asserting that element renders correctly with 'ariaAttributes()' method.", ); } @@ -209,9 +207,9 @@ public function testRenderWithAttributes(): void

HTML, - LineEndingNormalizer::normalize( - H2::tag()->attributes(['class' => 'value'])->render(), - ), + H2::tag() + ->attributes(['class' => 'value']) + ->render(), "Failed asserting that element renders correctly with 'attributes()' method.", ); } @@ -223,9 +221,9 @@ public function testRenderWithAutofocus(): void

HTML, - LineEndingNormalizer::normalize( - H2::tag()->autofocus(true)->render(), - ), + H2::tag() + ->autofocus(true) + ->render(), "Failed asserting that element renders correctly with 'autofocus' attribute.", ); } @@ -238,9 +236,7 @@ public function testRenderWithBeginEnd(): void Content HTML, - LineEndingNormalizer::normalize( - H2::tag()->begin() . 'Content' . H2::end(), - ), + H2::tag()->begin() . 'Content' . H2::end(), "Failed asserting that element renders correctly with 'begin()' and 'end()' methods.", ); } @@ -252,9 +248,9 @@ public function testRenderWithClass(): void

HTML, - LineEndingNormalizer::normalize( - H2::tag()->class('value')->render(), - ), + H2::tag() + ->class('value') + ->render(), "Failed asserting that element renders correctly with 'class' attribute.", ); } @@ -267,9 +263,9 @@ public function testRenderWithContent(): void value HTML, - LineEndingNormalizer::normalize( - H2::tag()->content('value')->render(), - ), + H2::tag() + ->content('value') + ->render(), 'Failed asserting that element renders correctly with default values.', ); } @@ -281,9 +277,9 @@ public function testRenderWithContentEditable(): void

HTML, - LineEndingNormalizer::normalize( - H2::tag()->contentEditable(true)->render(), - ), + H2::tag() + ->contentEditable(true) + ->render(), "Failed asserting that element renders correctly with 'contentEditable' attribute.", ); } @@ -295,9 +291,9 @@ public function testRenderWithContentEditableUsingEnum(): void

HTML, - LineEndingNormalizer::normalize( - H2::tag()->contentEditable(ContentEditable::TRUE)->render(), - ), + H2::tag() + ->contentEditable(ContentEditable::TRUE) + ->render(), "Failed asserting that element renders correctly with 'contentEditable' attribute using enum.", ); } @@ -309,9 +305,9 @@ public function testRenderWithDataAttributes(): void

HTML, - LineEndingNormalizer::normalize( - H2::tag()->dataAttributes(['value' => 'value'])->render(), - ), + H2::tag() + ->dataAttributes(['value' => 'value']) + ->render(), "Failed asserting that element renders correctly with 'dataAttributes()' method.", ); } @@ -323,9 +319,7 @@ public function testRenderWithDefaultConfigurationValues(): void

HTML, - LineEndingNormalizer::normalize( - H2::tag(['class' => 'default-class'])->render(), - ), + H2::tag(['class' => 'default-class'])->render(), 'Failed asserting that default configuration values are applied correctly.', ); } @@ -337,9 +331,9 @@ public function testRenderWithDefaultProvider(): void

HTML, - LineEndingNormalizer::normalize( - H2::tag()->addDefaultProvider(DefaultProvider::class)->render(), - ), + H2::tag() + ->addDefaultProvider(DefaultProvider::class) + ->render(), 'Failed asserting that default provider is applied correctly.', ); } @@ -351,9 +345,9 @@ public function testRenderWithDir(): void

HTML, - LineEndingNormalizer::normalize( - H2::tag()->dir('ltr')->render(), - ), + H2::tag() + ->dir('ltr') + ->render(), "Failed asserting that element renders correctly with 'dir' attribute.", ); } @@ -365,9 +359,9 @@ public function testRenderWithDirUsingEnum(): void

HTML, - LineEndingNormalizer::normalize( - H2::tag()->dir(Direction::LTR)->render(), - ), + H2::tag() + ->dir(Direction::LTR) + ->render(), "Failed asserting that element renders correctly with 'dir' attribute using enum.", ); } @@ -379,9 +373,9 @@ public function testRenderWithDraggable(): void

HTML, - LineEndingNormalizer::normalize( - H2::tag()->draggable(true)->render(), - ), + H2::tag() + ->draggable(true) + ->render(), "Failed asserting that element renders correctly with 'draggable' attribute.", ); } @@ -393,9 +387,9 @@ public function testRenderWithDraggableUsingEnum(): void

HTML, - LineEndingNormalizer::normalize( - H2::tag()->draggable(Draggable::TRUE)->render(), - ), + H2::tag() + ->draggable(Draggable::TRUE) + ->render(), "Failed asserting that element renders correctly with 'draggable' attribute using enum.", ); } @@ -409,9 +403,7 @@ public function testRenderWithGlobalDefaultsAreApplied(): void

HTML, - LineEndingNormalizer::normalize( - H2::tag()->render(), - ), + H2::tag()->render(), 'Failed asserting that global defaults are applied correctly.', ); @@ -425,9 +417,9 @@ public function testRenderWithHidden(): void HTML, - LineEndingNormalizer::normalize( - H2::tag()->hidden(true)->render(), - ), + H2::tag() + ->hidden(true) + ->render(), "Failed asserting that element renders correctly with 'hidden' attribute.", ); } @@ -439,9 +431,9 @@ public function testRenderWithId(): void

HTML, - LineEndingNormalizer::normalize( - H2::tag()->id('test-id')->render(), - ), + H2::tag() + ->id('test-id') + ->render(), "Failed asserting that element renders correctly with 'id' attribute.", ); } @@ -453,9 +445,9 @@ public function testRenderWithLang(): void

HTML, - LineEndingNormalizer::normalize( - H2::tag()->lang('es')->render(), - ), + H2::tag() + ->lang('es') + ->render(), "Failed asserting that element renders correctly with 'lang' attribute.", ); } @@ -467,9 +459,9 @@ public function testRenderWithLangUsingEnum(): void

HTML, - LineEndingNormalizer::normalize( - H2::tag()->lang(Language::SPANISH)->render(), - ), + H2::tag() + ->lang(Language::SPANISH) + ->render(), "Failed asserting that element renders correctly with 'lang' attribute using enum.", ); } @@ -481,15 +473,13 @@ public function testRenderWithMicroData(): void

HTML, - LineEndingNormalizer::normalize( - H2::tag() - ->itemId('https://example.com/item') - ->itemProp('name') - ->itemRef('info') - ->itemScope(true) - ->itemType('https://schema.org/Thing') - ->render(), - ), + H2::tag() + ->itemId('https://example.com/item') + ->itemProp('name') + ->itemRef('info') + ->itemScope(true) + ->itemType('https://schema.org/Thing') + ->render(), 'Failed asserting that element renders correctly with microdata attributes.', ); } @@ -501,12 +491,10 @@ public function testRenderWithRemoveAriaAttribute(): void

HTML, - LineEndingNormalizer::normalize( - H2::tag() - ->addAriaAttribute('label', 'Close') - ->removeAriaAttribute('label') - ->render(), - ), + H2::tag() + ->addAriaAttribute('label', 'Close') + ->removeAriaAttribute('label') + ->render(), "Failed asserting that element renders correctly with 'removeAriaAttribute()' method.", ); } @@ -518,12 +506,10 @@ public function testRenderWithRemoveAttribute(): void

HTML, - LineEndingNormalizer::normalize( - H2::tag() - ->addAttribute('data-test', 'value') - ->removeAttribute('data-test') - ->render(), - ), + H2::tag() + ->addAttribute('data-test', 'value') + ->removeAttribute('data-test') + ->render(), "Failed asserting that element renders correctly with 'removeAttribute()' method.", ); } @@ -535,12 +521,10 @@ public function testRenderWithRemoveDataAttribute(): void

HTML, - LineEndingNormalizer::normalize( - H2::tag() - ->addDataAttribute('value', 'test') - ->removeDataAttribute('value') - ->render(), - ), + H2::tag() + ->addDataAttribute('value', 'test') + ->removeDataAttribute('value') + ->render(), "Failed asserting that element renders correctly with 'removeDataAttribute()' method.", ); } @@ -552,9 +536,9 @@ public function testRenderWithRole(): void

HTML, - LineEndingNormalizer::normalize( - H2::tag()->role('banner')->render(), - ), + H2::tag() + ->role('banner') + ->render(), "Failed asserting that element renders correctly with 'role' attribute.", ); } @@ -566,9 +550,9 @@ public function testRenderWithRoleUsingEnum(): void

HTML, - LineEndingNormalizer::normalize( - H2::tag()->role(Role::BANNER)->render(), - ), + H2::tag() + ->role(Role::BANNER) + ->render(), "Failed asserting that element renders correctly with 'role' attribute using enum.", ); } @@ -580,9 +564,7 @@ public function testRenderWithSpellcheck(): void

HTML, - LineEndingNormalizer::normalize( - H2::tag()->spellcheck(true)->render(), - ), + H2::tag()->spellcheck(true)->render(), "Failed asserting that element renders correctly with 'spellcheck' attribute.", ); } @@ -594,9 +576,9 @@ public function testRenderWithStyle(): void

HTML, - LineEndingNormalizer::normalize( - H2::tag()->style('value')->render(), - ), + H2::tag() + ->style('value') + ->render(), "Failed asserting that element renders correctly with 'style' attribute.", ); } @@ -608,9 +590,9 @@ public function testRenderWithTabindex(): void

HTML, - LineEndingNormalizer::normalize( - H2::tag()->tabIndex(3)->render(), - ), + H2::tag() + ->tabIndex(3) + ->render(), "Failed asserting that element renders correctly with 'tabindex' attribute.", ); } @@ -622,9 +604,9 @@ public function testRenderWithThemeProvider(): void

HTML, - LineEndingNormalizer::normalize( - H2::tag()->addThemeProvider('muted', DefaultThemeProvider::class)->render(), - ), + H2::tag() + ->addThemeProvider('muted', DefaultThemeProvider::class) + ->render(), "Failed asserting that element renders correctly with 'addThemeProvider()' method.", ); } @@ -636,7 +618,9 @@ public function testRenderWithTitle(): void

HTML, - H2::tag()->title('value')->render(), + H2::tag() + ->title('value') + ->render(), "Failed asserting that element renders correctly with 'title' attribute.", ); } @@ -648,9 +632,7 @@ public function testRenderWithToString(): void

HTML, - LineEndingNormalizer::normalize( - (string) H2::tag(), - ), + (string) H2::tag(), "Failed asserting that '__toString()' method renders correctly.", ); } @@ -662,9 +644,9 @@ public function testRenderWithTranslate(): void

HTML, - LineEndingNormalizer::normalize( - H2::tag()->translate(false)->render(), - ), + H2::tag() + ->translate(false) + ->render(), "Failed asserting that element renders correctly with 'translate' attribute.", ); } @@ -676,9 +658,9 @@ public function testRenderWithTranslateUsingEnum(): void

HTML, - LineEndingNormalizer::normalize( - H2::tag()->translate(Translate::NO)->render(), - ), + H2::tag() + ->translate(Translate::NO) + ->render(), "Failed asserting that element renders correctly with 'translate' attribute using enum.", ); } @@ -692,9 +674,7 @@ public function testRenderWithUserOverridesGlobalDefaults(): void

HTML, - LineEndingNormalizer::normalize( - H2::tag(['id' => 'id-user'])->render(), - ), + H2::tag(['id' => 'id-user'])->render(), 'Failed asserting that user-defined attributes override global defaults correctly.', ); diff --git a/tests/Heading/H3Test.php b/tests/Heading/H3Test.php index ed9cfa6..1896c43 100644 --- a/tests/Heading/H3Test.php +++ b/tests/Heading/H3Test.php @@ -4,7 +4,6 @@ namespace UIAwesome\Html\Tests\Heading; -use PHPForge\Support\LineEndingNormalizer; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use UIAwesome\Html\Attribute\Values\{ @@ -34,17 +33,16 @@ * @copyright Copyright (C) 2026 Terabytesoftw. * @license https://opensource.org/license/bsd-3-clause BSD 3-Clause License. */ -#[Group('html')] #[Group('heading')] final class H3Test extends TestCase { public function testContentEncodesValues(): void { - $h3 = H3::tag()->content(''); - self::assertSame( '<value>', - $h3->getContent(), + H3::tag() + ->content('') + ->getContent(), "Failed asserting that 'content()' method encodes values correctly.", ); } @@ -62,7 +60,9 @@ public function testGetAttributesReturnsAssignedAttributes(): void { self::assertSame( ['data-test' => 'value'], - H3::tag()->addAttribute('data-test', 'value')->getAttributes(), + H3::tag() + ->addAttribute('data-test', 'value') + ->getAttributes(), "Failed asserting that 'getAttributes()' returns the assigned attributes.", ); } @@ -75,9 +75,9 @@ public function testHtmlDoesNotEncodeValues(): void HTML, - LineEndingNormalizer::normalize( - H3::tag()->html('')->render(), - ), + H3::tag() + ->html('') + ->render(), "Failed asserting that element renders correctly with 'html()' method.", ); } @@ -89,9 +89,9 @@ public function testRenderWithAccesskey(): void

HTML, - LineEndingNormalizer::normalize( - H3::tag()->accesskey('k')->render(), - ), + H3::tag() + ->accesskey('k') + ->render(), "Failed asserting that element renders correctly with 'accesskey' attribute.", ); } @@ -103,9 +103,9 @@ public function testRenderWithAddAriaAttribute(): void

HTML, - LineEndingNormalizer::normalize( - H3::tag()->addAriaAttribute('pressed', true)->render(), - ), + H3::tag() + ->addAriaAttribute('pressed', true) + ->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method.", ); } @@ -117,9 +117,9 @@ public function testRenderWithAddAriaAttributeUsingEnum(): void

HTML, - LineEndingNormalizer::normalize( - H3::tag()->addAriaAttribute(Aria::PRESSED, true)->render(), - ), + H3::tag() + ->addAriaAttribute(Aria::PRESSED, true) + ->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method.", ); } @@ -131,9 +131,9 @@ public function testRenderWithAddAttribute(): void

HTML, - LineEndingNormalizer::normalize( - H3::tag()->addAttribute('data-test', 'value')->render(), - ), + H3::tag() + ->addAttribute('data-test', 'value') + ->render(), "Failed asserting that element renders correctly with 'addAttribute()' method.", ); } @@ -145,9 +145,9 @@ public function testRenderWithAddAttributeUsingEnum(): void

HTML, - LineEndingNormalizer::normalize( - H3::tag()->addAttribute(GlobalAttribute::TITLE, 'value')->render(), - ), + H3::tag() + ->addAttribute(GlobalAttribute::TITLE, 'value') + ->render(), "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", ); } @@ -159,9 +159,9 @@ public function testRenderWithAddDataAttribute(): void

HTML, - LineEndingNormalizer::normalize( - H3::tag()->addDataAttribute('value', 'value')->render(), - ), + H3::tag() + ->addDataAttribute('value', 'value') + ->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method.", ); } @@ -173,9 +173,9 @@ public function testRenderWithAddDataAttributeUsingEnum(): void

HTML, - LineEndingNormalizer::normalize( - H3::tag()->addDataAttribute(Data::VALUE, 'value')->render(), - ), + H3::tag() + ->addDataAttribute(Data::VALUE, 'value') + ->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method.", ); } @@ -187,17 +187,15 @@ public function testRenderWithAriaAttributes(): void

HTML, - LineEndingNormalizer::normalize( - H3::tag() - ->ariaAttributes( - [ - 'controls' => static fn(): string => 'modal-1', - 'hidden' => false, - 'label' => 'Close', - ], - ) - ->render(), - ), + H3::tag() + ->ariaAttributes( + [ + 'controls' => static fn(): string => 'modal-1', + 'hidden' => false, + 'label' => 'Close', + ], + ) + ->render(), "Failed asserting that element renders correctly with 'ariaAttributes()' method.", ); } @@ -209,9 +207,9 @@ public function testRenderWithAttributes(): void

HTML, - LineEndingNormalizer::normalize( - H3::tag()->attributes(['class' => 'value'])->render(), - ), + H3::tag() + ->attributes(['class' => 'value']) + ->render(), "Failed asserting that element renders correctly with 'attributes()' method.", ); } @@ -223,9 +221,9 @@ public function testRenderWithAutofocus(): void

HTML, - LineEndingNormalizer::normalize( - H3::tag()->autofocus(true)->render(), - ), + H3::tag() + ->autofocus(true) + ->render(), "Failed asserting that element renders correctly with 'autofocus' attribute.", ); } @@ -238,9 +236,7 @@ public function testRenderWithBeginEnd(): void Content HTML, - LineEndingNormalizer::normalize( - H3::tag()->begin() . 'Content' . H3::end(), - ), + H3::tag()->begin() . 'Content' . H3::end(), "Failed asserting that element renders correctly with 'begin()' and 'end()' methods.", ); } @@ -252,9 +248,9 @@ public function testRenderWithClass(): void

HTML, - LineEndingNormalizer::normalize( - H3::tag()->class('value')->render(), - ), + H3::tag() + ->class('value') + ->render(), "Failed asserting that element renders correctly with 'class' attribute.", ); } @@ -267,9 +263,9 @@ public function testRenderWithContent(): void value HTML, - LineEndingNormalizer::normalize( - H3::tag()->content('value')->render(), - ), + H3::tag() + ->content('value') + ->render(), 'Failed asserting that element renders correctly with default values.', ); } @@ -281,9 +277,9 @@ public function testRenderWithContentEditable(): void

HTML, - LineEndingNormalizer::normalize( - H3::tag()->contentEditable(true)->render(), - ), + H3::tag() + ->contentEditable(true) + ->render(), "Failed asserting that element renders correctly with 'contentEditable' attribute.", ); } @@ -295,9 +291,9 @@ public function testRenderWithContentEditableUsingEnum(): void

HTML, - LineEndingNormalizer::normalize( - H3::tag()->contentEditable(ContentEditable::TRUE)->render(), - ), + H3::tag() + ->contentEditable(ContentEditable::TRUE) + ->render(), "Failed asserting that element renders correctly with 'contentEditable' attribute using enum.", ); } @@ -309,9 +305,9 @@ public function testRenderWithDataAttributes(): void

HTML, - LineEndingNormalizer::normalize( - H3::tag()->dataAttributes(['value' => 'value'])->render(), - ), + H3::tag() + ->dataAttributes(['value' => 'value']) + ->render(), "Failed asserting that element renders correctly with 'dataAttributes()' method.", ); } @@ -323,9 +319,7 @@ public function testRenderWithDefaultConfigurationValues(): void

HTML, - LineEndingNormalizer::normalize( - H3::tag(['class' => 'default-class'])->render(), - ), + H3::tag(['class' => 'default-class'])->render(), 'Failed asserting that default configuration values are applied correctly.', ); } @@ -337,9 +331,9 @@ public function testRenderWithDefaultProvider(): void

HTML, - LineEndingNormalizer::normalize( - H3::tag()->addDefaultProvider(DefaultProvider::class)->render(), - ), + H3::tag() + ->addDefaultProvider(DefaultProvider::class) + ->render(), 'Failed asserting that default provider is applied correctly.', ); } @@ -351,9 +345,9 @@ public function testRenderWithDir(): void

HTML, - LineEndingNormalizer::normalize( - H3::tag()->dir('ltr')->render(), - ), + H3::tag() + ->dir('ltr') + ->render(), "Failed asserting that element renders correctly with 'dir' attribute.", ); } @@ -365,9 +359,9 @@ public function testRenderWithDirUsingEnum(): void

HTML, - LineEndingNormalizer::normalize( - H3::tag()->dir(Direction::LTR)->render(), - ), + H3::tag() + ->dir(Direction::LTR) + ->render(), "Failed asserting that element renders correctly with 'dir' attribute using enum.", ); } @@ -379,9 +373,9 @@ public function testRenderWithDraggable(): void

HTML, - LineEndingNormalizer::normalize( - H3::tag()->draggable(true)->render(), - ), + H3::tag() + ->draggable(true) + ->render(), "Failed asserting that element renders correctly with 'draggable' attribute.", ); } @@ -393,9 +387,9 @@ public function testRenderWithDraggableUsingEnum(): void

HTML, - LineEndingNormalizer::normalize( - H3::tag()->draggable(Draggable::TRUE)->render(), - ), + H3::tag() + ->draggable(Draggable::TRUE) + ->render(), "Failed asserting that element renders correctly with 'draggable' attribute using enum.", ); } @@ -409,9 +403,7 @@ public function testRenderWithGlobalDefaultsAreApplied(): void

HTML, - LineEndingNormalizer::normalize( - H3::tag()->render(), - ), + H3::tag()->render(), 'Failed asserting that global defaults are applied correctly.', ); @@ -425,9 +417,9 @@ public function testRenderWithHidden(): void HTML, - LineEndingNormalizer::normalize( - H3::tag()->hidden(true)->render(), - ), + H3::tag() + ->hidden(true) + ->render(), "Failed asserting that element renders correctly with 'hidden' attribute.", ); } @@ -439,9 +431,9 @@ public function testRenderWithId(): void

HTML, - LineEndingNormalizer::normalize( - H3::tag()->id('test-id')->render(), - ), + H3::tag() + ->id('test-id') + ->render(), "Failed asserting that element renders correctly with 'id' attribute.", ); } @@ -453,9 +445,9 @@ public function testRenderWithLang(): void

HTML, - LineEndingNormalizer::normalize( - H3::tag()->lang('es')->render(), - ), + H3::tag() + ->lang('es') + ->render(), "Failed asserting that element renders correctly with 'lang' attribute.", ); } @@ -467,9 +459,9 @@ public function testRenderWithLangUsingEnum(): void

HTML, - LineEndingNormalizer::normalize( - H3::tag()->lang(Language::SPANISH)->render(), - ), + H3::tag() + ->lang(Language::SPANISH) + ->render(), "Failed asserting that element renders correctly with 'lang' attribute using enum.", ); } @@ -481,15 +473,13 @@ public function testRenderWithMicroData(): void

HTML, - LineEndingNormalizer::normalize( - H3::tag() - ->itemId('https://example.com/item') - ->itemProp('name') - ->itemRef('info') - ->itemScope(true) - ->itemType('https://schema.org/Thing') - ->render(), - ), + H3::tag() + ->itemId('https://example.com/item') + ->itemProp('name') + ->itemRef('info') + ->itemScope(true) + ->itemType('https://schema.org/Thing') + ->render(), 'Failed asserting that element renders correctly with microdata attributes.', ); } @@ -501,12 +491,10 @@ public function testRenderWithRemoveAriaAttribute(): void

HTML, - LineEndingNormalizer::normalize( - H3::tag() - ->addAriaAttribute('label', 'Close') - ->removeAriaAttribute('label') - ->render(), - ), + H3::tag() + ->addAriaAttribute('label', 'Close') + ->removeAriaAttribute('label') + ->render(), "Failed asserting that element renders correctly with 'removeAriaAttribute()' method.", ); } @@ -518,12 +506,10 @@ public function testRenderWithRemoveAttribute(): void

HTML, - LineEndingNormalizer::normalize( - H3::tag() - ->addAttribute('data-test', 'value') - ->removeAttribute('data-test') - ->render(), - ), + H3::tag() + ->addAttribute('data-test', 'value') + ->removeAttribute('data-test') + ->render(), "Failed asserting that element renders correctly with 'removeAttribute()' method.", ); } @@ -535,12 +521,10 @@ public function testRenderWithRemoveDataAttribute(): void

HTML, - LineEndingNormalizer::normalize( - H3::tag() - ->addDataAttribute('value', 'test') - ->removeDataAttribute('value') - ->render(), - ), + H3::tag() + ->addDataAttribute('value', 'test') + ->removeDataAttribute('value') + ->render(), "Failed asserting that element renders correctly with 'removeDataAttribute()' method.", ); } @@ -552,9 +536,9 @@ public function testRenderWithRole(): void

HTML, - LineEndingNormalizer::normalize( - H3::tag()->role('banner')->render(), - ), + H3::tag() + ->role('banner') + ->render(), "Failed asserting that element renders correctly with 'role' attribute.", ); } @@ -566,9 +550,9 @@ public function testRenderWithRoleUsingEnum(): void

HTML, - LineEndingNormalizer::normalize( - H3::tag()->role(Role::BANNER)->render(), - ), + H3::tag() + ->role(Role::BANNER) + ->render(), "Failed asserting that element renders correctly with 'role' attribute using enum.", ); } @@ -580,9 +564,9 @@ public function testRenderWithSpellcheck(): void

HTML, - LineEndingNormalizer::normalize( - H3::tag()->spellcheck(true)->render(), - ), + H3::tag() + ->spellcheck(true) + ->render(), "Failed asserting that element renders correctly with 'spellcheck' attribute.", ); } @@ -594,9 +578,9 @@ public function testRenderWithStyle(): void

HTML, - LineEndingNormalizer::normalize( - H3::tag()->style('value')->render(), - ), + H3::tag() + ->style('value') + ->render(), "Failed asserting that element renders correctly with 'style' attribute.", ); } @@ -608,9 +592,9 @@ public function testRenderWithTabindex(): void

HTML, - LineEndingNormalizer::normalize( - H3::tag()->tabIndex(3)->render(), - ), + H3::tag() + ->tabIndex(3) + ->render(), "Failed asserting that element renders correctly with 'tabindex' attribute.", ); } @@ -622,9 +606,9 @@ public function testRenderWithThemeProvider(): void

HTML, - LineEndingNormalizer::normalize( - H3::tag()->addThemeProvider('muted', DefaultThemeProvider::class)->render(), - ), + H3::tag() + ->addThemeProvider('muted', DefaultThemeProvider::class) + ->render(), "Failed asserting that element renders correctly with 'addThemeProvider()' method.", ); } @@ -636,7 +620,9 @@ public function testRenderWithTitle(): void

HTML, - H3::tag()->title('value')->render(), + H3::tag() + ->title('value') + ->render(), "Failed asserting that element renders correctly with 'title' attribute.", ); } @@ -648,9 +634,7 @@ public function testRenderWithToString(): void

HTML, - LineEndingNormalizer::normalize( - (string) H3::tag(), - ), + (string) H3::tag(), "Failed asserting that '__toString()' method renders correctly.", ); } @@ -662,9 +646,9 @@ public function testRenderWithTranslate(): void

HTML, - LineEndingNormalizer::normalize( - H3::tag()->translate(false)->render(), - ), + H3::tag() + ->translate(false) + ->render(), "Failed asserting that element renders correctly with 'translate' attribute.", ); } @@ -676,9 +660,9 @@ public function testRenderWithTranslateUsingEnum(): void

HTML, - LineEndingNormalizer::normalize( - H3::tag()->translate(Translate::NO)->render(), - ), + H3::tag() + ->translate(Translate::NO) + ->render(), "Failed asserting that element renders correctly with 'translate' attribute using enum.", ); } @@ -692,9 +676,7 @@ public function testRenderWithUserOverridesGlobalDefaults(): void

HTML, - LineEndingNormalizer::normalize( - H3::tag(['id' => 'id-user'])->render(), - ), + H3::tag(['id' => 'id-user'])->render(), 'Failed asserting that user-defined attributes override global defaults correctly.', ); diff --git a/tests/Heading/H4Test.php b/tests/Heading/H4Test.php index 3551cbd..f7e16a6 100644 --- a/tests/Heading/H4Test.php +++ b/tests/Heading/H4Test.php @@ -4,7 +4,6 @@ namespace UIAwesome\Html\Tests\Heading; -use PHPForge\Support\LineEndingNormalizer; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use UIAwesome\Html\Attribute\Values\{ @@ -34,17 +33,16 @@ * @copyright Copyright (C) 2026 Terabytesoftw. * @license https://opensource.org/license/bsd-3-clause BSD 3-Clause License. */ -#[Group('html')] #[Group('heading')] final class H4Test extends TestCase { public function testContentEncodesValues(): void { - $h4 = H4::tag()->content(''); - self::assertSame( '<value>', - $h4->getContent(), + H4::tag() + ->content('') + ->getContent(), "Failed asserting that 'content()' method encodes values correctly.", ); } @@ -62,7 +60,9 @@ public function testGetAttributesReturnsAssignedAttributes(): void { self::assertSame( ['data-test' => 'value'], - H4::tag()->addAttribute('data-test', 'value')->getAttributes(), + H4::tag() + ->addAttribute('data-test', 'value') + ->getAttributes(), "Failed asserting that 'getAttributes()' returns the assigned attributes.", ); } @@ -75,9 +75,9 @@ public function testHtmlDoesNotEncodeValues(): void HTML, - LineEndingNormalizer::normalize( - H4::tag()->html('')->render(), - ), + H4::tag() + ->html('') + ->render(), "Failed asserting that element renders correctly with 'html()' method.", ); } @@ -89,9 +89,9 @@ public function testRenderWithAccesskey(): void

HTML, - LineEndingNormalizer::normalize( - H4::tag()->accesskey('k')->render(), - ), + H4::tag() + ->accesskey('k') + ->render(), "Failed asserting that element renders correctly with 'accesskey' attribute.", ); } @@ -103,9 +103,9 @@ public function testRenderWithAddAriaAttribute(): void

HTML, - LineEndingNormalizer::normalize( - H4::tag()->addAriaAttribute('pressed', true)->render(), - ), + H4::tag() + ->addAriaAttribute('pressed', true) + ->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method.", ); } @@ -117,9 +117,9 @@ public function testRenderWithAddAriaAttributeUsingEnum(): void

HTML, - LineEndingNormalizer::normalize( - H4::tag()->addAriaAttribute(Aria::PRESSED, true)->render(), - ), + H4::tag() + ->addAriaAttribute(Aria::PRESSED, true) + ->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method.", ); } @@ -131,9 +131,9 @@ public function testRenderWithAddAttribute(): void

HTML, - LineEndingNormalizer::normalize( - H4::tag()->addAttribute('data-test', 'value')->render(), - ), + H4::tag() + ->addAttribute('data-test', 'value') + ->render(), "Failed asserting that element renders correctly with 'addAttribute()' method.", ); } @@ -145,9 +145,9 @@ public function testRenderWithAddAttributeUsingEnum(): void

HTML, - LineEndingNormalizer::normalize( - H4::tag()->addAttribute(GlobalAttribute::TITLE, 'value')->render(), - ), + H4::tag() + ->addAttribute(GlobalAttribute::TITLE, 'value') + ->render(), "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", ); } @@ -159,9 +159,9 @@ public function testRenderWithAddDataAttribute(): void

HTML, - LineEndingNormalizer::normalize( - H4::tag()->addDataAttribute('value', 'value')->render(), - ), + H4::tag() + ->addDataAttribute('value', 'value') + ->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method.", ); } @@ -173,9 +173,9 @@ public function testRenderWithAddDataAttributeUsingEnum(): void

HTML, - LineEndingNormalizer::normalize( - H4::tag()->addDataAttribute(Data::VALUE, 'value')->render(), - ), + H4::tag() + ->addDataAttribute(Data::VALUE, 'value') + ->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method.", ); } @@ -187,17 +187,15 @@ public function testRenderWithAriaAttributes(): void

HTML, - LineEndingNormalizer::normalize( - H4::tag() - ->ariaAttributes( - [ - 'controls' => static fn(): string => 'modal-1', - 'hidden' => false, - 'label' => 'Close', - ], - ) - ->render(), - ), + H4::tag() + ->ariaAttributes( + [ + 'controls' => static fn(): string => 'modal-1', + 'hidden' => false, + 'label' => 'Close', + ], + ) + ->render(), "Failed asserting that element renders correctly with 'ariaAttributes()' method.", ); } @@ -209,9 +207,9 @@ public function testRenderWithAttributes(): void

HTML, - LineEndingNormalizer::normalize( - H4::tag()->attributes(['class' => 'value'])->render(), - ), + H4::tag() + ->attributes(['class' => 'value']) + ->render(), "Failed asserting that element renders correctly with 'attributes()' method.", ); } @@ -223,9 +221,9 @@ public function testRenderWithAutofocus(): void

HTML, - LineEndingNormalizer::normalize( - H4::tag()->autofocus(true)->render(), - ), + H4::tag() + ->autofocus(true) + ->render(), "Failed asserting that element renders correctly with 'autofocus' attribute.", ); } @@ -238,9 +236,7 @@ public function testRenderWithBeginEnd(): void Content HTML, - LineEndingNormalizer::normalize( - H4::tag()->begin() . 'Content' . H4::end(), - ), + H4::tag()->begin() . 'Content' . H4::end(), "Failed asserting that element renders correctly with 'begin()' and 'end()' methods.", ); } @@ -252,9 +248,9 @@ public function testRenderWithClass(): void

HTML, - LineEndingNormalizer::normalize( - H4::tag()->class('value')->render(), - ), + H4::tag() + ->class('value') + ->render(), "Failed asserting that element renders correctly with 'class' attribute.", ); } @@ -267,9 +263,9 @@ public function testRenderWithContent(): void value HTML, - LineEndingNormalizer::normalize( - H4::tag()->content('value')->render(), - ), + H4::tag() + ->content('value') + ->render(), 'Failed asserting that element renders correctly with default values.', ); } @@ -281,9 +277,9 @@ public function testRenderWithContentEditable(): void

HTML, - LineEndingNormalizer::normalize( - H4::tag()->contentEditable(true)->render(), - ), + H4::tag() + ->contentEditable(true) + ->render(), "Failed asserting that element renders correctly with 'contentEditable' attribute.", ); } @@ -295,9 +291,9 @@ public function testRenderWithContentEditableUsingEnum(): void

HTML, - LineEndingNormalizer::normalize( - H4::tag()->contentEditable(ContentEditable::TRUE)->render(), - ), + H4::tag() + ->contentEditable(ContentEditable::TRUE) + ->render(), "Failed asserting that element renders correctly with 'contentEditable' attribute using enum.", ); } @@ -309,9 +305,9 @@ public function testRenderWithDataAttributes(): void

HTML, - LineEndingNormalizer::normalize( - H4::tag()->dataAttributes(['value' => 'value'])->render(), - ), + H4::tag() + ->dataAttributes(['value' => 'value']) + ->render(), "Failed asserting that element renders correctly with 'dataAttributes()' method.", ); } @@ -323,9 +319,7 @@ public function testRenderWithDefaultConfigurationValues(): void

HTML, - LineEndingNormalizer::normalize( - H4::tag(['class' => 'default-class'])->render(), - ), + H4::tag(['class' => 'default-class'])->render(), 'Failed asserting that default configuration values are applied correctly.', ); } @@ -337,9 +331,9 @@ public function testRenderWithDefaultProvider(): void

HTML, - LineEndingNormalizer::normalize( - H4::tag()->addDefaultProvider(DefaultProvider::class)->render(), - ), + H4::tag() + ->addDefaultProvider(DefaultProvider::class) + ->render(), 'Failed asserting that default provider is applied correctly.', ); } @@ -351,9 +345,9 @@ public function testRenderWithDir(): void

HTML, - LineEndingNormalizer::normalize( - H4::tag()->dir('ltr')->render(), - ), + H4::tag() + ->dir('ltr') + ->render(), "Failed asserting that element renders correctly with 'dir' attribute.", ); } @@ -365,9 +359,9 @@ public function testRenderWithDirUsingEnum(): void

HTML, - LineEndingNormalizer::normalize( - H4::tag()->dir(Direction::LTR)->render(), - ), + H4::tag() + ->dir(Direction::LTR) + ->render(), "Failed asserting that element renders correctly with 'dir' attribute using enum.", ); } @@ -379,9 +373,9 @@ public function testRenderWithDraggable(): void

HTML, - LineEndingNormalizer::normalize( - H4::tag()->draggable(true)->render(), - ), + H4::tag() + ->draggable(true) + ->render(), "Failed asserting that element renders correctly with 'draggable' attribute.", ); } @@ -393,9 +387,9 @@ public function testRenderWithDraggableUsingEnum(): void

HTML, - LineEndingNormalizer::normalize( - H4::tag()->draggable(Draggable::TRUE)->render(), - ), + H4::tag() + ->draggable(Draggable::TRUE) + ->render(), "Failed asserting that element renders correctly with 'draggable' attribute using enum.", ); } @@ -409,9 +403,7 @@ public function testRenderWithGlobalDefaultsAreApplied(): void

HTML, - LineEndingNormalizer::normalize( - H4::tag()->render(), - ), + H4::tag()->render(), 'Failed asserting that global defaults are applied correctly.', ); @@ -425,9 +417,9 @@ public function testRenderWithHidden(): void HTML, - LineEndingNormalizer::normalize( - H4::tag()->hidden(true)->render(), - ), + H4::tag() + ->hidden(true) + ->render(), "Failed asserting that element renders correctly with 'hidden' attribute.", ); } @@ -439,9 +431,9 @@ public function testRenderWithId(): void

HTML, - LineEndingNormalizer::normalize( - H4::tag()->id('test-id')->render(), - ), + H4::tag() + ->id('test-id') + ->render(), "Failed asserting that element renders correctly with 'id' attribute.", ); } @@ -453,9 +445,9 @@ public function testRenderWithLang(): void

HTML, - LineEndingNormalizer::normalize( - H4::tag()->lang('es')->render(), - ), + H4::tag() + ->lang('es') + ->render(), "Failed asserting that element renders correctly with 'lang' attribute.", ); } @@ -467,9 +459,9 @@ public function testRenderWithLangUsingEnum(): void

HTML, - LineEndingNormalizer::normalize( - H4::tag()->lang(Language::SPANISH)->render(), - ), + H4::tag() + ->lang(Language::SPANISH) + ->render(), "Failed asserting that element renders correctly with 'lang' attribute using enum.", ); } @@ -481,15 +473,13 @@ public function testRenderWithMicroData(): void

HTML, - LineEndingNormalizer::normalize( - H4::tag() - ->itemId('https://example.com/item') - ->itemProp('name') - ->itemRef('info') - ->itemScope(true) - ->itemType('https://schema.org/Thing') - ->render(), - ), + H4::tag() + ->itemId('https://example.com/item') + ->itemProp('name') + ->itemRef('info') + ->itemScope(true) + ->itemType('https://schema.org/Thing') + ->render(), 'Failed asserting that element renders correctly with microdata attributes.', ); } @@ -501,12 +491,10 @@ public function testRenderWithRemoveAriaAttribute(): void

HTML, - LineEndingNormalizer::normalize( - H4::tag() - ->addAriaAttribute('label', 'Close') - ->removeAriaAttribute('label') - ->render(), - ), + H4::tag() + ->addAriaAttribute('label', 'Close') + ->removeAriaAttribute('label') + ->render(), "Failed asserting that element renders correctly with 'removeAriaAttribute()' method.", ); } @@ -518,12 +506,10 @@ public function testRenderWithRemoveAttribute(): void

HTML, - LineEndingNormalizer::normalize( - H4::tag() - ->addAttribute('data-test', 'value') - ->removeAttribute('data-test') - ->render(), - ), + H4::tag() + ->addAttribute('data-test', 'value') + ->removeAttribute('data-test') + ->render(), "Failed asserting that element renders correctly with 'removeAttribute()' method.", ); } @@ -535,12 +521,10 @@ public function testRenderWithRemoveDataAttribute(): void

HTML, - LineEndingNormalizer::normalize( - H4::tag() - ->addDataAttribute('value', 'test') - ->removeDataAttribute('value') - ->render(), - ), + H4::tag() + ->addDataAttribute('value', 'test') + ->removeDataAttribute('value') + ->render(), "Failed asserting that element renders correctly with 'removeDataAttribute()' method.", ); } @@ -552,9 +536,9 @@ public function testRenderWithRole(): void

HTML, - LineEndingNormalizer::normalize( - H4::tag()->role('banner')->render(), - ), + H4::tag() + ->role('banner') + ->render(), "Failed asserting that element renders correctly with 'role' attribute.", ); } @@ -566,9 +550,9 @@ public function testRenderWithRoleUsingEnum(): void

HTML, - LineEndingNormalizer::normalize( - H4::tag()->role(Role::BANNER)->render(), - ), + H4::tag() + ->role(Role::BANNER) + ->render(), "Failed asserting that element renders correctly with 'role' attribute using enum.", ); } @@ -580,9 +564,9 @@ public function testRenderWithSpellcheck(): void

HTML, - LineEndingNormalizer::normalize( - H4::tag()->spellcheck(true)->render(), - ), + H4::tag() + ->spellcheck(true) + ->render(), "Failed asserting that element renders correctly with 'spellcheck' attribute.", ); } @@ -594,9 +578,9 @@ public function testRenderWithStyle(): void

HTML, - LineEndingNormalizer::normalize( - H4::tag()->style('value')->render(), - ), + H4::tag() + ->style('value') + ->render(), "Failed asserting that element renders correctly with 'style' attribute.", ); } @@ -608,9 +592,9 @@ public function testRenderWithTabindex(): void

HTML, - LineEndingNormalizer::normalize( - H4::tag()->tabIndex(3)->render(), - ), + H4::tag() + ->tabIndex(3) + ->render(), "Failed asserting that element renders correctly with 'tabindex' attribute.", ); } @@ -622,9 +606,9 @@ public function testRenderWithThemeProvider(): void

HTML, - LineEndingNormalizer::normalize( - H4::tag()->addThemeProvider('muted', DefaultThemeProvider::class)->render(), - ), + H4::tag() + ->addThemeProvider('muted', DefaultThemeProvider::class) + ->render(), "Failed asserting that element renders correctly with 'addThemeProvider()' method.", ); } @@ -636,7 +620,9 @@ public function testRenderWithTitle(): void

HTML, - H4::tag()->title('value')->render(), + H4::tag() + ->title('value') + ->render(), "Failed asserting that element renders correctly with 'title' attribute.", ); } @@ -648,9 +634,7 @@ public function testRenderWithToString(): void

HTML, - LineEndingNormalizer::normalize( - (string) H4::tag(), - ), + (string) H4::tag(), "Failed asserting that '__toString()' method renders correctly.", ); } @@ -662,9 +646,9 @@ public function testRenderWithTranslate(): void

HTML, - LineEndingNormalizer::normalize( - H4::tag()->translate(false)->render(), - ), + H4::tag() + ->translate(false) + ->render(), "Failed asserting that element renders correctly with 'translate' attribute.", ); } @@ -676,9 +660,9 @@ public function testRenderWithTranslateUsingEnum(): void

HTML, - LineEndingNormalizer::normalize( - H4::tag()->translate(Translate::NO)->render(), - ), + H4::tag() + ->translate(Translate::NO) + ->render(), "Failed asserting that element renders correctly with 'translate' attribute using enum.", ); } @@ -692,9 +676,7 @@ public function testRenderWithUserOverridesGlobalDefaults(): void

HTML, - LineEndingNormalizer::normalize( - H4::tag(['id' => 'id-user'])->render(), - ), + H4::tag(['id' => 'id-user'])->render(), 'Failed asserting that user-defined attributes override global defaults correctly.', ); diff --git a/tests/Heading/H5Test.php b/tests/Heading/H5Test.php index 4acf275..cbc86da 100644 --- a/tests/Heading/H5Test.php +++ b/tests/Heading/H5Test.php @@ -4,7 +4,6 @@ namespace UIAwesome\Html\Tests\Heading; -use PHPForge\Support\LineEndingNormalizer; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use UIAwesome\Html\Attribute\Values\{ @@ -34,17 +33,16 @@ * @copyright Copyright (C) 2026 Terabytesoftw. * @license https://opensource.org/license/bsd-3-clause BSD 3-Clause License. */ -#[Group('html')] #[Group('heading')] final class H5Test extends TestCase { public function testContentEncodesValues(): void { - $h5 = H5::tag()->content(''); - self::assertSame( '<value>', - $h5->getContent(), + H5::tag() + ->content('') + ->getContent(), "Failed asserting that 'content()' method encodes values correctly.", ); } @@ -62,7 +60,9 @@ public function testGetAttributesReturnsAssignedAttributes(): void { self::assertSame( ['data-test' => 'value'], - H5::tag()->addAttribute('data-test', 'value')->getAttributes(), + H5::tag() + ->addAttribute('data-test', 'value') + ->getAttributes(), "Failed asserting that 'getAttributes()' returns the assigned attributes.", ); } @@ -75,9 +75,9 @@ public function testHtmlDoesNotEncodeValues(): void HTML, - LineEndingNormalizer::normalize( - H5::tag()->html('')->render(), - ), + H5::tag() + ->html('') + ->render(), "Failed asserting that element renders correctly with 'html()' method.", ); } @@ -89,9 +89,9 @@ public function testRenderWithAccesskey(): void
HTML, - LineEndingNormalizer::normalize( - H5::tag()->accesskey('k')->render(), - ), + H5::tag() + ->accesskey('k') + ->render(), "Failed asserting that element renders correctly with 'accesskey' attribute.", ); } @@ -103,9 +103,9 @@ public function testRenderWithAddAriaAttribute(): void
HTML, - LineEndingNormalizer::normalize( - H5::tag()->addAriaAttribute('pressed', true)->render(), - ), + H5::tag() + ->addAriaAttribute('pressed', true) + ->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method.", ); } @@ -117,9 +117,9 @@ public function testRenderWithAddAriaAttributeUsingEnum(): void
HTML, - LineEndingNormalizer::normalize( - H5::tag()->addAriaAttribute(Aria::PRESSED, true)->render(), - ), + H5::tag() + ->addAriaAttribute(Aria::PRESSED, true) + ->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method.", ); } @@ -131,9 +131,9 @@ public function testRenderWithAddAttribute(): void
HTML, - LineEndingNormalizer::normalize( - H5::tag()->addAttribute('data-test', 'value')->render(), - ), + H5::tag() + ->addAttribute('data-test', 'value') + ->render(), "Failed asserting that element renders correctly with 'addAttribute()' method.", ); } @@ -145,9 +145,9 @@ public function testRenderWithAddAttributeUsingEnum(): void
HTML, - LineEndingNormalizer::normalize( - H5::tag()->addAttribute(GlobalAttribute::TITLE, 'value')->render(), - ), + H5::tag() + ->addAttribute(GlobalAttribute::TITLE, 'value') + ->render(), "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", ); } @@ -159,9 +159,7 @@ public function testRenderWithAddDataAttribute(): void
HTML, - LineEndingNormalizer::normalize( - H5::tag()->addDataAttribute('value', 'value')->render(), - ), + H5::tag()->addDataAttribute('value', 'value')->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method.", ); } @@ -173,9 +171,9 @@ public function testRenderWithAddDataAttributeUsingEnum(): void
HTML, - LineEndingNormalizer::normalize( - H5::tag()->addDataAttribute(Data::VALUE, 'value')->render(), - ), + H5::tag() + ->addDataAttribute(Data::VALUE, 'value') + ->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method.", ); } @@ -187,17 +185,15 @@ public function testRenderWithAriaAttributes(): void
HTML, - LineEndingNormalizer::normalize( - H5::tag() - ->ariaAttributes( - [ - 'controls' => static fn(): string => 'modal-1', - 'hidden' => false, - 'label' => 'Close', - ], - ) - ->render(), - ), + H5::tag() + ->ariaAttributes( + [ + 'controls' => static fn(): string => 'modal-1', + 'hidden' => false, + 'label' => 'Close', + ], + ) + ->render(), "Failed asserting that element renders correctly with 'ariaAttributes()' method.", ); } @@ -209,9 +205,9 @@ public function testRenderWithAttributes(): void
HTML, - LineEndingNormalizer::normalize( - H5::tag()->attributes(['class' => 'value'])->render(), - ), + H5::tag() + ->attributes(['class' => 'value']) + ->render(), "Failed asserting that element renders correctly with 'attributes()' method.", ); } @@ -223,9 +219,9 @@ public function testRenderWithAutofocus(): void
HTML, - LineEndingNormalizer::normalize( - H5::tag()->autofocus(true)->render(), - ), + H5::tag() + ->autofocus(true) + ->render(), "Failed asserting that element renders correctly with 'autofocus' attribute.", ); } @@ -238,9 +234,7 @@ public function testRenderWithBeginEnd(): void Content HTML, - LineEndingNormalizer::normalize( - H5::tag()->begin() . 'Content' . H5::end(), - ), + H5::tag()->begin() . 'Content' . H5::end(), "Failed asserting that element renders correctly with 'begin()' and 'end()' methods.", ); } @@ -252,9 +246,9 @@ public function testRenderWithClass(): void
HTML, - LineEndingNormalizer::normalize( - H5::tag()->class('value')->render(), - ), + H5::tag() + ->class('value') + ->render(), "Failed asserting that element renders correctly with 'class' attribute.", ); } @@ -267,9 +261,9 @@ public function testRenderWithContent(): void value HTML, - LineEndingNormalizer::normalize( - H5::tag()->content('value')->render(), - ), + H5::tag() + ->content('value') + ->render(), 'Failed asserting that element renders correctly with default values.', ); } @@ -281,9 +275,9 @@ public function testRenderWithContentEditable(): void
HTML, - LineEndingNormalizer::normalize( - H5::tag()->contentEditable(true)->render(), - ), + H5::tag() + ->contentEditable(true) + ->render(), "Failed asserting that element renders correctly with 'contentEditable' attribute.", ); } @@ -295,9 +289,9 @@ public function testRenderWithContentEditableUsingEnum(): void
HTML, - LineEndingNormalizer::normalize( - H5::tag()->contentEditable(ContentEditable::TRUE)->render(), - ), + H5::tag() + ->contentEditable(ContentEditable::TRUE) + ->render(), "Failed asserting that element renders correctly with 'contentEditable' attribute using enum.", ); } @@ -309,9 +303,9 @@ public function testRenderWithDataAttributes(): void
HTML, - LineEndingNormalizer::normalize( - H5::tag()->dataAttributes(['value' => 'value'])->render(), - ), + H5::tag() + ->dataAttributes(['value' => 'value']) + ->render(), "Failed asserting that element renders correctly with 'dataAttributes()' method.", ); } @@ -323,9 +317,7 @@ public function testRenderWithDefaultConfigurationValues(): void
HTML, - LineEndingNormalizer::normalize( - H5::tag(['class' => 'default-class'])->render(), - ), + H5::tag(['class' => 'default-class'])->render(), 'Failed asserting that default configuration values are applied correctly.', ); } @@ -337,9 +329,9 @@ public function testRenderWithDefaultProvider(): void
HTML, - LineEndingNormalizer::normalize( - H5::tag()->addDefaultProvider(DefaultProvider::class)->render(), - ), + H5::tag() + ->addDefaultProvider(DefaultProvider::class) + ->render(), 'Failed asserting that default provider is applied correctly.', ); } @@ -351,9 +343,9 @@ public function testRenderWithDir(): void
HTML, - LineEndingNormalizer::normalize( - H5::tag()->dir('ltr')->render(), - ), + H5::tag() + ->dir('ltr') + ->render(), "Failed asserting that element renders correctly with 'dir' attribute.", ); } @@ -365,9 +357,9 @@ public function testRenderWithDirUsingEnum(): void
HTML, - LineEndingNormalizer::normalize( - H5::tag()->dir(Direction::LTR)->render(), - ), + H5::tag() + ->dir(Direction::LTR) + ->render(), "Failed asserting that element renders correctly with 'dir' attribute using enum.", ); } @@ -379,9 +371,9 @@ public function testRenderWithDraggable(): void
HTML, - LineEndingNormalizer::normalize( - H5::tag()->draggable(true)->render(), - ), + H5::tag() + ->draggable(true) + ->render(), "Failed asserting that element renders correctly with 'draggable' attribute.", ); } @@ -393,9 +385,9 @@ public function testRenderWithDraggableUsingEnum(): void
HTML, - LineEndingNormalizer::normalize( - H5::tag()->draggable(Draggable::TRUE)->render(), - ), + H5::tag() + ->draggable(Draggable::TRUE) + ->render(), "Failed asserting that element renders correctly with 'draggable' attribute using enum.", ); } @@ -409,9 +401,7 @@ public function testRenderWithGlobalDefaultsAreApplied(): void
HTML, - LineEndingNormalizer::normalize( - H5::tag()->render(), - ), + H5::tag()->render(), 'Failed asserting that global defaults are applied correctly.', ); @@ -425,9 +415,9 @@ public function testRenderWithHidden(): void HTML, - LineEndingNormalizer::normalize( - H5::tag()->hidden(true)->render(), - ), + H5::tag() + ->hidden(true) + ->render(), "Failed asserting that element renders correctly with 'hidden' attribute.", ); } @@ -439,9 +429,9 @@ public function testRenderWithId(): void
HTML, - LineEndingNormalizer::normalize( - H5::tag()->id('test-id')->render(), - ), + H5::tag() + ->id('test-id') + ->render(), "Failed asserting that element renders correctly with 'id' attribute.", ); } @@ -453,9 +443,9 @@ public function testRenderWithLang(): void
HTML, - LineEndingNormalizer::normalize( - H5::tag()->lang('es')->render(), - ), + H5::tag() + ->lang('es') + ->render(), "Failed asserting that element renders correctly with 'lang' attribute.", ); } @@ -467,9 +457,9 @@ public function testRenderWithLangUsingEnum(): void
HTML, - LineEndingNormalizer::normalize( - H5::tag()->lang(Language::SPANISH)->render(), - ), + H5::tag() + ->lang(Language::SPANISH) + ->render(), "Failed asserting that element renders correctly with 'lang' attribute using enum.", ); } @@ -481,15 +471,13 @@ public function testRenderWithMicroData(): void
HTML, - LineEndingNormalizer::normalize( - H5::tag() - ->itemId('https://example.com/item') - ->itemProp('name') - ->itemRef('info') - ->itemScope(true) - ->itemType('https://schema.org/Thing') - ->render(), - ), + H5::tag() + ->itemId('https://example.com/item') + ->itemProp('name') + ->itemRef('info') + ->itemScope(true) + ->itemType('https://schema.org/Thing') + ->render(), 'Failed asserting that element renders correctly with microdata attributes.', ); } @@ -501,12 +489,10 @@ public function testRenderWithRemoveAriaAttribute(): void
HTML, - LineEndingNormalizer::normalize( - H5::tag() - ->addAriaAttribute('label', 'Close') - ->removeAriaAttribute('label') - ->render(), - ), + H5::tag() + ->addAriaAttribute('label', 'Close') + ->removeAriaAttribute('label') + ->render(), "Failed asserting that element renders correctly with 'removeAriaAttribute()' method.", ); } @@ -518,12 +504,10 @@ public function testRenderWithRemoveAttribute(): void
HTML, - LineEndingNormalizer::normalize( - H5::tag() - ->addAttribute('data-test', 'value') - ->removeAttribute('data-test') - ->render(), - ), + H5::tag() + ->addAttribute('data-test', 'value') + ->removeAttribute('data-test') + ->render(), "Failed asserting that element renders correctly with 'removeAttribute()' method.", ); } @@ -535,12 +519,10 @@ public function testRenderWithRemoveDataAttribute(): void
HTML, - LineEndingNormalizer::normalize( - H5::tag() - ->addDataAttribute('value', 'test') - ->removeDataAttribute('value') - ->render(), - ), + H5::tag() + ->addDataAttribute('value', 'test') + ->removeDataAttribute('value') + ->render(), "Failed asserting that element renders correctly with 'removeDataAttribute()' method.", ); } @@ -552,9 +534,9 @@ public function testRenderWithRole(): void
HTML, - LineEndingNormalizer::normalize( - H5::tag()->role('banner')->render(), - ), + H5::tag() + ->role('banner') + ->render(), "Failed asserting that element renders correctly with 'role' attribute.", ); } @@ -566,9 +548,9 @@ public function testRenderWithRoleUsingEnum(): void
HTML, - LineEndingNormalizer::normalize( - H5::tag()->role(Role::BANNER)->render(), - ), + H5::tag() + ->role(Role::BANNER) + ->render(), "Failed asserting that element renders correctly with 'role' attribute using enum.", ); } @@ -580,9 +562,9 @@ public function testRenderWithSpellcheck(): void
HTML, - LineEndingNormalizer::normalize( - H5::tag()->spellcheck(true)->render(), - ), + H5::tag() + ->spellcheck(true) + ->render(), "Failed asserting that element renders correctly with 'spellcheck' attribute.", ); } @@ -594,9 +576,9 @@ public function testRenderWithStyle(): void
HTML, - LineEndingNormalizer::normalize( - H5::tag()->style('value')->render(), - ), + H5::tag() + ->style('value') + ->render(), "Failed asserting that element renders correctly with 'style' attribute.", ); } @@ -608,9 +590,9 @@ public function testRenderWithTabindex(): void
HTML, - LineEndingNormalizer::normalize( - H5::tag()->tabIndex(3)->render(), - ), + H5::tag() + ->tabIndex(3) + ->render(), "Failed asserting that element renders correctly with 'tabindex' attribute.", ); } @@ -622,9 +604,9 @@ public function testRenderWithThemeProvider(): void
HTML, - LineEndingNormalizer::normalize( - H5::tag()->addThemeProvider('muted', DefaultThemeProvider::class)->render(), - ), + H5::tag() + ->addThemeProvider('muted', DefaultThemeProvider::class) + ->render(), "Failed asserting that element renders correctly with 'addThemeProvider()' method.", ); } @@ -636,7 +618,9 @@ public function testRenderWithTitle(): void
HTML, - H5::tag()->title('value')->render(), + H5::tag() + ->title('value') + ->render(), "Failed asserting that element renders correctly with 'title' attribute.", ); } @@ -648,9 +632,7 @@ public function testRenderWithToString(): void
HTML, - LineEndingNormalizer::normalize( - (string) H5::tag(), - ), + (string) H5::tag(), "Failed asserting that '__toString()' method renders correctly.", ); } @@ -662,9 +644,9 @@ public function testRenderWithTranslate(): void
HTML, - LineEndingNormalizer::normalize( - H5::tag()->translate(false)->render(), - ), + H5::tag() + ->translate(false) + ->render(), "Failed asserting that element renders correctly with 'translate' attribute.", ); } @@ -676,9 +658,9 @@ public function testRenderWithTranslateUsingEnum(): void
HTML, - LineEndingNormalizer::normalize( - H5::tag()->translate(Translate::NO)->render(), - ), + H5::tag() + ->translate(Translate::NO) + ->render(), "Failed asserting that element renders correctly with 'translate' attribute using enum.", ); } @@ -692,9 +674,7 @@ public function testRenderWithUserOverridesGlobalDefaults(): void
HTML, - LineEndingNormalizer::normalize( - H5::tag(['id' => 'id-user'])->render(), - ), + H5::tag(['id' => 'id-user'])->render(), 'Failed asserting that user-defined attributes override global defaults correctly.', ); diff --git a/tests/Heading/H6Test.php b/tests/Heading/H6Test.php index b8de134..9147936 100644 --- a/tests/Heading/H6Test.php +++ b/tests/Heading/H6Test.php @@ -4,7 +4,6 @@ namespace UIAwesome\Html\Tests\Heading; -use PHPForge\Support\LineEndingNormalizer; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use UIAwesome\Html\Attribute\Values\{ @@ -34,17 +33,16 @@ * @copyright Copyright (C) 2026 Terabytesoftw. * @license https://opensource.org/license/bsd-3-clause BSD 3-Clause License. */ -#[Group('html')] #[Group('heading')] final class H6Test extends TestCase { public function testContentEncodesValues(): void { - $h6 = H6::tag()->content(''); - self::assertSame( '<value>', - $h6->getContent(), + H6::tag() + ->content('') + ->getContent(), "Failed asserting that 'content()' method encodes values correctly.", ); } @@ -62,7 +60,9 @@ public function testGetAttributesReturnsAssignedAttributes(): void { self::assertSame( ['data-test' => 'value'], - H6::tag()->addAttribute('data-test', 'value')->getAttributes(), + H6::tag() + ->addAttribute('data-test', 'value') + ->getAttributes(), "Failed asserting that 'getAttributes()' returns the assigned attributes.", ); } @@ -75,9 +75,9 @@ public function testHtmlDoesNotEncodeValues(): void HTML, - LineEndingNormalizer::normalize( - H6::tag()->html('')->render(), - ), + H6::tag() + ->html('') + ->render(), "Failed asserting that element renders correctly with 'html()' method.", ); } @@ -89,9 +89,9 @@ public function testRenderWithAccesskey(): void
HTML, - LineEndingNormalizer::normalize( - H6::tag()->accesskey('k')->render(), - ), + H6::tag() + ->accesskey('k') + ->render(), "Failed asserting that element renders correctly with 'accesskey' attribute.", ); } @@ -103,9 +103,9 @@ public function testRenderWithAddAriaAttribute(): void
HTML, - LineEndingNormalizer::normalize( - H6::tag()->addAriaAttribute('pressed', true)->render(), - ), + H6::tag() + ->addAriaAttribute('pressed', true) + ->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method.", ); } @@ -117,9 +117,9 @@ public function testRenderWithAddAriaAttributeUsingEnum(): void
HTML, - LineEndingNormalizer::normalize( - H6::tag()->addAriaAttribute(Aria::PRESSED, true)->render(), - ), + H6::tag() + ->addAriaAttribute(Aria::PRESSED, true) + ->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method.", ); } @@ -131,9 +131,9 @@ public function testRenderWithAddAttribute(): void
HTML, - LineEndingNormalizer::normalize( - H6::tag()->addAttribute('data-test', 'value')->render(), - ), + H6::tag() + ->addAttribute('data-test', 'value') + ->render(), "Failed asserting that element renders correctly with 'addAttribute()' method.", ); } @@ -145,9 +145,9 @@ public function testRenderWithAddAttributeUsingEnum(): void
HTML, - LineEndingNormalizer::normalize( - H6::tag()->addAttribute(GlobalAttribute::TITLE, 'value')->render(), - ), + H6::tag() + ->addAttribute(GlobalAttribute::TITLE, 'value') + ->render(), "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", ); } @@ -159,9 +159,9 @@ public function testRenderWithAddDataAttribute(): void
HTML, - LineEndingNormalizer::normalize( - H6::tag()->addDataAttribute('value', 'value')->render(), - ), + H6::tag() + ->addDataAttribute('value', 'value') + ->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method.", ); } @@ -173,9 +173,9 @@ public function testRenderWithAddDataAttributeUsingEnum(): void
HTML, - LineEndingNormalizer::normalize( - H6::tag()->addDataAttribute(Data::VALUE, 'value')->render(), - ), + H6::tag() + ->addDataAttribute(Data::VALUE, 'value') + ->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method.", ); } @@ -187,17 +187,15 @@ public function testRenderWithAriaAttributes(): void
HTML, - LineEndingNormalizer::normalize( - H6::tag() - ->ariaAttributes( - [ - 'controls' => static fn(): string => 'modal-1', - 'hidden' => false, - 'label' => 'Close', - ], - ) - ->render(), - ), + H6::tag() + ->ariaAttributes( + [ + 'controls' => static fn(): string => 'modal-1', + 'hidden' => false, + 'label' => 'Close', + ], + ) + ->render(), "Failed asserting that element renders correctly with 'ariaAttributes()' method.", ); } @@ -209,9 +207,9 @@ public function testRenderWithAttributes(): void
HTML, - LineEndingNormalizer::normalize( - H6::tag()->attributes(['class' => 'value'])->render(), - ), + H6::tag() + ->attributes(['class' => 'value']) + ->render(), "Failed asserting that element renders correctly with 'attributes()' method.", ); } @@ -223,9 +221,9 @@ public function testRenderWithAutofocus(): void
HTML, - LineEndingNormalizer::normalize( - H6::tag()->autofocus(true)->render(), - ), + H6::tag() + ->autofocus(true) + ->render(), "Failed asserting that element renders correctly with 'autofocus' attribute.", ); } @@ -238,9 +236,7 @@ public function testRenderWithBeginEnd(): void Content HTML, - LineEndingNormalizer::normalize( - H6::tag()->begin() . 'Content' . H6::end(), - ), + H6::tag()->begin() . 'Content' . H6::end(), "Failed asserting that element renders correctly with 'begin()' and 'end()' methods.", ); } @@ -252,9 +248,9 @@ public function testRenderWithClass(): void
HTML, - LineEndingNormalizer::normalize( - H6::tag()->class('value')->render(), - ), + H6::tag() + ->class('value') + ->render(), "Failed asserting that element renders correctly with 'class' attribute.", ); } @@ -267,9 +263,9 @@ public function testRenderWithContent(): void value HTML, - LineEndingNormalizer::normalize( - H6::tag()->content('value')->render(), - ), + H6::tag() + ->content('value') + ->render(), 'Failed asserting that element renders correctly with default values.', ); } @@ -281,9 +277,9 @@ public function testRenderWithContentEditable(): void
HTML, - LineEndingNormalizer::normalize( - H6::tag()->contentEditable(true)->render(), - ), + H6::tag() + ->contentEditable(true) + ->render(), "Failed asserting that element renders correctly with 'contentEditable' attribute.", ); } @@ -295,9 +291,9 @@ public function testRenderWithContentEditableUsingEnum(): void
HTML, - LineEndingNormalizer::normalize( - H6::tag()->contentEditable(ContentEditable::TRUE)->render(), - ), + H6::tag() + ->contentEditable(ContentEditable::TRUE) + ->render(), "Failed asserting that element renders correctly with 'contentEditable' attribute using enum.", ); } @@ -309,9 +305,9 @@ public function testRenderWithDataAttributes(): void
HTML, - LineEndingNormalizer::normalize( - H6::tag()->dataAttributes(['value' => 'value'])->render(), - ), + H6::tag() + ->dataAttributes(['value' => 'value']) + ->render(), "Failed asserting that element renders correctly with 'dataAttributes()' method.", ); } @@ -323,9 +319,7 @@ public function testRenderWithDefaultConfigurationValues(): void
HTML, - LineEndingNormalizer::normalize( - H6::tag(['class' => 'default-class'])->render(), - ), + H6::tag(['class' => 'default-class'])->render(), 'Failed asserting that default configuration values are applied correctly.', ); } @@ -337,9 +331,9 @@ public function testRenderWithDefaultProvider(): void
HTML, - LineEndingNormalizer::normalize( - H6::tag()->addDefaultProvider(DefaultProvider::class)->render(), - ), + H6::tag() + ->addDefaultProvider(DefaultProvider::class) + ->render(), 'Failed asserting that default provider is applied correctly.', ); } @@ -351,9 +345,9 @@ public function testRenderWithDir(): void
HTML, - LineEndingNormalizer::normalize( - H6::tag()->dir('ltr')->render(), - ), + H6::tag() + ->dir('ltr') + ->render(), "Failed asserting that element renders correctly with 'dir' attribute.", ); } @@ -365,9 +359,9 @@ public function testRenderWithDirUsingEnum(): void
HTML, - LineEndingNormalizer::normalize( - H6::tag()->dir(Direction::LTR)->render(), - ), + H6::tag() + ->dir(Direction::LTR) + ->render(), "Failed asserting that element renders correctly with 'dir' attribute using enum.", ); } @@ -379,9 +373,9 @@ public function testRenderWithDraggable(): void
HTML, - LineEndingNormalizer::normalize( - H6::tag()->draggable(true)->render(), - ), + H6::tag() + ->draggable(true) + ->render(), "Failed asserting that element renders correctly with 'draggable' attribute.", ); } @@ -393,9 +387,9 @@ public function testRenderWithDraggableUsingEnum(): void
HTML, - LineEndingNormalizer::normalize( - H6::tag()->draggable(Draggable::TRUE)->render(), - ), + H6::tag() + ->draggable(Draggable::TRUE) + ->render(), "Failed asserting that element renders correctly with 'draggable' attribute using enum.", ); } @@ -409,9 +403,7 @@ public function testRenderWithGlobalDefaultsAreApplied(): void
HTML, - LineEndingNormalizer::normalize( - H6::tag()->render(), - ), + H6::tag()->render(), 'Failed asserting that global defaults are applied correctly.', ); @@ -425,9 +417,9 @@ public function testRenderWithHidden(): void HTML, - LineEndingNormalizer::normalize( - H6::tag()->hidden(true)->render(), - ), + H6::tag() + ->hidden(true) + ->render(), "Failed asserting that element renders correctly with 'hidden' attribute.", ); } @@ -439,9 +431,9 @@ public function testRenderWithId(): void
HTML, - LineEndingNormalizer::normalize( - H6::tag()->id('test-id')->render(), - ), + H6::tag() + ->id('test-id') + ->render(), "Failed asserting that element renders correctly with 'id' attribute.", ); } @@ -453,9 +445,9 @@ public function testRenderWithLang(): void
HTML, - LineEndingNormalizer::normalize( - H6::tag()->lang('es')->render(), - ), + H6::tag() + ->lang('es') + ->render(), "Failed asserting that element renders correctly with 'lang' attribute.", ); } @@ -467,9 +459,9 @@ public function testRenderWithLangUsingEnum(): void
HTML, - LineEndingNormalizer::normalize( - H6::tag()->lang(Language::SPANISH)->render(), - ), + H6::tag() + ->lang(Language::SPANISH) + ->render(), "Failed asserting that element renders correctly with 'lang' attribute using enum.", ); } @@ -481,15 +473,13 @@ public function testRenderWithMicroData(): void
HTML, - LineEndingNormalizer::normalize( - H6::tag() - ->itemId('https://example.com/item') - ->itemProp('name') - ->itemRef('info') - ->itemScope(true) - ->itemType('https://schema.org/Thing') - ->render(), - ), + H6::tag() + ->itemId('https://example.com/item') + ->itemProp('name') + ->itemRef('info') + ->itemScope(true) + ->itemType('https://schema.org/Thing') + ->render(), 'Failed asserting that element renders correctly with microdata attributes.', ); } @@ -501,12 +491,10 @@ public function testRenderWithRemoveAriaAttribute(): void
HTML, - LineEndingNormalizer::normalize( - H6::tag() - ->addAriaAttribute('label', 'Close') - ->removeAriaAttribute('label') - ->render(), - ), + H6::tag() + ->addAriaAttribute('label', 'Close') + ->removeAriaAttribute('label') + ->render(), "Failed asserting that element renders correctly with 'removeAriaAttribute()' method.", ); } @@ -518,12 +506,10 @@ public function testRenderWithRemoveAttribute(): void
HTML, - LineEndingNormalizer::normalize( - H6::tag() - ->addAttribute('data-test', 'value') - ->removeAttribute('data-test') - ->render(), - ), + H6::tag() + ->addAttribute('data-test', 'value') + ->removeAttribute('data-test') + ->render(), "Failed asserting that element renders correctly with 'removeAttribute()' method.", ); } @@ -535,12 +521,10 @@ public function testRenderWithRemoveDataAttribute(): void
HTML, - LineEndingNormalizer::normalize( - H6::tag() - ->addDataAttribute('value', 'test') - ->removeDataAttribute('value') - ->render(), - ), + H6::tag() + ->addDataAttribute('value', 'test') + ->removeDataAttribute('value') + ->render(), "Failed asserting that element renders correctly with 'removeDataAttribute()' method.", ); } @@ -552,9 +536,9 @@ public function testRenderWithRole(): void
HTML, - LineEndingNormalizer::normalize( - H6::tag()->role('banner')->render(), - ), + H6::tag() + ->role('banner') + ->render(), "Failed asserting that element renders correctly with 'role' attribute.", ); } @@ -566,9 +550,9 @@ public function testRenderWithRoleUsingEnum(): void
HTML, - LineEndingNormalizer::normalize( - H6::tag()->role(Role::BANNER)->render(), - ), + H6::tag() + ->role(Role::BANNER) + ->render(), "Failed asserting that element renders correctly with 'role' attribute using enum.", ); } @@ -580,9 +564,9 @@ public function testRenderWithSpellcheck(): void
HTML, - LineEndingNormalizer::normalize( - H6::tag()->spellcheck(true)->render(), - ), + H6::tag() + ->spellcheck(true) + ->render(), "Failed asserting that element renders correctly with 'spellcheck' attribute.", ); } @@ -594,9 +578,9 @@ public function testRenderWithStyle(): void
HTML, - LineEndingNormalizer::normalize( - H6::tag()->style('value')->render(), - ), + H6::tag() + ->style('value') + ->render(), "Failed asserting that element renders correctly with 'style' attribute.", ); } @@ -608,9 +592,9 @@ public function testRenderWithTabindex(): void
HTML, - LineEndingNormalizer::normalize( - H6::tag()->tabIndex(3)->render(), - ), + H6::tag() + ->tabIndex(3) + ->render(), "Failed asserting that element renders correctly with 'tabindex' attribute.", ); } @@ -622,9 +606,9 @@ public function testRenderWithThemeProvider(): void
HTML, - LineEndingNormalizer::normalize( - H6::tag()->addThemeProvider('muted', DefaultThemeProvider::class)->render(), - ), + H6::tag() + ->addThemeProvider('muted', DefaultThemeProvider::class) + ->render(), "Failed asserting that element renders correctly with 'addThemeProvider()' method.", ); } @@ -636,7 +620,9 @@ public function testRenderWithTitle(): void
HTML, - H6::tag()->title('value')->render(), + H6::tag() + ->title('value') + ->render(), "Failed asserting that element renders correctly with 'title' attribute.", ); } @@ -648,9 +634,7 @@ public function testRenderWithToString(): void
HTML, - LineEndingNormalizer::normalize( - (string) H6::tag(), - ), + (string) H6::tag(), "Failed asserting that '__toString()' method renders correctly.", ); } @@ -662,9 +646,9 @@ public function testRenderWithTranslate(): void
HTML, - LineEndingNormalizer::normalize( - H6::tag()->translate(false)->render(), - ), + H6::tag() + ->translate(false) + ->render(), "Failed asserting that element renders correctly with 'translate' attribute.", ); } @@ -676,9 +660,9 @@ public function testRenderWithTranslateUsingEnum(): void
HTML, - LineEndingNormalizer::normalize( - H6::tag()->translate(Translate::NO)->render(), - ), + H6::tag() + ->translate(Translate::NO) + ->render(), "Failed asserting that element renders correctly with 'translate' attribute using enum.", ); } @@ -692,9 +676,7 @@ public function testRenderWithUserOverridesGlobalDefaults(): void
HTML, - LineEndingNormalizer::normalize( - H6::tag(['id' => 'id-user'])->render(), - ), + H6::tag(['id' => 'id-user'])->render(), 'Failed asserting that user-defined attributes override global defaults correctly.', ); diff --git a/tests/Heading/HGroupTest.php b/tests/Heading/HGroupTest.php index 921473a..21721bc 100644 --- a/tests/Heading/HGroupTest.php +++ b/tests/Heading/HGroupTest.php @@ -4,7 +4,6 @@ namespace UIAwesome\Html\Tests\Heading; -use PHPForge\Support\LineEndingNormalizer; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use UIAwesome\Html\Attribute\Values\{ @@ -34,17 +33,16 @@ * @copyright Copyright (C) 2026 Terabytesoftw. * @license https://opensource.org/license/bsd-3-clause BSD 3-Clause License. */ -#[Group('html')] #[Group('heading')] final class HGroupTest extends TestCase { public function testContentEncodesValues(): void { - $hgroup = HGroup::tag()->content(''); - self::assertSame( '<value>', - $hgroup->getContent(), + HGroup::tag() + ->content('') + ->getContent(), "Failed asserting that 'content()' method encodes values correctly.", ); } @@ -62,7 +60,9 @@ public function testGetAttributesReturnsAssignedAttributes(): void { self::assertSame( ['data-test' => 'value'], - HGroup::tag()->addAttribute('data-test', 'value')->getAttributes(), + HGroup::tag() + ->addAttribute('data-test', 'value') + ->getAttributes(), "Failed asserting that 'getAttributes()' returns the assigned attributes.", ); } @@ -75,9 +75,9 @@ public function testHtmlDoesNotEncodeValues(): void HTML, - LineEndingNormalizer::normalize( - HGroup::tag()->html('')->render(), - ), + HGroup::tag() + ->html('') + ->render(), "Failed asserting that element renders correctly with 'html()' method.", ); } @@ -89,9 +89,9 @@ public function testRenderWithAccesskey(): void
HTML, - LineEndingNormalizer::normalize( - HGroup::tag()->accesskey('k')->render(), - ), + HGroup::tag() + ->accesskey('k') + ->render(), "Failed asserting that element renders correctly with 'accesskey' attribute.", ); } @@ -103,9 +103,9 @@ public function testRenderWithAddAriaAttribute(): void
HTML, - LineEndingNormalizer::normalize( - HGroup::tag()->addAriaAttribute('pressed', true)->render(), - ), + HGroup::tag() + ->addAriaAttribute('pressed', true) + ->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method.", ); } @@ -117,9 +117,9 @@ public function testRenderWithAddAriaAttributeUsingEnum(): void
HTML, - LineEndingNormalizer::normalize( - HGroup::tag()->addAriaAttribute(Aria::PRESSED, true)->render(), - ), + HGroup::tag() + ->addAriaAttribute(Aria::PRESSED, true) + ->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method.", ); } @@ -131,9 +131,9 @@ public function testRenderWithAddAttribute(): void
HTML, - LineEndingNormalizer::normalize( - HGroup::tag()->addAttribute('data-test', 'value')->render(), - ), + HGroup::tag() + ->addAttribute('data-test', 'value') + ->render(), "Failed asserting that element renders correctly with 'addAttribute()' method.", ); } @@ -145,9 +145,9 @@ public function testRenderWithAddAttributeUsingEnum(): void
HTML, - LineEndingNormalizer::normalize( - HGroup::tag()->addAttribute(GlobalAttribute::TITLE, 'value')->render(), - ), + HGroup::tag() + ->addAttribute(GlobalAttribute::TITLE, 'value') + ->render(), "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", ); } @@ -159,9 +159,9 @@ public function testRenderWithAddDataAttribute(): void
HTML, - LineEndingNormalizer::normalize( - HGroup::tag()->addDataAttribute('value', 'value')->render(), - ), + HGroup::tag() + ->addDataAttribute('value', 'value') + ->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method.", ); } @@ -173,9 +173,9 @@ public function testRenderWithAddDataAttributeUsingEnum(): void
HTML, - LineEndingNormalizer::normalize( - HGroup::tag()->addDataAttribute(Data::VALUE, 'value')->render(), - ), + HGroup::tag() + ->addDataAttribute(Data::VALUE, 'value') + ->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method.", ); } @@ -187,17 +187,15 @@ public function testRenderWithAriaAttributes(): void
HTML, - LineEndingNormalizer::normalize( - HGroup::tag() - ->ariaAttributes( - [ - 'controls' => static fn(): string => 'modal-1', - 'hidden' => false, - 'label' => 'Close', - ], - ) - ->render(), - ), + HGroup::tag() + ->ariaAttributes( + [ + 'controls' => static fn(): string => 'modal-1', + 'hidden' => false, + 'label' => 'Close', + ], + ) + ->render(), "Failed asserting that element renders correctly with 'ariaAttributes()' method.", ); } @@ -209,9 +207,9 @@ public function testRenderWithAttributes(): void
HTML, - LineEndingNormalizer::normalize( - HGroup::tag()->attributes(['class' => 'value'])->render(), - ), + HGroup::tag() + ->attributes(['class' => 'value']) + ->render(), "Failed asserting that element renders correctly with 'attributes()' method.", ); } @@ -223,9 +221,9 @@ public function testRenderWithAutofocus(): void
HTML, - LineEndingNormalizer::normalize( - HGroup::tag()->autofocus(true)->render(), - ), + HGroup::tag() + ->autofocus(true) + ->render(), "Failed asserting that element renders correctly with 'autofocus' attribute.", ); } @@ -238,9 +236,7 @@ public function testRenderWithBeginEnd(): void Content HTML, - LineEndingNormalizer::normalize( - HGroup::tag()->begin() . 'Content' . HGroup::end(), - ), + HGroup::tag()->begin() . 'Content' . HGroup::end(), "Failed asserting that element renders correctly with 'begin()' and 'end()' methods.", ); } @@ -252,9 +248,9 @@ public function testRenderWithClass(): void
HTML, - LineEndingNormalizer::normalize( - HGroup::tag()->class('value')->render(), - ), + HGroup::tag() + ->class('value') + ->render(), "Failed asserting that element renders correctly with 'class' attribute.", ); } @@ -267,9 +263,9 @@ public function testRenderWithContent(): void value HTML, - LineEndingNormalizer::normalize( - HGroup::tag()->content('value')->render(), - ), + HGroup::tag() + ->content('value') + ->render(), 'Failed asserting that element renders correctly with default values.', ); } @@ -281,9 +277,9 @@ public function testRenderWithContentEditable(): void
HTML, - LineEndingNormalizer::normalize( - HGroup::tag()->contentEditable(true)->render(), - ), + HGroup::tag() + ->contentEditable(true) + ->render(), "Failed asserting that element renders correctly with 'contentEditable' attribute.", ); } @@ -295,9 +291,9 @@ public function testRenderWithContentEditableUsingEnum(): void
HTML, - LineEndingNormalizer::normalize( - HGroup::tag()->contentEditable(ContentEditable::TRUE)->render(), - ), + HGroup::tag() + ->contentEditable(ContentEditable::TRUE) + ->render(), "Failed asserting that element renders correctly with 'contentEditable' attribute using enum.", ); } @@ -309,9 +305,9 @@ public function testRenderWithDataAttributes(): void
HTML, - LineEndingNormalizer::normalize( - HGroup::tag()->dataAttributes(['value' => 'value'])->render(), - ), + HGroup::tag() + ->dataAttributes(['value' => 'value']) + ->render(), "Failed asserting that element renders correctly with 'dataAttributes()' method.", ); } @@ -323,9 +319,7 @@ public function testRenderWithDefaultConfigurationValues(): void
HTML, - LineEndingNormalizer::normalize( - HGroup::tag(['class' => 'default-class'])->render(), - ), + HGroup::tag(['class' => 'default-class'])->render(), 'Failed asserting that default configuration values are applied correctly.', ); } @@ -337,9 +331,9 @@ public function testRenderWithDefaultProvider(): void
HTML, - LineEndingNormalizer::normalize( - HGroup::tag()->addDefaultProvider(DefaultProvider::class)->render(), - ), + HGroup::tag() + ->addDefaultProvider(DefaultProvider::class) + ->render(), 'Failed asserting that default provider is applied correctly.', ); } @@ -351,9 +345,9 @@ public function testRenderWithDir(): void
HTML, - LineEndingNormalizer::normalize( - HGroup::tag()->dir('ltr')->render(), - ), + HGroup::tag() + ->dir('ltr') + ->render(), "Failed asserting that element renders correctly with 'dir' attribute.", ); } @@ -365,9 +359,9 @@ public function testRenderWithDirUsingEnum(): void
HTML, - LineEndingNormalizer::normalize( - HGroup::tag()->dir(Direction::LTR)->render(), - ), + HGroup::tag() + ->dir(Direction::LTR) + ->render(), "Failed asserting that element renders correctly with 'dir' attribute using enum.", ); } @@ -379,9 +373,9 @@ public function testRenderWithDraggable(): void
HTML, - LineEndingNormalizer::normalize( - HGroup::tag()->draggable(true)->render(), - ), + HGroup::tag() + ->draggable(true) + ->render(), "Failed asserting that element renders correctly with 'draggable' attribute.", ); } @@ -393,9 +387,9 @@ public function testRenderWithDraggableUsingEnum(): void
HTML, - LineEndingNormalizer::normalize( - HGroup::tag()->draggable(Draggable::TRUE)->render(), - ), + HGroup::tag() + ->draggable(Draggable::TRUE) + ->render(), "Failed asserting that element renders correctly with 'draggable' attribute using enum.", ); } @@ -409,9 +403,7 @@ public function testRenderWithGlobalDefaultsAreApplied(): void
HTML, - LineEndingNormalizer::normalize( - HGroup::tag()->render(), - ), + HGroup::tag()->render(), 'Failed asserting that global defaults are applied correctly.', ); @@ -425,9 +417,9 @@ public function testRenderWithHidden(): void HTML, - LineEndingNormalizer::normalize( - HGroup::tag()->hidden(true)->render(), - ), + HGroup::tag() + ->hidden(true) + ->render(), "Failed asserting that element renders correctly with 'hidden' attribute.", ); } @@ -439,9 +431,9 @@ public function testRenderWithId(): void
HTML, - LineEndingNormalizer::normalize( - HGroup::tag()->id('test-id')->render(), - ), + HGroup::tag() + ->id('test-id') + ->render(), "Failed asserting that element renders correctly with 'id' attribute.", ); } @@ -453,9 +445,9 @@ public function testRenderWithLang(): void
HTML, - LineEndingNormalizer::normalize( - HGroup::tag()->lang('es')->render(), - ), + HGroup::tag() + ->lang('es') + ->render(), "Failed asserting that element renders correctly with 'lang' attribute.", ); } @@ -467,9 +459,9 @@ public function testRenderWithLangUsingEnum(): void
HTML, - LineEndingNormalizer::normalize( - HGroup::tag()->lang(Language::SPANISH)->render(), - ), + HGroup::tag() + ->lang(Language::SPANISH) + ->render(), "Failed asserting that element renders correctly with 'lang' attribute using enum.", ); } @@ -481,15 +473,13 @@ public function testRenderWithMicroData(): void
HTML, - LineEndingNormalizer::normalize( - HGroup::tag() - ->itemId('https://example.com/item') - ->itemProp('name') - ->itemRef('info') - ->itemScope(true) - ->itemType('https://schema.org/Thing') - ->render(), - ), + HGroup::tag() + ->itemId('https://example.com/item') + ->itemProp('name') + ->itemRef('info') + ->itemScope(true) + ->itemType('https://schema.org/Thing') + ->render(), 'Failed asserting that element renders correctly with microdata attributes.', ); } @@ -501,12 +491,10 @@ public function testRenderWithRemoveAriaAttribute(): void
HTML, - LineEndingNormalizer::normalize( - HGroup::tag() - ->addAriaAttribute('label', 'Close') - ->removeAriaAttribute('label') - ->render(), - ), + HGroup::tag() + ->addAriaAttribute('label', 'Close') + ->removeAriaAttribute('label') + ->render(), "Failed asserting that element renders correctly with 'removeAriaAttribute()' method.", ); } @@ -518,12 +506,10 @@ public function testRenderWithRemoveAttribute(): void
HTML, - LineEndingNormalizer::normalize( - HGroup::tag() - ->addAttribute('data-test', 'value') - ->removeAttribute('data-test') - ->render(), - ), + HGroup::tag() + ->addAttribute('data-test', 'value') + ->removeAttribute('data-test') + ->render(), "Failed asserting that element renders correctly with 'removeAttribute()' method.", ); } @@ -535,12 +521,10 @@ public function testRenderWithRemoveDataAttribute(): void
HTML, - LineEndingNormalizer::normalize( - HGroup::tag() - ->addDataAttribute('value', 'test') - ->removeDataAttribute('value') - ->render(), - ), + HGroup::tag() + ->addDataAttribute('value', 'test') + ->removeDataAttribute('value') + ->render(), "Failed asserting that element renders correctly with 'removeDataAttribute()' method.", ); } @@ -552,9 +536,9 @@ public function testRenderWithRole(): void
HTML, - LineEndingNormalizer::normalize( - HGroup::tag()->role('group')->render(), - ), + HGroup::tag() + ->role('group') + ->render(), "Failed asserting that element renders correctly with 'role' attribute.", ); } @@ -566,9 +550,9 @@ public function testRenderWithRoleUsingEnum(): void
HTML, - LineEndingNormalizer::normalize( - HGroup::tag()->role(Role::GROUP)->render(), - ), + HGroup::tag() + ->role(Role::GROUP) + ->render(), "Failed asserting that element renders correctly with 'role' attribute using enum.", ); } @@ -580,9 +564,9 @@ public function testRenderWithSpellcheck(): void
HTML, - LineEndingNormalizer::normalize( - HGroup::tag()->spellcheck(true)->render(), - ), + HGroup::tag() + ->spellcheck(true) + ->render(), "Failed asserting that element renders correctly with 'spellcheck' attribute.", ); } @@ -594,9 +578,9 @@ public function testRenderWithStyle(): void
HTML, - LineEndingNormalizer::normalize( - HGroup::tag()->style('value')->render(), - ), + HGroup::tag() + ->style('value') + ->render(), "Failed asserting that element renders correctly with 'style' attribute.", ); } @@ -608,9 +592,7 @@ public function testRenderWithTabindex(): void
HTML, - LineEndingNormalizer::normalize( - HGroup::tag()->tabIndex(3)->render(), - ), + HGroup::tag()->tabIndex(3)->render(), "Failed asserting that element renders correctly with 'tabindex' attribute.", ); } @@ -622,9 +604,9 @@ public function testRenderWithThemeProvider(): void
HTML, - LineEndingNormalizer::normalize( - HGroup::tag()->addThemeProvider('muted', DefaultThemeProvider::class)->render(), - ), + HGroup::tag() + ->addThemeProvider('muted', DefaultThemeProvider::class) + ->render(), "Failed asserting that element renders correctly with 'addThemeProvider()' method.", ); } @@ -636,7 +618,9 @@ public function testRenderWithTitle(): void
HTML, - HGroup::tag()->title('value')->render(), + HGroup::tag() + ->title('value') + ->render(), "Failed asserting that element renders correctly with 'title' attribute.", ); } @@ -648,9 +632,7 @@ public function testRenderWithToString(): void
HTML, - LineEndingNormalizer::normalize( - (string) HGroup::tag(), - ), + (string) HGroup::tag(), "Failed asserting that '__toString()' method renders correctly.", ); } @@ -662,9 +644,9 @@ public function testRenderWithTranslate(): void
HTML, - LineEndingNormalizer::normalize( - HGroup::tag()->translate(false)->render(), - ), + HGroup::tag() + ->translate(false) + ->render(), "Failed asserting that element renders correctly with 'translate' attribute.", ); } @@ -676,9 +658,9 @@ public function testRenderWithTranslateUsingEnum(): void
HTML, - LineEndingNormalizer::normalize( - HGroup::tag()->translate(Translate::NO)->render(), - ), + HGroup::tag() + ->translate(Translate::NO) + ->render(), "Failed asserting that element renders correctly with 'translate' attribute using enum.", ); } @@ -692,9 +674,7 @@ public function testRenderWithUserOverridesGlobalDefaults(): void
HTML, - LineEndingNormalizer::normalize( - HGroup::tag(['id' => 'id-user'])->render(), - ), + HGroup::tag(['id' => 'id-user'])->render(), 'Failed asserting that user-defined attributes override global defaults correctly.', ); diff --git a/tests/List/DdTest.php b/tests/List/DdTest.php index b1430d7..26089cf 100644 --- a/tests/List/DdTest.php +++ b/tests/List/DdTest.php @@ -4,7 +4,6 @@ namespace UIAwesome\Html\Tests\List; -use PHPForge\Support\LineEndingNormalizer; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use UIAwesome\Html\Attribute\Values\{ @@ -34,17 +33,16 @@ * @copyright Copyright (C) 2026 Terabytesoftw. * @license https://opensource.org/license/bsd-3-clause BSD 3-Clause License. */ -#[Group('html')] #[Group('list')] final class DdTest extends TestCase { public function testContentEncodesValues(): void { - $dd = Dd::tag()->content(''); - self::assertSame( '<value>', - $dd->getContent(), + Dd::tag() + ->content('') + ->getContent(), "Failed asserting that 'content()' method encodes values correctly.", ); } @@ -62,7 +60,9 @@ public function testGetAttributesReturnsAssignedAttributes(): void { self::assertSame( ['data-test' => 'value'], - Dd::tag()->addAttribute('data-test', 'value')->getAttributes(), + Dd::tag() + ->addAttribute('data-test', 'value') + ->getAttributes(), "Failed asserting that 'getAttributes()' returns the assigned attributes.", ); } @@ -75,9 +75,9 @@ public function testHtmlDoesNotEncodeValues(): void HTML, - LineEndingNormalizer::normalize( - Dd::tag()->html('')->render(), - ), + Dd::tag() + ->html('') + ->render(), "Failed asserting that element renders correctly with 'html()' method.", ); } @@ -89,9 +89,9 @@ public function testRenderWithAccesskey(): void
HTML, - LineEndingNormalizer::normalize( - Dd::tag()->accesskey('k')->render(), - ), + Dd::tag() + ->accesskey('k') + ->render(), "Failed asserting that element renders correctly with 'accesskey' attribute.", ); } @@ -103,9 +103,9 @@ public function testRenderWithAddAriaAttribute(): void
HTML, - LineEndingNormalizer::normalize( - Dd::tag()->addAriaAttribute('pressed', true)->render(), - ), + Dd::tag() + ->addAriaAttribute('pressed', true) + ->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method.", ); } @@ -117,9 +117,9 @@ public function testRenderWithAddAriaAttributeUsingEnum(): void
HTML, - LineEndingNormalizer::normalize( - Dd::tag()->addAriaAttribute(Aria::PRESSED, true)->render(), - ), + Dd::tag() + ->addAriaAttribute(Aria::PRESSED, true) + ->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method.", ); } @@ -131,9 +131,9 @@ public function testRenderWithAddAttribute(): void
HTML, - LineEndingNormalizer::normalize( - Dd::tag()->addAttribute('data-test', 'value')->render(), - ), + Dd::tag() + ->addAttribute('data-test', 'value') + ->render(), "Failed asserting that element renders correctly with 'addAttribute()' method.", ); } @@ -145,9 +145,9 @@ public function testRenderWithAddAttributeUsingEnum(): void
HTML, - LineEndingNormalizer::normalize( - Dd::tag()->addAttribute(GlobalAttribute::TITLE, 'value')->render(), - ), + Dd::tag() + ->addAttribute(GlobalAttribute::TITLE, 'value') + ->render(), "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", ); } @@ -159,9 +159,9 @@ public function testRenderWithAddDataAttribute(): void
HTML, - LineEndingNormalizer::normalize( - Dd::tag()->addDataAttribute('value', 'value')->render(), - ), + Dd::tag() + ->addDataAttribute('value', 'value') + ->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method.", ); } @@ -173,9 +173,9 @@ public function testRenderWithAddDataAttributeUsingEnum(): void
HTML, - LineEndingNormalizer::normalize( - Dd::tag()->addDataAttribute(Data::VALUE, 'value')->render(), - ), + Dd::tag() + ->addDataAttribute(Data::VALUE, 'value') + ->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method.", ); } @@ -187,17 +187,15 @@ public function testRenderWithAriaAttributes(): void
HTML, - LineEndingNormalizer::normalize( - Dd::tag() - ->ariaAttributes( - [ - 'controls' => static fn(): string => 'modal-1', - 'hidden' => false, - 'label' => 'Close', - ], - ) - ->render(), - ), + Dd::tag() + ->ariaAttributes( + [ + 'controls' => static fn(): string => 'modal-1', + 'hidden' => false, + 'label' => 'Close', + ], + ) + ->render(), "Failed asserting that element renders correctly with 'ariaAttributes()' method.", ); } @@ -209,9 +207,9 @@ public function testRenderWithAttributes(): void
HTML, - LineEndingNormalizer::normalize( - Dd::tag()->attributes(['class' => 'value'])->render(), - ), + Dd::tag() + ->attributes(['class' => 'value']) + ->render(), "Failed asserting that element renders correctly with 'attributes()' method.", ); } @@ -223,9 +221,9 @@ public function testRenderWithAutofocus(): void
HTML, - LineEndingNormalizer::normalize( - Dd::tag()->autofocus(true)->render(), - ), + Dd::tag() + ->autofocus(true) + ->render(), "Failed asserting that element renders correctly with 'autofocus' attribute.", ); } @@ -238,9 +236,7 @@ public function testRenderWithBeginEnd(): void Content HTML, - LineEndingNormalizer::normalize( - Dd::tag()->begin() . 'Content' . Dd::end(), - ), + Dd::tag()->begin() . 'Content' . Dd::end(), "Failed asserting that element renders correctly with 'begin()' and 'end()' methods.", ); } @@ -252,9 +248,9 @@ public function testRenderWithClass(): void
HTML, - LineEndingNormalizer::normalize( - Dd::tag()->class('value')->render(), - ), + Dd::tag() + ->class('value') + ->render(), "Failed asserting that element renders correctly with 'class' attribute.", ); } @@ -267,9 +263,9 @@ public function testRenderWithContent(): void value HTML, - LineEndingNormalizer::normalize( - Dd::tag()->content('value')->render(), - ), + Dd::tag() + ->content('value') + ->render(), 'Failed asserting that element renders correctly with default values.', ); } @@ -281,9 +277,9 @@ public function testRenderWithContentEditable(): void
HTML, - LineEndingNormalizer::normalize( - Dd::tag()->contentEditable(true)->render(), - ), + Dd::tag() + ->contentEditable(true) + ->render(), "Failed asserting that element renders correctly with 'contentEditable' attribute.", ); } @@ -295,9 +291,9 @@ public function testRenderWithContentEditableUsingEnum(): void
HTML, - LineEndingNormalizer::normalize( - Dd::tag()->contentEditable(ContentEditable::TRUE)->render(), - ), + Dd::tag() + ->contentEditable(ContentEditable::TRUE) + ->render(), "Failed asserting that element renders correctly with 'contentEditable' attribute using enum.", ); } @@ -309,9 +305,9 @@ public function testRenderWithDataAttributes(): void
HTML, - LineEndingNormalizer::normalize( - Dd::tag()->dataAttributes(['value' => 'value'])->render(), - ), + Dd::tag() + ->dataAttributes(['value' => 'value']) + ->render(), "Failed asserting that element renders correctly with 'dataAttributes()' method.", ); } @@ -323,9 +319,7 @@ public function testRenderWithDefaultConfigurationValues(): void
HTML, - LineEndingNormalizer::normalize( - Dd::tag(['class' => 'default-class'])->render(), - ), + Dd::tag(['class' => 'default-class'])->render(), 'Failed asserting that default configuration values are applied correctly.', ); } @@ -337,9 +331,9 @@ public function testRenderWithDefaultProvider(): void
HTML, - LineEndingNormalizer::normalize( - Dd::tag()->addDefaultProvider(DefaultProvider::class)->render(), - ), + Dd::tag() + ->addDefaultProvider(DefaultProvider::class) + ->render(), 'Failed asserting that default provider is applied correctly.', ); } @@ -351,9 +345,9 @@ public function testRenderWithDir(): void
HTML, - LineEndingNormalizer::normalize( - Dd::tag()->dir('ltr')->render(), - ), + Dd::tag() + ->dir('ltr') + ->render(), "Failed asserting that element renders correctly with 'dir' attribute.", ); } @@ -365,9 +359,9 @@ public function testRenderWithDirUsingEnum(): void
HTML, - LineEndingNormalizer::normalize( - Dd::tag()->dir(Direction::LTR)->render(), - ), + Dd::tag() + ->dir(Direction::LTR) + ->render(), "Failed asserting that element renders correctly with 'dir' attribute using enum.", ); } @@ -379,9 +373,9 @@ public function testRenderWithDraggable(): void
HTML, - LineEndingNormalizer::normalize( - Dd::tag()->draggable(true)->render(), - ), + Dd::tag() + ->draggable(true) + ->render(), "Failed asserting that element renders correctly with 'draggable' attribute.", ); } @@ -393,9 +387,9 @@ public function testRenderWithDraggableUsingEnum(): void
HTML, - LineEndingNormalizer::normalize( - Dd::tag()->draggable(Draggable::TRUE)->render(), - ), + Dd::tag() + ->draggable(Draggable::TRUE) + ->render(), "Failed asserting that element renders correctly with 'draggable' attribute using enum.", ); } @@ -409,9 +403,7 @@ public function testRenderWithGlobalDefaultsAreApplied(): void
HTML, - LineEndingNormalizer::normalize( - Dd::tag()->render(), - ), + Dd::tag()->render(), 'Failed asserting that global defaults are applied correctly.', ); @@ -425,9 +417,9 @@ public function testRenderWithHidden(): void HTML, - LineEndingNormalizer::normalize( - Dd::tag()->hidden(true)->render(), - ), + Dd::tag() + ->hidden(true) + ->render(), "Failed asserting that element renders correctly with 'hidden' attribute.", ); } @@ -439,9 +431,9 @@ public function testRenderWithId(): void
HTML, - LineEndingNormalizer::normalize( - Dd::tag()->id('test-id')->render(), - ), + Dd::tag() + ->id('test-id') + ->render(), "Failed asserting that element renders correctly with 'id' attribute.", ); } @@ -453,9 +445,9 @@ public function testRenderWithLang(): void
HTML, - LineEndingNormalizer::normalize( - Dd::tag()->lang('es')->render(), - ), + Dd::tag() + ->lang('es') + ->render(), "Failed asserting that element renders correctly with 'lang' attribute.", ); } @@ -467,9 +459,9 @@ public function testRenderWithLangUsingEnum(): void
HTML, - LineEndingNormalizer::normalize( - Dd::tag()->lang(Language::SPANISH)->render(), - ), + Dd::tag() + ->lang(Language::SPANISH) + ->render(), "Failed asserting that element renders correctly with 'lang' attribute using enum.", ); } @@ -481,15 +473,13 @@ public function testRenderWithMicroData(): void
HTML, - LineEndingNormalizer::normalize( - Dd::tag() - ->itemId('https://example.com/item') - ->itemProp('name') - ->itemRef('info') - ->itemScope(true) - ->itemType('https://schema.org/Thing') - ->render(), - ), + Dd::tag() + ->itemId('https://example.com/item') + ->itemProp('name') + ->itemRef('info') + ->itemScope(true) + ->itemType('https://schema.org/Thing') + ->render(), 'Failed asserting that element renders correctly with microdata attributes.', ); } @@ -501,12 +491,10 @@ public function testRenderWithRemoveAriaAttribute(): void
HTML, - LineEndingNormalizer::normalize( - Dd::tag() - ->addAriaAttribute('label', 'Close') - ->removeAriaAttribute('label') - ->render(), - ), + Dd::tag() + ->addAriaAttribute('label', 'Close') + ->removeAriaAttribute('label') + ->render(), "Failed asserting that element renders correctly with 'removeAriaAttribute()' method.", ); } @@ -518,12 +506,10 @@ public function testRenderWithRemoveAttribute(): void
HTML, - LineEndingNormalizer::normalize( - Dd::tag() - ->addAttribute('data-test', 'value') - ->removeAttribute('data-test') - ->render(), - ), + Dd::tag() + ->addAttribute('data-test', 'value') + ->removeAttribute('data-test') + ->render(), "Failed asserting that element renders correctly with 'removeAttribute()' method.", ); } @@ -535,12 +521,10 @@ public function testRenderWithRemoveDataAttribute(): void
HTML, - LineEndingNormalizer::normalize( - Dd::tag() - ->addDataAttribute('value', 'test') - ->removeDataAttribute('value') - ->render(), - ), + Dd::tag() + ->addDataAttribute('value', 'test') + ->removeDataAttribute('value') + ->render(), "Failed asserting that element renders correctly with 'removeDataAttribute()' method.", ); } @@ -552,9 +536,9 @@ public function testRenderWithRole(): void
HTML, - LineEndingNormalizer::normalize( - Dd::tag()->role('definition')->render(), - ), + Dd::tag() + ->role('definition') + ->render(), "Failed asserting that element renders correctly with 'role' attribute.", ); } @@ -566,9 +550,9 @@ public function testRenderWithRoleUsingEnum(): void
HTML, - LineEndingNormalizer::normalize( - Dd::tag()->role(Role::DEFINITION)->render(), - ), + Dd::tag() + ->role(Role::DEFINITION) + ->render(), "Failed asserting that element renders correctly with 'role' attribute using enum.", ); } @@ -580,9 +564,9 @@ public function testRenderWithSpellcheck(): void
HTML, - LineEndingNormalizer::normalize( - Dd::tag()->spellcheck(true)->render(), - ), + Dd::tag() + ->spellcheck(true) + ->render(), "Failed asserting that element renders correctly with 'spellcheck' attribute.", ); } @@ -594,9 +578,9 @@ public function testRenderWithStyle(): void
HTML, - LineEndingNormalizer::normalize( - Dd::tag()->style('value')->render(), - ), + Dd::tag() + ->style('value') + ->render(), "Failed asserting that element renders correctly with 'style' attribute.", ); } @@ -608,9 +592,9 @@ public function testRenderWithTabindex(): void
HTML, - LineEndingNormalizer::normalize( - Dd::tag()->tabIndex(3)->render(), - ), + Dd::tag() + ->tabIndex(3) + ->render(), "Failed asserting that element renders correctly with 'tabindex' attribute.", ); } @@ -622,9 +606,9 @@ public function testRenderWithThemeProvider(): void
HTML, - LineEndingNormalizer::normalize( - Dd::tag()->addThemeProvider('muted', DefaultThemeProvider::class)->render(), - ), + Dd::tag() + ->addThemeProvider('muted', DefaultThemeProvider::class) + ->render(), "Failed asserting that element renders correctly with 'addThemeProvider()' method.", ); } @@ -636,9 +620,9 @@ public function testRenderWithTitle(): void
HTML, - LineEndingNormalizer::normalize( - Dd::tag()->title('value')->render(), - ), + Dd::tag() + ->title('value') + ->render(), "Failed asserting that element renders correctly with 'title' attribute.", ); } @@ -650,9 +634,7 @@ public function testRenderWithToString(): void
HTML, - LineEndingNormalizer::normalize( - (string) Dd::tag(), - ), + (string) Dd::tag(), "Failed asserting that '__toString()' method renders correctly.", ); } @@ -664,9 +646,9 @@ public function testRenderWithTranslate(): void
HTML, - LineEndingNormalizer::normalize( - Dd::tag()->translate(false)->render(), - ), + Dd::tag() + ->translate(false) + ->render(), "Failed asserting that element renders correctly with 'translate' attribute.", ); } @@ -678,9 +660,9 @@ public function testRenderWithTranslateUsingEnum(): void
HTML, - LineEndingNormalizer::normalize( - Dd::tag()->translate(Translate::NO)->render(), - ), + Dd::tag() + ->translate(Translate::NO) + ->render(), "Failed asserting that element renders correctly with 'translate' attribute using enum.", ); } @@ -694,9 +676,7 @@ public function testRenderWithUserOverridesGlobalDefaults(): void
HTML, - LineEndingNormalizer::normalize( - Dd::tag(['id' => 'id-user'])->render(), - ), + Dd::tag(['id' => 'id-user'])->render(), 'Failed asserting that user-defined attributes override global defaults correctly.', ); diff --git a/tests/List/DlTest.php b/tests/List/DlTest.php index e919dda..cf4060b 100644 --- a/tests/List/DlTest.php +++ b/tests/List/DlTest.php @@ -4,7 +4,6 @@ namespace UIAwesome\Html\Tests\List; -use PHPForge\Support\LineEndingNormalizer; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use UIAwesome\Html\Attribute\Values\{ @@ -34,17 +33,16 @@ * @copyright Copyright (C) 2026 Terabytesoftw. * @license https://opensource.org/license/bsd-3-clause BSD 3-Clause License. */ -#[Group('html')] #[Group('list')] final class DlTest extends TestCase { public function testContentEncodesValues(): void { - $dl = Dl::tag()->content(''); - self::assertSame( '<value>', - $dl->getContent(), + Dl::tag() + ->content('') + ->getContent(), "Failed asserting that 'content()' method encodes values correctly.", ); } @@ -62,7 +60,9 @@ public function testGetAttributesReturnsAssignedAttributes(): void { self::assertSame( ['data-test' => 'value'], - Dl::tag()->addAttribute('data-test', 'value')->getAttributes(), + Dl::tag() + ->addAttribute('data-test', 'value') + ->getAttributes(), "Failed asserting that 'getAttributes()' returns the assigned attributes.", ); } @@ -75,9 +75,9 @@ public function testHtmlDoesNotEncodeValues(): void HTML, - LineEndingNormalizer::normalize( - Dl::tag()->html('')->render(), - ), + Dl::tag() + ->html('') + ->render(), "Failed asserting that element renders correctly with 'html()' method.", ); } @@ -89,9 +89,9 @@ public function testRenderWithAccesskey(): void
HTML, - LineEndingNormalizer::normalize( - Dl::tag()->accesskey('k')->render(), - ), + Dl::tag() + ->accesskey('k') + ->render(), "Failed asserting that element renders correctly with 'accesskey' attribute.", ); } @@ -103,9 +103,9 @@ public function testRenderWithAddAriaAttribute(): void
HTML, - LineEndingNormalizer::normalize( - Dl::tag()->addAriaAttribute('pressed', true)->render(), - ), + Dl::tag() + ->addAriaAttribute('pressed', true) + ->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method.", ); } @@ -117,9 +117,9 @@ public function testRenderWithAddAriaAttributeUsingEnum(): void
HTML, - LineEndingNormalizer::normalize( - Dl::tag()->addAriaAttribute(Aria::PRESSED, true)->render(), - ), + Dl::tag() + ->addAriaAttribute(Aria::PRESSED, true) + ->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method.", ); } @@ -131,9 +131,9 @@ public function testRenderWithAddAttribute(): void
HTML, - LineEndingNormalizer::normalize( - Dl::tag()->addAttribute('data-test', 'value')->render(), - ), + Dl::tag() + ->addAttribute('data-test', 'value') + ->render(), "Failed asserting that element renders correctly with 'addAttribute()' method.", ); } @@ -145,9 +145,9 @@ public function testRenderWithAddAttributeUsingEnum(): void
HTML, - LineEndingNormalizer::normalize( - Dl::tag()->addAttribute(GlobalAttribute::TITLE, 'value')->render(), - ), + Dl::tag() + ->addAttribute(GlobalAttribute::TITLE, 'value') + ->render(), "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", ); } @@ -159,9 +159,9 @@ public function testRenderWithAddDataAttribute(): void
HTML, - LineEndingNormalizer::normalize( - Dl::tag()->addDataAttribute('value', 'value')->render(), - ), + Dl::tag() + ->addDataAttribute('value', 'value') + ->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method.", ); } @@ -173,9 +173,9 @@ public function testRenderWithAddDataAttributeUsingEnum(): void
HTML, - LineEndingNormalizer::normalize( - Dl::tag()->addDataAttribute(Data::VALUE, 'value')->render(), - ), + Dl::tag() + ->addDataAttribute(Data::VALUE, 'value') + ->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method.", ); } @@ -187,17 +187,15 @@ public function testRenderWithAriaAttributes(): void
HTML, - LineEndingNormalizer::normalize( - Dl::tag() - ->ariaAttributes( - [ - 'controls' => static fn(): string => 'modal-1', - 'hidden' => false, - 'label' => 'Close', - ], - ) - ->render(), - ), + Dl::tag() + ->ariaAttributes( + [ + 'controls' => static fn(): string => 'modal-1', + 'hidden' => false, + 'label' => 'Close', + ], + ) + ->render(), "Failed asserting that element renders correctly with 'ariaAttributes()' method.", ); } @@ -209,9 +207,9 @@ public function testRenderWithAttributes(): void
HTML, - LineEndingNormalizer::normalize( - Dl::tag()->attributes(['class' => 'value'])->render(), - ), + Dl::tag() + ->attributes(['class' => 'value']) + ->render(), "Failed asserting that element renders correctly with 'attributes()' method.", ); } @@ -223,9 +221,9 @@ public function testRenderWithAutofocus(): void
HTML, - LineEndingNormalizer::normalize( - Dl::tag()->autofocus(true)->render(), - ), + Dl::tag() + ->autofocus(true) + ->render(), "Failed asserting that element renders correctly with 'autofocus' attribute.", ); } @@ -238,9 +236,7 @@ public function testRenderWithBeginEnd(): void Content HTML, - LineEndingNormalizer::normalize( - Dl::tag()->begin() . 'Content' . Dl::end(), - ), + Dl::tag()->begin() . 'Content' . Dl::end(), "Failed asserting that element renders correctly with 'begin()' and 'end()' methods.", ); } @@ -252,9 +248,9 @@ public function testRenderWithClass(): void
HTML, - LineEndingNormalizer::normalize( - Dl::tag()->class('value')->render(), - ), + Dl::tag() + ->class('value') + ->render(), "Failed asserting that element renders correctly with 'class' attribute.", ); } @@ -267,9 +263,9 @@ public function testRenderWithContent(): void value HTML, - LineEndingNormalizer::normalize( - Dl::tag()->content('value')->render(), - ), + Dl::tag() + ->content('value') + ->render(), 'Failed asserting that element renders correctly with default values.', ); } @@ -281,9 +277,9 @@ public function testRenderWithContentEditable(): void
HTML, - LineEndingNormalizer::normalize( - Dl::tag()->contentEditable(true)->render(), - ), + Dl::tag() + ->contentEditable(true) + ->render(), "Failed asserting that element renders correctly with 'contentEditable' attribute.", ); } @@ -295,9 +291,9 @@ public function testRenderWithContentEditableUsingEnum(): void
HTML, - LineEndingNormalizer::normalize( - Dl::tag()->contentEditable(ContentEditable::TRUE)->render(), - ), + Dl::tag() + ->contentEditable(ContentEditable::TRUE) + ->render(), "Failed asserting that element renders correctly with 'contentEditable' attribute using enum.", ); } @@ -309,9 +305,9 @@ public function testRenderWithDataAttributes(): void
HTML, - LineEndingNormalizer::normalize( - Dl::tag()->dataAttributes(['value' => 'value'])->render(), - ), + Dl::tag() + ->dataAttributes(['value' => 'value']) + ->render(), "Failed asserting that element renders correctly with 'dataAttributes()' method.", ); } @@ -329,9 +325,10 @@ public function testRenderWithDd(): void HTML, - LineEndingNormalizer::normalize( - Dl::tag()->dd('First description')->dd('Second description')->render(), - ), + Dl::tag() + ->dd('First description') + ->dd('Second description') + ->render(), "Failed asserting that element renders correctly with 'dd()' method.", ); } @@ -343,9 +340,7 @@ public function testRenderWithDefaultConfigurationValues(): void
HTML, - LineEndingNormalizer::normalize( - Dl::tag(['class' => 'default-class'])->render(), - ), + Dl::tag(['class' => 'default-class'])->render(), 'Failed asserting that default configuration values are applied correctly.', ); } @@ -357,9 +352,9 @@ public function testRenderWithDefaultProvider(): void
HTML, - LineEndingNormalizer::normalize( - Dl::tag()->addDefaultProvider(DefaultProvider::class)->render(), - ), + Dl::tag() + ->addDefaultProvider(DefaultProvider::class) + ->render(), 'Failed asserting that default provider is applied correctly.', ); } @@ -371,9 +366,9 @@ public function testRenderWithDir(): void
HTML, - LineEndingNormalizer::normalize( - Dl::tag()->dir('ltr')->render(), - ), + Dl::tag() + ->dir('ltr') + ->render(), "Failed asserting that element renders correctly with 'dir' attribute.", ); } @@ -385,9 +380,9 @@ public function testRenderWithDirUsingEnum(): void
HTML, - LineEndingNormalizer::normalize( - Dl::tag()->dir(Direction::LTR)->render(), - ), + Dl::tag() + ->dir(Direction::LTR) + ->render(), "Failed asserting that element renders correctly with 'dir' attribute using enum.", ); } @@ -399,9 +394,9 @@ public function testRenderWithDraggable(): void
HTML, - LineEndingNormalizer::normalize( - Dl::tag()->draggable(true)->render(), - ), + Dl::tag() + ->draggable(true) + ->render(), "Failed asserting that element renders correctly with 'draggable' attribute.", ); } @@ -413,9 +408,9 @@ public function testRenderWithDraggableUsingEnum(): void
HTML, - LineEndingNormalizer::normalize( - Dl::tag()->draggable(Draggable::TRUE)->render(), - ), + Dl::tag() + ->draggable(Draggable::TRUE) + ->render(), "Failed asserting that element renders correctly with 'draggable' attribute using enum.", ); } @@ -433,9 +428,10 @@ public function testRenderWithDt(): void HTML, - LineEndingNormalizer::normalize( - Dl::tag()->dt('First term')->dt('Second term')->render(), - ), + Dl::tag() + ->dt('First term') + ->dt('Second term') + ->render(), "Failed asserting that element renders correctly with 'dt()' method.", ); } @@ -453,9 +449,10 @@ public function testRenderWithDtAndDd(): void HTML, - LineEndingNormalizer::normalize( - Dl::tag()->dt('Term')->dd('Description')->render(), - ), + Dl::tag() + ->dt('Term') + ->dd('Description') + ->render(), "Failed asserting that element renders correctly with 'dt()' and 'dd()' methods.", ); } @@ -469,9 +466,7 @@ public function testRenderWithGlobalDefaultsAreApplied(): void
HTML, - LineEndingNormalizer::normalize( - Dl::tag()->render(), - ), + Dl::tag()->render(), 'Failed asserting that global defaults are applied correctly.', ); @@ -485,9 +480,9 @@ public function testRenderWithHidden(): void HTML, - LineEndingNormalizer::normalize( - Dl::tag()->hidden(true)->render(), - ), + Dl::tag() + ->hidden(true) + ->render(), "Failed asserting that element renders correctly with 'hidden' attribute.", ); } @@ -499,9 +494,9 @@ public function testRenderWithId(): void
HTML, - LineEndingNormalizer::normalize( - Dl::tag()->id('test-id')->render(), - ), + Dl::tag() + ->id('test-id') + ->render(), "Failed asserting that element renders correctly with 'id' attribute.", ); } @@ -513,9 +508,9 @@ public function testRenderWithLang(): void
HTML, - LineEndingNormalizer::normalize( - Dl::tag()->lang('es')->render(), - ), + Dl::tag() + ->lang('es') + ->render(), "Failed asserting that element renders correctly with 'lang' attribute.", ); } @@ -527,9 +522,9 @@ public function testRenderWithLangUsingEnum(): void
HTML, - LineEndingNormalizer::normalize( - Dl::tag()->lang(Language::SPANISH)->render(), - ), + Dl::tag() + ->lang(Language::SPANISH) + ->render(), "Failed asserting that element renders correctly with 'lang' attribute using enum.", ); } @@ -541,15 +536,13 @@ public function testRenderWithMicroData(): void
HTML, - LineEndingNormalizer::normalize( - Dl::tag() - ->itemId('https://example.com/item') - ->itemProp('name') - ->itemRef('info') - ->itemScope(true) - ->itemType('https://schema.org/Thing') - ->render(), - ), + Dl::tag() + ->itemId('https://example.com/item') + ->itemProp('name') + ->itemRef('info') + ->itemScope(true) + ->itemType('https://schema.org/Thing') + ->render(), 'Failed asserting that element renders correctly with microdata attributes.', ); } @@ -561,12 +554,10 @@ public function testRenderWithRemoveAriaAttribute(): void
HTML, - LineEndingNormalizer::normalize( - Dl::tag() - ->addAriaAttribute('label', 'Close') - ->removeAriaAttribute('label') - ->render(), - ), + Dl::tag() + ->addAriaAttribute('label', 'Close') + ->removeAriaAttribute('label') + ->render(), "Failed asserting that element renders correctly with 'removeAriaAttribute()' method.", ); } @@ -578,12 +569,10 @@ public function testRenderWithRemoveAttribute(): void
HTML, - LineEndingNormalizer::normalize( - Dl::tag() - ->addAttribute('data-test', 'value') - ->removeAttribute('data-test') - ->render(), - ), + Dl::tag() + ->addAttribute('data-test', 'value') + ->removeAttribute('data-test') + ->render(), "Failed asserting that element renders correctly with 'removeAttribute()' method.", ); } @@ -595,12 +584,10 @@ public function testRenderWithRemoveDataAttribute(): void
HTML, - LineEndingNormalizer::normalize( - Dl::tag() - ->addDataAttribute('value', 'test') - ->removeDataAttribute('value') - ->render(), - ), + Dl::tag() + ->addDataAttribute('value', 'test') + ->removeDataAttribute('value') + ->render(), "Failed asserting that element renders correctly with 'removeDataAttribute()' method.", ); } @@ -612,9 +599,9 @@ public function testRenderWithRole(): void
HTML, - LineEndingNormalizer::normalize( - Dl::tag()->role('list')->render(), - ), + Dl::tag() + ->role('list') + ->render(), "Failed asserting that element renders correctly with 'role' attribute.", ); } @@ -626,9 +613,9 @@ public function testRenderWithRoleUsingEnum(): void
HTML, - LineEndingNormalizer::normalize( - Dl::tag()->role(Role::LIST)->render(), - ), + Dl::tag() + ->role(Role::LIST) + ->render(), "Failed asserting that element renders correctly with 'role' attribute using enum.", ); } @@ -640,9 +627,9 @@ public function testRenderWithSpellcheck(): void
HTML, - LineEndingNormalizer::normalize( - Dl::tag()->spellcheck(true)->render(), - ), + Dl::tag() + ->spellcheck(true) + ->render(), "Failed asserting that element renders correctly with 'spellcheck' attribute.", ); } @@ -654,9 +641,9 @@ public function testRenderWithStyle(): void
HTML, - LineEndingNormalizer::normalize( - Dl::tag()->style('value')->render(), - ), + Dl::tag() + ->style('value') + ->render(), "Failed asserting that element renders correctly with 'style' attribute.", ); } @@ -668,9 +655,9 @@ public function testRenderWithTabindex(): void
HTML, - LineEndingNormalizer::normalize( - Dl::tag()->tabIndex(3)->render(), - ), + Dl::tag() + ->tabIndex(3) + ->render(), "Failed asserting that element renders correctly with 'tabindex' attribute.", ); } @@ -682,9 +669,9 @@ public function testRenderWithThemeProvider(): void
HTML, - LineEndingNormalizer::normalize( - Dl::tag()->addThemeProvider('muted', DefaultThemeProvider::class)->render(), - ), + Dl::tag() + ->addThemeProvider('muted', DefaultThemeProvider::class) + ->render(), "Failed asserting that element renders correctly with 'addThemeProvider()' method.", ); } @@ -696,9 +683,9 @@ public function testRenderWithTitle(): void
HTML, - LineEndingNormalizer::normalize( - Dl::tag()->title('value')->render(), - ), + Dl::tag() + ->title('value') + ->render(), "Failed asserting that element renders correctly with 'title' attribute.", ); } @@ -710,9 +697,7 @@ public function testRenderWithToString(): void
HTML, - LineEndingNormalizer::normalize( - (string) Dl::tag(), - ), + (string) Dl::tag(), "Failed asserting that '__toString()' method renders correctly.", ); } @@ -724,9 +709,9 @@ public function testRenderWithTranslate(): void
HTML, - LineEndingNormalizer::normalize( - Dl::tag()->translate(false)->render(), - ), + Dl::tag() + ->translate(false) + ->render(), "Failed asserting that element renders correctly with 'translate' attribute.", ); } @@ -738,9 +723,9 @@ public function testRenderWithTranslateUsingEnum(): void
HTML, - LineEndingNormalizer::normalize( - Dl::tag()->translate(Translate::NO)->render(), - ), + Dl::tag() + ->translate(Translate::NO) + ->render(), "Failed asserting that element renders correctly with 'translate' attribute using enum.", ); } @@ -754,9 +739,7 @@ public function testRenderWithUserOverridesGlobalDefaults(): void
HTML, - LineEndingNormalizer::normalize( - Dl::tag(['id' => 'id-user'])->render(), - ), + Dl::tag(['id' => 'id-user'])->render(), 'Failed asserting that user-defined attributes override global defaults correctly.', ); diff --git a/tests/List/DtTest.php b/tests/List/DtTest.php index 25ad6ca..dafef19 100644 --- a/tests/List/DtTest.php +++ b/tests/List/DtTest.php @@ -4,7 +4,6 @@ namespace UIAwesome\Html\Tests\List; -use PHPForge\Support\LineEndingNormalizer; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use UIAwesome\Html\Attribute\Values\{ @@ -34,17 +33,16 @@ * @copyright Copyright (C) 2026 Terabytesoftw. * @license https://opensource.org/license/bsd-3-clause BSD 3-Clause License. */ -#[Group('html')] #[Group('list')] final class DtTest extends TestCase { public function testContentEncodesValues(): void { - $dt = Dt::tag()->content(''); - self::assertSame( '<value>', - $dt->getContent(), + Dt::tag() + ->content('') + ->getContent(), "Failed asserting that 'content()' method encodes values correctly.", ); } @@ -62,7 +60,9 @@ public function testGetAttributesReturnsAssignedAttributes(): void { self::assertSame( ['data-test' => 'value'], - Dt::tag()->addAttribute('data-test', 'value')->getAttributes(), + Dt::tag() + ->addAttribute('data-test', 'value') + ->getAttributes(), "Failed asserting that 'getAttributes()' returns the assigned attributes.", ); } @@ -75,9 +75,9 @@ public function testHtmlDoesNotEncodeValues(): void HTML, - LineEndingNormalizer::normalize( - Dt::tag()->html('')->render(), - ), + Dt::tag() + ->html('') + ->render(), "Failed asserting that element renders correctly with 'html()' method.", ); } @@ -89,9 +89,9 @@ public function testRenderWithAccesskey(): void
HTML, - LineEndingNormalizer::normalize( - Dt::tag()->accesskey('k')->render(), - ), + Dt::tag() + ->accesskey('k') + ->render(), "Failed asserting that element renders correctly with 'accesskey' attribute.", ); } @@ -103,9 +103,9 @@ public function testRenderWithAddAriaAttribute(): void
HTML, - LineEndingNormalizer::normalize( - Dt::tag()->addAriaAttribute('pressed', true)->render(), - ), + Dt::tag() + ->addAriaAttribute('pressed', true) + ->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method.", ); } @@ -117,9 +117,9 @@ public function testRenderWithAddAriaAttributeUsingEnum(): void
HTML, - LineEndingNormalizer::normalize( - Dt::tag()->addAriaAttribute(Aria::PRESSED, true)->render(), - ), + Dt::tag() + ->addAriaAttribute(Aria::PRESSED, true) + ->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method.", ); } @@ -131,9 +131,9 @@ public function testRenderWithAddAttribute(): void
HTML, - LineEndingNormalizer::normalize( - Dt::tag()->addAttribute('data-test', 'value')->render(), - ), + Dt::tag() + ->addAttribute('data-test', 'value') + ->render(), "Failed asserting that element renders correctly with 'addAttribute()' method.", ); } @@ -145,9 +145,9 @@ public function testRenderWithAddAttributeUsingEnum(): void
HTML, - LineEndingNormalizer::normalize( - Dt::tag()->addAttribute(GlobalAttribute::TITLE, 'value')->render(), - ), + Dt::tag() + ->addAttribute(GlobalAttribute::TITLE, 'value') + ->render(), "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", ); } @@ -159,9 +159,9 @@ public function testRenderWithAddDataAttribute(): void
HTML, - LineEndingNormalizer::normalize( - Dt::tag()->addDataAttribute('value', 'value')->render(), - ), + Dt::tag() + ->addDataAttribute('value', 'value') + ->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method.", ); } @@ -173,9 +173,9 @@ public function testRenderWithAddDataAttributeUsingEnum(): void
HTML, - LineEndingNormalizer::normalize( - Dt::tag()->addDataAttribute(Data::VALUE, 'value')->render(), - ), + Dt::tag() + ->addDataAttribute(Data::VALUE, 'value') + ->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method.", ); } @@ -187,17 +187,15 @@ public function testRenderWithAriaAttributes(): void
HTML, - LineEndingNormalizer::normalize( - Dt::tag() - ->ariaAttributes( - [ - 'controls' => static fn(): string => 'modal-1', - 'hidden' => false, - 'label' => 'Close', - ], - ) - ->render(), - ), + Dt::tag() + ->ariaAttributes( + [ + 'controls' => static fn(): string => 'modal-1', + 'hidden' => false, + 'label' => 'Close', + ], + ) + ->render(), "Failed asserting that element renders correctly with 'ariaAttributes()' method.", ); } @@ -209,9 +207,9 @@ public function testRenderWithAttributes(): void
HTML, - LineEndingNormalizer::normalize( - Dt::tag()->attributes(['class' => 'value'])->render(), - ), + Dt::tag() + ->attributes(['class' => 'value']) + ->render(), "Failed asserting that element renders correctly with 'attributes()' method.", ); } @@ -223,9 +221,9 @@ public function testRenderWithAutofocus(): void
HTML, - LineEndingNormalizer::normalize( - Dt::tag()->autofocus(true)->render(), - ), + Dt::tag() + ->autofocus(true) + ->render(), "Failed asserting that element renders correctly with 'autofocus' attribute.", ); } @@ -238,9 +236,7 @@ public function testRenderWithBeginEnd(): void Content HTML, - LineEndingNormalizer::normalize( - Dt::tag()->begin() . 'Content' . Dt::end(), - ), + Dt::tag()->begin() . 'Content' . Dt::end(), "Failed asserting that element renders correctly with 'begin()' and 'end()' methods.", ); } @@ -252,9 +248,9 @@ public function testRenderWithClass(): void
HTML, - LineEndingNormalizer::normalize( - Dt::tag()->class('value')->render(), - ), + Dt::tag() + ->class('value') + ->render(), "Failed asserting that element renders correctly with 'class' attribute.", ); } @@ -267,9 +263,9 @@ public function testRenderWithContent(): void value HTML, - LineEndingNormalizer::normalize( - Dt::tag()->content('value')->render(), - ), + Dt::tag() + ->content('value') + ->render(), 'Failed asserting that element renders correctly with default values.', ); } @@ -281,9 +277,9 @@ public function testRenderWithContentEditable(): void
HTML, - LineEndingNormalizer::normalize( - Dt::tag()->contentEditable(true)->render(), - ), + Dt::tag() + ->contentEditable(true) + ->render(), "Failed asserting that element renders correctly with 'contentEditable' attribute.", ); } @@ -295,9 +291,9 @@ public function testRenderWithContentEditableUsingEnum(): void
HTML, - LineEndingNormalizer::normalize( - Dt::tag()->contentEditable(ContentEditable::TRUE)->render(), - ), + Dt::tag() + ->contentEditable(ContentEditable::TRUE) + ->render(), "Failed asserting that element renders correctly with 'contentEditable' attribute using enum.", ); } @@ -309,9 +305,9 @@ public function testRenderWithDataAttributes(): void
HTML, - LineEndingNormalizer::normalize( - Dt::tag()->dataAttributes(['value' => 'value'])->render(), - ), + Dt::tag() + ->dataAttributes(['value' => 'value']) + ->render(), "Failed asserting that element renders correctly with 'dataAttributes()' method.", ); } @@ -323,9 +319,7 @@ public function testRenderWithDefaultConfigurationValues(): void
HTML, - LineEndingNormalizer::normalize( - Dt::tag(['class' => 'default-class'])->render(), - ), + Dt::tag(['class' => 'default-class'])->render(), 'Failed asserting that default configuration values are applied correctly.', ); } @@ -337,9 +331,9 @@ public function testRenderWithDefaultProvider(): void
HTML, - LineEndingNormalizer::normalize( - Dt::tag()->addDefaultProvider(DefaultProvider::class)->render(), - ), + Dt::tag() + ->addDefaultProvider(DefaultProvider::class) + ->render(), 'Failed asserting that default provider is applied correctly.', ); } @@ -351,9 +345,9 @@ public function testRenderWithDir(): void
HTML, - LineEndingNormalizer::normalize( - Dt::tag()->dir('ltr')->render(), - ), + Dt::tag() + ->dir('ltr') + ->render(), "Failed asserting that element renders correctly with 'dir' attribute.", ); } @@ -365,9 +359,9 @@ public function testRenderWithDirUsingEnum(): void
HTML, - LineEndingNormalizer::normalize( - Dt::tag()->dir(Direction::LTR)->render(), - ), + Dt::tag() + ->dir(Direction::LTR) + ->render(), "Failed asserting that element renders correctly with 'dir' attribute using enum.", ); } @@ -379,9 +373,9 @@ public function testRenderWithDraggable(): void
HTML, - LineEndingNormalizer::normalize( - Dt::tag()->draggable(true)->render(), - ), + Dt::tag() + ->draggable(true) + ->render(), "Failed asserting that element renders correctly with 'draggable' attribute.", ); } @@ -393,9 +387,9 @@ public function testRenderWithDraggableUsingEnum(): void
HTML, - LineEndingNormalizer::normalize( - Dt::tag()->draggable(Draggable::TRUE)->render(), - ), + Dt::tag() + ->draggable(Draggable::TRUE) + ->render(), "Failed asserting that element renders correctly with 'draggable' attribute using enum.", ); } @@ -409,9 +403,7 @@ public function testRenderWithGlobalDefaultsAreApplied(): void
HTML, - LineEndingNormalizer::normalize( - Dt::tag()->render(), - ), + Dt::tag()->render(), 'Failed asserting that global defaults are applied correctly.', ); @@ -425,9 +417,9 @@ public function testRenderWithHidden(): void HTML, - LineEndingNormalizer::normalize( - Dt::tag()->hidden(true)->render(), - ), + Dt::tag() + ->hidden(true) + ->render(), "Failed asserting that element renders correctly with 'hidden' attribute.", ); } @@ -439,9 +431,9 @@ public function testRenderWithId(): void
HTML, - LineEndingNormalizer::normalize( - Dt::tag()->id('test-id')->render(), - ), + Dt::tag() + ->id('test-id') + ->render(), "Failed asserting that element renders correctly with 'id' attribute.", ); } @@ -453,9 +445,9 @@ public function testRenderWithLang(): void
HTML, - LineEndingNormalizer::normalize( - Dt::tag()->lang('es')->render(), - ), + Dt::tag() + ->lang('es') + ->render(), "Failed asserting that element renders correctly with 'lang' attribute.", ); } @@ -467,9 +459,9 @@ public function testRenderWithLangUsingEnum(): void
HTML, - LineEndingNormalizer::normalize( - Dt::tag()->lang(Language::SPANISH)->render(), - ), + Dt::tag() + ->lang(Language::SPANISH) + ->render(), "Failed asserting that element renders correctly with 'lang' attribute using enum.", ); } @@ -481,15 +473,13 @@ public function testRenderWithMicroData(): void
HTML, - LineEndingNormalizer::normalize( - Dt::tag() - ->itemId('https://example.com/item') - ->itemProp('name') - ->itemRef('info') - ->itemScope(true) - ->itemType('https://schema.org/Thing') - ->render(), - ), + Dt::tag() + ->itemId('https://example.com/item') + ->itemProp('name') + ->itemRef('info') + ->itemScope(true) + ->itemType('https://schema.org/Thing') + ->render(), 'Failed asserting that element renders correctly with microdata attributes.', ); } @@ -501,12 +491,10 @@ public function testRenderWithRemoveAriaAttribute(): void
HTML, - LineEndingNormalizer::normalize( - Dt::tag() - ->addAriaAttribute('label', 'Close') - ->removeAriaAttribute('label') - ->render(), - ), + Dt::tag() + ->addAriaAttribute('label', 'Close') + ->removeAriaAttribute('label') + ->render(), "Failed asserting that element renders correctly with 'removeAriaAttribute()' method.", ); } @@ -518,12 +506,10 @@ public function testRenderWithRemoveAttribute(): void
HTML, - LineEndingNormalizer::normalize( - Dt::tag() - ->addAttribute('data-test', 'value') - ->removeAttribute('data-test') - ->render(), - ), + Dt::tag() + ->addAttribute('data-test', 'value') + ->removeAttribute('data-test') + ->render(), "Failed asserting that element renders correctly with 'removeAttribute()' method.", ); } @@ -535,12 +521,10 @@ public function testRenderWithRemoveDataAttribute(): void
HTML, - LineEndingNormalizer::normalize( - Dt::tag() - ->addDataAttribute('value', 'test') - ->removeDataAttribute('value') - ->render(), - ), + Dt::tag() + ->addDataAttribute('value', 'test') + ->removeDataAttribute('value') + ->render(), "Failed asserting that element renders correctly with 'removeDataAttribute()' method.", ); } @@ -552,9 +536,9 @@ public function testRenderWithRole(): void
HTML, - LineEndingNormalizer::normalize( - Dt::tag()->role('listitem')->render(), - ), + Dt::tag() + ->role('listitem') + ->render(), "Failed asserting that element renders correctly with 'role' attribute.", ); } @@ -566,9 +550,9 @@ public function testRenderWithRoleUsingEnum(): void
HTML, - LineEndingNormalizer::normalize( - Dt::tag()->role(Role::LISTITEM)->render(), - ), + Dt::tag() + ->role(Role::LISTITEM) + ->render(), "Failed asserting that element renders correctly with 'role' attribute using enum.", ); } @@ -580,9 +564,9 @@ public function testRenderWithSpellcheck(): void
HTML, - LineEndingNormalizer::normalize( - Dt::tag()->spellcheck(true)->render(), - ), + Dt::tag() + ->spellcheck(true) + ->render(), "Failed asserting that element renders correctly with 'spellcheck' attribute.", ); } @@ -594,9 +578,9 @@ public function testRenderWithStyle(): void
HTML, - LineEndingNormalizer::normalize( - Dt::tag()->style('value')->render(), - ), + Dt::tag() + ->style('value') + ->render(), "Failed asserting that element renders correctly with 'style' attribute.", ); } @@ -608,9 +592,9 @@ public function testRenderWithTabindex(): void
HTML, - LineEndingNormalizer::normalize( - Dt::tag()->tabIndex(3)->render(), - ), + Dt::tag() + ->tabIndex(3) + ->render(), "Failed asserting that element renders correctly with 'tabindex' attribute.", ); } @@ -622,9 +606,9 @@ public function testRenderWithThemeProvider(): void
HTML, - LineEndingNormalizer::normalize( - Dt::tag()->addThemeProvider('muted', DefaultThemeProvider::class)->render(), - ), + Dt::tag() + ->addThemeProvider('muted', DefaultThemeProvider::class) + ->render(), "Failed asserting that element renders correctly with 'addThemeProvider()' method.", ); } @@ -636,9 +620,9 @@ public function testRenderWithTitle(): void
HTML, - LineEndingNormalizer::normalize( - Dt::tag()->title('value')->render(), - ), + Dt::tag() + ->title('value') + ->render(), "Failed asserting that element renders correctly with 'title' attribute.", ); } @@ -650,9 +634,7 @@ public function testRenderWithToString(): void
HTML, - LineEndingNormalizer::normalize( - (string) Dt::tag(), - ), + (string) Dt::tag(), "Failed asserting that '__toString()' method renders correctly.", ); } @@ -664,9 +646,9 @@ public function testRenderWithTranslate(): void
HTML, - LineEndingNormalizer::normalize( - Dt::tag()->translate(false)->render(), - ), + Dt::tag() + ->translate(false) + ->render(), "Failed asserting that element renders correctly with 'translate' attribute.", ); } @@ -678,9 +660,9 @@ public function testRenderWithTranslateUsingEnum(): void
HTML, - LineEndingNormalizer::normalize( - Dt::tag()->translate(Translate::NO)->render(), - ), + Dt::tag() + ->translate(Translate::NO) + ->render(), "Failed asserting that element renders correctly with 'translate' attribute using enum.", ); } @@ -694,9 +676,7 @@ public function testRenderWithUserOverridesGlobalDefaults(): void
HTML, - LineEndingNormalizer::normalize( - Dt::tag(['id' => 'id-user'])->render(), - ), + Dt::tag(['id' => 'id-user'])->render(), 'Failed asserting that user-defined attributes override global defaults correctly.', ); diff --git a/tests/List/LiTest.php b/tests/List/LiTest.php index 3f23758..1a2eed2 100644 --- a/tests/List/LiTest.php +++ b/tests/List/LiTest.php @@ -4,7 +4,6 @@ namespace UIAwesome\Html\Tests\List; -use PHPForge\Support\LineEndingNormalizer; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use UIAwesome\Html\Attribute\Values\{ @@ -35,17 +34,16 @@ * @copyright Copyright (C) 2026 Terabytesoftw. * @license https://opensource.org/license/bsd-3-clause BSD 3-Clause License. */ -#[Group('html')] #[Group('list')] final class LiTest extends TestCase { public function testContentEncodesValues(): void { - $li = Li::tag()->content(''); - self::assertSame( '<value>', - $li->getContent(), + Li::tag() + ->content('') + ->getContent(), "Failed asserting that 'content()' method encodes values correctly.", ); } @@ -63,7 +61,9 @@ public function testGetAttributesReturnsAssignedAttributes(): void { self::assertSame( ['data-test' => 'value'], - Li::tag()->addAttribute('data-test', 'value')->getAttributes(), + Li::tag() + ->addAttribute('data-test', 'value') + ->getAttributes(), "Failed asserting that 'getAttributes()' returns the assigned attributes.", ); } @@ -76,9 +76,9 @@ public function testHtmlDoesNotEncodeValues(): void HTML, - LineEndingNormalizer::normalize( - Li::tag()->html('')->render(), - ), + Li::tag() + ->html('') + ->render(), "Failed asserting that element renders correctly with 'html()' method.", ); } @@ -90,9 +90,9 @@ public function testRenderWithAccesskey(): void
  • HTML, - LineEndingNormalizer::normalize( - Li::tag()->accesskey('k')->render(), - ), + Li::tag() + ->accesskey('k') + ->render(), "Failed asserting that element renders correctly with 'accesskey' attribute.", ); } @@ -104,9 +104,9 @@ public function testRenderWithAddAriaAttribute(): void
  • HTML, - LineEndingNormalizer::normalize( - Li::tag()->addAriaAttribute('pressed', true)->render(), - ), + Li::tag() + ->addAriaAttribute('pressed', true) + ->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method.", ); } @@ -118,9 +118,9 @@ public function testRenderWithAddAriaAttributeUsingEnum(): void
  • HTML, - LineEndingNormalizer::normalize( - Li::tag()->addAriaAttribute(Aria::PRESSED, true)->render(), - ), + Li::tag() + ->addAriaAttribute(Aria::PRESSED, true) + ->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method.", ); } @@ -132,9 +132,9 @@ public function testRenderWithAddAttribute(): void
  • HTML, - LineEndingNormalizer::normalize( - Li::tag()->addAttribute('data-test', 'value')->render(), - ), + Li::tag() + ->addAttribute('data-test', 'value') + ->render(), "Failed asserting that element renders correctly with 'addAttribute()' method.", ); } @@ -146,9 +146,9 @@ public function testRenderWithAddAttributeUsingEnum(): void
  • HTML, - LineEndingNormalizer::normalize( - Li::tag()->addAttribute(GlobalAttribute::TITLE, 'value')->render(), - ), + Li::tag() + ->addAttribute(GlobalAttribute::TITLE, 'value') + ->render(), "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", ); } @@ -160,9 +160,9 @@ public function testRenderWithAddDataAttribute(): void
  • HTML, - LineEndingNormalizer::normalize( - Li::tag()->addDataAttribute('value', 'value')->render(), - ), + Li::tag() + ->addDataAttribute('value', 'value') + ->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method.", ); } @@ -174,9 +174,9 @@ public function testRenderWithAddDataAttributeUsingEnum(): void
  • HTML, - LineEndingNormalizer::normalize( - Li::tag()->addDataAttribute(Data::VALUE, 'value')->render(), - ), + Li::tag() + ->addDataAttribute(Data::VALUE, 'value') + ->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method.", ); } @@ -188,17 +188,15 @@ public function testRenderWithAriaAttributes(): void
  • HTML, - LineEndingNormalizer::normalize( - Li::tag() - ->ariaAttributes( - [ - 'controls' => static fn(): string => 'modal-1', - 'hidden' => false, - 'label' => 'Close', - ], - ) - ->render(), - ), + Li::tag() + ->ariaAttributes( + [ + 'controls' => static fn(): string => 'modal-1', + 'hidden' => false, + 'label' => 'Close', + ], + ) + ->render(), "Failed asserting that element renders correctly with 'ariaAttributes()' method.", ); } @@ -210,9 +208,9 @@ public function testRenderWithAttributes(): void
  • HTML, - LineEndingNormalizer::normalize( - Li::tag()->attributes(['class' => 'value'])->render(), - ), + Li::tag() + ->attributes(['class' => 'value']) + ->render(), "Failed asserting that element renders correctly with 'attributes()' method.", ); } @@ -224,9 +222,9 @@ public function testRenderWithAutofocus(): void
  • HTML, - LineEndingNormalizer::normalize( - Li::tag()->autofocus(true)->render(), - ), + Li::tag() + ->autofocus(true) + ->render(), "Failed asserting that element renders correctly with 'autofocus' attribute.", ); } @@ -239,9 +237,7 @@ public function testRenderWithBeginEnd(): void Content HTML, - LineEndingNormalizer::normalize( - Li::tag()->begin() . 'Content' . Li::end(), - ), + Li::tag()->begin() . 'Content' . Li::end(), "Failed asserting that element renders correctly with 'begin()' and 'end()' methods.", ); } @@ -253,9 +249,9 @@ public function testRenderWithClass(): void
  • HTML, - LineEndingNormalizer::normalize( - Li::tag()->class('value')->render(), - ), + Li::tag() + ->class('value') + ->render(), "Failed asserting that element renders correctly with 'class' attribute.", ); } @@ -268,9 +264,9 @@ public function testRenderWithContent(): void value HTML, - LineEndingNormalizer::normalize( - Li::tag()->content('value')->render(), - ), + Li::tag() + ->content('value') + ->render(), 'Failed asserting that element renders correctly with default values.', ); } @@ -282,9 +278,9 @@ public function testRenderWithContentEditable(): void
  • HTML, - LineEndingNormalizer::normalize( - Li::tag()->contentEditable(true)->render(), - ), + Li::tag() + ->contentEditable(true) + ->render(), "Failed asserting that element renders correctly with 'contentEditable' attribute.", ); } @@ -296,9 +292,9 @@ public function testRenderWithContentEditableUsingEnum(): void
  • HTML, - LineEndingNormalizer::normalize( - Li::tag()->contentEditable(ContentEditable::TRUE)->render(), - ), + Li::tag() + ->contentEditable(ContentEditable::TRUE) + ->render(), "Failed asserting that element renders correctly with 'contentEditable' attribute using enum.", ); } @@ -310,9 +306,9 @@ public function testRenderWithDataAttributes(): void
  • HTML, - LineEndingNormalizer::normalize( - Li::tag()->dataAttributes(['value' => 'value'])->render(), - ), + Li::tag() + ->dataAttributes(['value' => 'value']) + ->render(), "Failed asserting that element renders correctly with 'dataAttributes()' method.", ); } @@ -324,9 +320,7 @@ public function testRenderWithDefaultConfigurationValues(): void
  • HTML, - LineEndingNormalizer::normalize( - Li::tag(['class' => 'default-class'])->render(), - ), + Li::tag(['class' => 'default-class'])->render(), 'Failed asserting that default configuration values are applied correctly.', ); } @@ -338,9 +332,9 @@ public function testRenderWithDefaultProvider(): void
  • HTML, - LineEndingNormalizer::normalize( - Li::tag()->addDefaultProvider(DefaultProvider::class)->render(), - ), + Li::tag() + ->addDefaultProvider(DefaultProvider::class) + ->render(), 'Failed asserting that default provider is applied correctly.', ); } @@ -352,9 +346,9 @@ public function testRenderWithDir(): void
  • HTML, - LineEndingNormalizer::normalize( - Li::tag()->dir('ltr')->render(), - ), + Li::tag() + ->dir('ltr') + ->render(), "Failed asserting that element renders correctly with 'dir' attribute.", ); } @@ -366,9 +360,9 @@ public function testRenderWithDirUsingEnum(): void
  • HTML, - LineEndingNormalizer::normalize( - Li::tag()->dir(Direction::LTR)->render(), - ), + Li::tag() + ->dir(Direction::LTR) + ->render(), "Failed asserting that element renders correctly with 'dir' attribute using enum.", ); } @@ -380,9 +374,9 @@ public function testRenderWithDraggable(): void
  • HTML, - LineEndingNormalizer::normalize( - Li::tag()->draggable(true)->render(), - ), + Li::tag() + ->draggable(true) + ->render(), "Failed asserting that element renders correctly with 'draggable' attribute.", ); } @@ -394,9 +388,9 @@ public function testRenderWithDraggableUsingEnum(): void
  • HTML, - LineEndingNormalizer::normalize( - Li::tag()->draggable(Draggable::TRUE)->render(), - ), + Li::tag() + ->draggable(Draggable::TRUE) + ->render(), "Failed asserting that element renders correctly with 'draggable' attribute using enum.", ); } @@ -410,9 +404,7 @@ public function testRenderWithGlobalDefaultsAreApplied(): void
  • HTML, - LineEndingNormalizer::normalize( - Li::tag()->render(), - ), + Li::tag()->render(), 'Failed asserting that global defaults are applied correctly.', ); @@ -426,9 +418,9 @@ public function testRenderWithHidden(): void HTML, - LineEndingNormalizer::normalize( - Li::tag()->hidden(true)->render(), - ), + Li::tag() + ->hidden(true) + ->render(), "Failed asserting that element renders correctly with 'hidden' attribute.", ); } @@ -440,9 +432,9 @@ public function testRenderWithId(): void
  • HTML, - LineEndingNormalizer::normalize( - Li::tag()->id('test-id')->render(), - ), + Li::tag() + ->id('test-id') + ->render(), "Failed asserting that element renders correctly with 'id' attribute.", ); } @@ -454,9 +446,9 @@ public function testRenderWithLang(): void
  • HTML, - LineEndingNormalizer::normalize( - Li::tag()->lang('es')->render(), - ), + Li::tag() + ->lang('es') + ->render(), "Failed asserting that element renders correctly with 'lang' attribute.", ); } @@ -468,9 +460,9 @@ public function testRenderWithLangUsingEnum(): void
  • HTML, - LineEndingNormalizer::normalize( - Li::tag()->lang(Language::SPANISH)->render(), - ), + Li::tag() + ->lang(Language::SPANISH) + ->render(), "Failed asserting that element renders correctly with 'lang' attribute using enum.", ); } @@ -482,15 +474,13 @@ public function testRenderWithMicroData(): void
  • HTML, - LineEndingNormalizer::normalize( - Li::tag() - ->itemId('https://example.com/item') - ->itemProp('name') - ->itemRef('info') - ->itemScope(true) - ->itemType('https://schema.org/Thing') - ->render(), - ), + Li::tag() + ->itemId('https://example.com/item') + ->itemProp('name') + ->itemRef('info') + ->itemScope(true) + ->itemType('https://schema.org/Thing') + ->render(), 'Failed asserting that element renders correctly with microdata attributes.', ); } @@ -503,9 +493,9 @@ public function testRenderWithoutValue(): void Item without value HTML, - LineEndingNormalizer::normalize( - Li::tag()->content('Item without value')->render(), - ), + Li::tag() + ->content('Item without value') + ->render(), "Failed asserting that element renders correctly without 'value' attribute.", ); } @@ -517,12 +507,10 @@ public function testRenderWithRemoveAriaAttribute(): void
  • HTML, - LineEndingNormalizer::normalize( - Li::tag() - ->addAriaAttribute('label', 'Close') - ->removeAriaAttribute('label') - ->render(), - ), + Li::tag() + ->addAriaAttribute('label', 'Close') + ->removeAriaAttribute('label') + ->render(), "Failed asserting that element renders correctly with 'removeAriaAttribute()' method.", ); } @@ -534,12 +522,10 @@ public function testRenderWithRemoveAttribute(): void
  • HTML, - LineEndingNormalizer::normalize( - Li::tag() - ->addAttribute('data-test', 'value') - ->removeAttribute('data-test') - ->render(), - ), + Li::tag() + ->addAttribute('data-test', 'value') + ->removeAttribute('data-test') + ->render(), "Failed asserting that element renders correctly with 'removeAttribute()' method.", ); } @@ -551,12 +537,10 @@ public function testRenderWithRemoveDataAttribute(): void
  • HTML, - LineEndingNormalizer::normalize( - Li::tag() - ->addDataAttribute('value', 'test') - ->removeDataAttribute('value') - ->render(), - ), + Li::tag() + ->addDataAttribute('value', 'test') + ->removeDataAttribute('value') + ->render(), "Failed asserting that element renders correctly with 'removeDataAttribute()' method.", ); } @@ -568,9 +552,9 @@ public function testRenderWithRole(): void
  • HTML, - LineEndingNormalizer::normalize( - Li::tag()->role('listitem')->render(), - ), + Li::tag() + ->role('listitem') + ->render(), "Failed asserting that element renders correctly with 'role' attribute.", ); } @@ -582,9 +566,9 @@ public function testRenderWithRoleUsingEnum(): void
  • HTML, - LineEndingNormalizer::normalize( - Li::tag()->role(Role::LISTITEM)->render(), - ), + Li::tag() + ->role(Role::LISTITEM) + ->render(), "Failed asserting that element renders correctly with 'role' attribute using enum.", ); } @@ -596,9 +580,9 @@ public function testRenderWithSpellcheck(): void
  • HTML, - LineEndingNormalizer::normalize( - Li::tag()->spellcheck(true)->render(), - ), + Li::tag() + ->spellcheck(true) + ->render(), "Failed asserting that element renders correctly with 'spellcheck' attribute.", ); } @@ -610,9 +594,9 @@ public function testRenderWithStyle(): void
  • HTML, - LineEndingNormalizer::normalize( - Li::tag()->style('value')->render(), - ), + Li::tag() + ->style('value') + ->render(), "Failed asserting that element renders correctly with 'style' attribute.", ); } @@ -624,9 +608,9 @@ public function testRenderWithTabindex(): void
  • HTML, - LineEndingNormalizer::normalize( - Li::tag()->tabIndex(3)->render(), - ), + Li::tag() + ->tabIndex(3) + ->render(), "Failed asserting that element renders correctly with 'tabindex' attribute.", ); } @@ -638,9 +622,9 @@ public function testRenderWithThemeProvider(): void
  • HTML, - LineEndingNormalizer::normalize( - Li::tag()->addThemeProvider('muted', DefaultThemeProvider::class)->render(), - ), + Li::tag() + ->addThemeProvider('muted', DefaultThemeProvider::class) + ->render(), "Failed asserting that element renders correctly with 'addThemeProvider()' method.", ); } @@ -652,9 +636,9 @@ public function testRenderWithTitle(): void
  • HTML, - LineEndingNormalizer::normalize( - Li::tag()->title('value')->render(), - ), + Li::tag() + ->title('value') + ->render(), "Failed asserting that element renders correctly with 'title' attribute.", ); } @@ -666,9 +650,7 @@ public function testRenderWithToString(): void
  • HTML, - LineEndingNormalizer::normalize( - (string) Li::tag(), - ), + (string) Li::tag(), "Failed asserting that '__toString()' method renders correctly.", ); } @@ -680,9 +662,9 @@ public function testRenderWithTranslate(): void
  • HTML, - LineEndingNormalizer::normalize( - Li::tag()->translate(false)->render(), - ), + Li::tag() + ->translate(false) + ->render(), "Failed asserting that element renders correctly with 'translate' attribute.", ); } @@ -694,9 +676,9 @@ public function testRenderWithTranslateUsingEnum(): void
  • HTML, - LineEndingNormalizer::normalize( - Li::tag()->translate(Translate::NO)->render(), - ), + Li::tag() + ->translate(Translate::NO) + ->render(), "Failed asserting that element renders correctly with 'translate' attribute using enum.", ); } @@ -710,9 +692,7 @@ public function testRenderWithUserOverridesGlobalDefaults(): void
  • HTML, - LineEndingNormalizer::normalize( - Li::tag(['id' => 'id-user'])->render(), - ), + Li::tag(['id' => 'id-user'])->render(), 'Failed asserting that user-defined attributes override global defaults correctly.', ); @@ -727,9 +707,9 @@ public function testRenderWithValue(): void Third item HTML, - LineEndingNormalizer::normalize( - Li::tag()->value(3)->content('Third item')->render(), - ), + Li::tag()->value(3) + ->content('Third item') + ->render(), "Failed asserting that element renders correctly with 'value' attribute.", ); } @@ -742,9 +722,9 @@ public function testRenderWithValueString(): void Item HTML, - LineEndingNormalizer::normalize( - Li::tag()->value('custom-value')->content('Item')->render(), - ), + Li::tag()->value('custom-value') + ->content('Item') + ->render(), "Failed asserting that element renders correctly with string 'value' attribute.", ); } diff --git a/tests/List/OlTest.php b/tests/List/OlTest.php index d663aa8..3d56eb9 100644 --- a/tests/List/OlTest.php +++ b/tests/List/OlTest.php @@ -4,7 +4,6 @@ namespace UIAwesome\Html\Tests\List; -use PHPForge\Support\LineEndingNormalizer; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use UIAwesome\Html\Attribute\Values\{ @@ -35,17 +34,16 @@ * @copyright Copyright (C) 2026 Terabytesoftw. * @license https://opensource.org/license/bsd-3-clause BSD 3-Clause License. */ -#[Group('html')] #[Group('list')] final class OlTest extends TestCase { public function testContentEncodesValues(): void { - $ol = Ol::tag()->content(''); - self::assertSame( '<value>', - $ol->getContent(), + Ol::tag() + ->content('') + ->getContent(), "Failed asserting that 'content()' method encodes values correctly.", ); } @@ -63,7 +61,9 @@ public function testGetAttributesReturnsAssignedAttributes(): void { self::assertSame( ['data-test' => 'value'], - Ol::tag()->addAttribute('data-test', 'value')->getAttributes(), + Ol::tag() + ->addAttribute('data-test', 'value') + ->getAttributes(), "Failed asserting that 'getAttributes()' returns the assigned attributes.", ); } @@ -76,9 +76,9 @@ public function testHtmlDoesNotEncodeValues(): void HTML, - LineEndingNormalizer::normalize( - Ol::tag()->html('')->render(), - ), + Ol::tag() + ->html('') + ->render(), "Failed asserting that element renders correctly with 'html()' method.", ); } @@ -90,9 +90,9 @@ public function testRenderWithAccesskey(): void
    HTML, - LineEndingNormalizer::normalize( - Ol::tag()->accesskey('k')->render(), - ), + Ol::tag() + ->accesskey('k') + ->render(), "Failed asserting that element renders correctly with 'accesskey' attribute.", ); } @@ -104,9 +104,9 @@ public function testRenderWithAddAriaAttribute(): void
    HTML, - LineEndingNormalizer::normalize( - Ol::tag()->addAriaAttribute('pressed', true)->render(), - ), + Ol::tag() + ->addAriaAttribute('pressed', true) + ->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method.", ); } @@ -118,9 +118,9 @@ public function testRenderWithAddAriaAttributeUsingEnum(): void
    HTML, - LineEndingNormalizer::normalize( - Ol::tag()->addAriaAttribute(Aria::PRESSED, true)->render(), - ), + Ol::tag() + ->addAriaAttribute(Aria::PRESSED, true) + ->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method.", ); } @@ -132,9 +132,9 @@ public function testRenderWithAddAttribute(): void
    HTML, - LineEndingNormalizer::normalize( - Ol::tag()->addAttribute('data-test', 'value')->render(), - ), + Ol::tag() + ->addAttribute('data-test', 'value') + ->render(), "Failed asserting that element renders correctly with 'addAttribute()' method.", ); } @@ -146,9 +146,9 @@ public function testRenderWithAddAttributeUsingEnum(): void
    HTML, - LineEndingNormalizer::normalize( - Ol::tag()->addAttribute(GlobalAttribute::TITLE, 'value')->render(), - ), + Ol::tag() + ->addAttribute(GlobalAttribute::TITLE, 'value') + ->render(), "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", ); } @@ -160,9 +160,9 @@ public function testRenderWithAddDataAttribute(): void
    HTML, - LineEndingNormalizer::normalize( - Ol::tag()->addDataAttribute('value', 'value')->render(), - ), + Ol::tag() + ->addDataAttribute('value', 'value') + ->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method.", ); } @@ -174,9 +174,9 @@ public function testRenderWithAddDataAttributeUsingEnum(): void
    HTML, - LineEndingNormalizer::normalize( - Ol::tag()->addDataAttribute(Data::VALUE, 'value')->render(), - ), + Ol::tag() + ->addDataAttribute(Data::VALUE, 'value') + ->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method.", ); } @@ -188,17 +188,15 @@ public function testRenderWithAriaAttributes(): void
    HTML, - LineEndingNormalizer::normalize( - Ol::tag() - ->ariaAttributes( - [ - 'controls' => static fn(): string => 'modal-1', - 'hidden' => false, - 'label' => 'Close', - ], - ) - ->render(), - ), + Ol::tag() + ->ariaAttributes( + [ + 'controls' => static fn(): string => 'modal-1', + 'hidden' => false, + 'label' => 'Close', + ], + ) + ->render(), "Failed asserting that element renders correctly with 'ariaAttributes()' method.", ); } @@ -210,9 +208,9 @@ public function testRenderWithAttributes(): void
    HTML, - LineEndingNormalizer::normalize( - Ol::tag()->attributes(['class' => 'value'])->render(), - ), + Ol::tag() + ->attributes(['class' => 'value']) + ->render(), "Failed asserting that element renders correctly with 'attributes()' method.", ); } @@ -224,9 +222,9 @@ public function testRenderWithAutofocus(): void
    HTML, - LineEndingNormalizer::normalize( - Ol::tag()->autofocus(true)->render(), - ), + Ol::tag() + ->autofocus(true) + ->render(), "Failed asserting that element renders correctly with 'autofocus' attribute.", ); } @@ -239,9 +237,7 @@ public function testRenderWithBeginEnd(): void Content HTML, - LineEndingNormalizer::normalize( - Ol::tag()->begin() . 'Content' . Ol::end(), - ), + Ol::tag()->begin() . 'Content' . Ol::end(), "Failed asserting that element renders correctly with 'begin()' and 'end()' methods.", ); } @@ -253,9 +249,9 @@ public function testRenderWithClass(): void
    HTML, - LineEndingNormalizer::normalize( - Ol::tag()->class('value')->render(), - ), + Ol::tag() + ->class('value') + ->render(), "Failed asserting that element renders correctly with 'class' attribute.", ); } @@ -268,9 +264,9 @@ public function testRenderWithContent(): void value HTML, - LineEndingNormalizer::normalize( - Ol::tag()->content('value')->render(), - ), + Ol::tag() + ->content('value') + ->render(), 'Failed asserting that element renders correctly with default values.', ); } @@ -282,9 +278,9 @@ public function testRenderWithContentEditable(): void
    HTML, - LineEndingNormalizer::normalize( - Ol::tag()->contentEditable(true)->render(), - ), + Ol::tag() + ->contentEditable(true) + ->render(), "Failed asserting that element renders correctly with 'contentEditable' attribute.", ); } @@ -296,9 +292,9 @@ public function testRenderWithContentEditableUsingEnum(): void
    HTML, - LineEndingNormalizer::normalize( - Ol::tag()->contentEditable(ContentEditable::TRUE)->render(), - ), + Ol::tag() + ->contentEditable(ContentEditable::TRUE) + ->render(), "Failed asserting that element renders correctly with 'contentEditable' attribute using enum.", ); } @@ -310,9 +306,9 @@ public function testRenderWithDataAttributes(): void
    HTML, - LineEndingNormalizer::normalize( - Ol::tag()->dataAttributes(['value' => 'value'])->render(), - ), + Ol::tag() + ->dataAttributes(['value' => 'value']) + ->render(), "Failed asserting that element renders correctly with 'dataAttributes()' method.", ); } @@ -324,9 +320,9 @@ public function testRenderWithDefaultConfigurationValues(): void
    HTML, - LineEndingNormalizer::normalize( - Ol::tag(['class' => 'default-class'])->render(), - ), + Ol::tag() + ->attributes(['class' => 'default-class']) + ->render(), 'Failed asserting that default configuration values are applied correctly.', ); } @@ -338,9 +334,9 @@ public function testRenderWithDefaultProvider(): void
    HTML, - LineEndingNormalizer::normalize( - Ol::tag()->addDefaultProvider(DefaultProvider::class)->render(), - ), + Ol::tag() + ->addDefaultProvider(DefaultProvider::class) + ->render(), 'Failed asserting that default provider is applied correctly.', ); } @@ -352,9 +348,9 @@ public function testRenderWithDir(): void
    HTML, - LineEndingNormalizer::normalize( - Ol::tag()->dir('ltr')->render(), - ), + Ol::tag() + ->dir('ltr') + ->render(), "Failed asserting that element renders correctly with 'dir' attribute.", ); } @@ -366,9 +362,9 @@ public function testRenderWithDirUsingEnum(): void
    HTML, - LineEndingNormalizer::normalize( - Ol::tag()->dir(Direction::LTR)->render(), - ), + Ol::tag() + ->dir(Direction::LTR) + ->render(), "Failed asserting that element renders correctly with 'dir' attribute using enum.", ); } @@ -380,9 +376,9 @@ public function testRenderWithDraggable(): void
    HTML, - LineEndingNormalizer::normalize( - Ol::tag()->draggable(true)->render(), - ), + Ol::tag() + ->draggable(true) + ->render(), "Failed asserting that element renders correctly with 'draggable' attribute.", ); } @@ -394,9 +390,9 @@ public function testRenderWithDraggableUsingEnum(): void
    HTML, - LineEndingNormalizer::normalize( - Ol::tag()->draggable(Draggable::TRUE)->render(), - ), + Ol::tag() + ->draggable(Draggable::TRUE) + ->render(), "Failed asserting that element renders correctly with 'draggable' attribute using enum.", ); } @@ -410,9 +406,7 @@ public function testRenderWithGlobalDefaultsAreApplied(): void
    HTML, - LineEndingNormalizer::normalize( - Ol::tag()->render(), - ), + Ol::tag()->render(), 'Failed asserting that global defaults are applied correctly.', ); @@ -426,9 +420,9 @@ public function testRenderWithHidden(): void HTML, - LineEndingNormalizer::normalize( - Ol::tag()->hidden(true)->render(), - ), + Ol::tag() + ->hidden(true) + ->render(), "Failed asserting that element renders correctly with 'hidden' attribute.", ); } @@ -440,9 +434,9 @@ public function testRenderWithId(): void
    HTML, - LineEndingNormalizer::normalize( - Ol::tag()->id('test-id')->render(), - ), + Ol::tag() + ->id('test-id') + ->render(), "Failed asserting that element renders correctly with 'id' attribute.", ); } @@ -463,9 +457,9 @@ public function testRenderWithItems(): void HTML, - LineEndingNormalizer::normalize( - Ol::tag()->items('Apple', 'Banana', 'Cherry')->render(), - ), + Ol::tag() + ->items('Apple', 'Banana', 'Cherry') + ->render(), "Failed asserting that element renders correctly with 'items()' method.", ); } @@ -477,9 +471,9 @@ public function testRenderWithLang(): void
    HTML, - LineEndingNormalizer::normalize( - Ol::tag()->lang('es')->render(), - ), + Ol::tag() + ->lang('es') + ->render(), "Failed asserting that element renders correctly with 'lang' attribute.", ); } @@ -491,9 +485,9 @@ public function testRenderWithLangUsingEnum(): void
    HTML, - LineEndingNormalizer::normalize( - Ol::tag()->lang(Language::SPANISH)->render(), - ), + Ol::tag() + ->lang(Language::SPANISH) + ->render(), "Failed asserting that element renders correctly with 'lang' attribute using enum.", ); } @@ -511,9 +505,10 @@ public function testRenderWithLi(): void HTML, - LineEndingNormalizer::normalize( - Ol::tag()->li('First item')->li('Second item')->render(), - ), + Ol::tag() + ->li('First item') + ->li('Second item') + ->render(), "Failed asserting that element renders correctly with 'li()' method.", ); } @@ -528,9 +523,9 @@ public function testRenderWithLiValue(): void HTML, - LineEndingNormalizer::normalize( - Ol::tag()->li('Item', 3)->render(), - ), + Ol::tag() + ->li('Item', 3) + ->render(), "Failed asserting that element renders correctly with 'li()' method using a value.", ); } @@ -542,15 +537,13 @@ public function testRenderWithMicroData(): void
    HTML, - LineEndingNormalizer::normalize( - Ol::tag() - ->itemId('https://example.com/item') - ->itemProp('name') - ->itemRef('info') - ->itemScope(true) - ->itemType('https://schema.org/Thing') - ->render(), - ), + Ol::tag() + ->itemId('https://example.com/item') + ->itemProp('name') + ->itemRef('info') + ->itemScope(true) + ->itemType('https://schema.org/Thing') + ->render(), 'Failed asserting that element renders correctly with microdata attributes.', ); } @@ -562,12 +555,10 @@ public function testRenderWithRemoveAriaAttribute(): void
    HTML, - LineEndingNormalizer::normalize( - Ol::tag() - ->addAriaAttribute('label', 'Close') - ->removeAriaAttribute('label') - ->render(), - ), + Ol::tag() + ->addAriaAttribute('label', 'Close') + ->removeAriaAttribute('label') + ->render(), "Failed asserting that element renders correctly with 'removeAriaAttribute()' method.", ); } @@ -579,12 +570,10 @@ public function testRenderWithRemoveAttribute(): void
    HTML, - LineEndingNormalizer::normalize( - Ol::tag() - ->addAttribute('data-test', 'value') - ->removeAttribute('data-test') - ->render(), - ), + Ol::tag() + ->addAttribute('data-test', 'value') + ->removeAttribute('data-test') + ->render(), "Failed asserting that element renders correctly with 'removeAttribute()' method.", ); } @@ -596,12 +585,10 @@ public function testRenderWithRemoveDataAttribute(): void
    HTML, - LineEndingNormalizer::normalize( - Ol::tag() - ->addDataAttribute('value', 'test') - ->removeDataAttribute('value') - ->render(), - ), + Ol::tag() + ->addDataAttribute('value', 'test') + ->removeDataAttribute('value') + ->render(), "Failed asserting that element renders correctly with 'removeDataAttribute()' method.", ); } @@ -616,9 +603,10 @@ public function testRenderWithReversed(): void HTML, - LineEndingNormalizer::normalize( - Ol::tag()->reversed(true)->li('Item')->render(), - ), + Ol::tag() + ->reversed(true) + ->li('Item') + ->render(), "Failed asserting that element renders correctly with 'reversed' attribute.", ); } @@ -630,9 +618,9 @@ public function testRenderWithRole(): void
    HTML, - LineEndingNormalizer::normalize( - Ol::tag()->role('list')->render(), - ), + Ol::tag() + ->role('list') + ->render(), "Failed asserting that element renders correctly with 'role' attribute.", ); } @@ -644,9 +632,9 @@ public function testRenderWithRoleUsingEnum(): void
    HTML, - LineEndingNormalizer::normalize( - Ol::tag()->role(Role::LIST)->render(), - ), + Ol::tag() + ->role(Role::LIST) + ->render(), "Failed asserting that element renders correctly with 'role' attribute using enum.", ); } @@ -658,9 +646,9 @@ public function testRenderWithSpellcheck(): void
    HTML, - LineEndingNormalizer::normalize( - Ol::tag()->spellcheck(true)->render(), - ), + Ol::tag() + ->spellcheck(true) + ->render(), "Failed asserting that element renders correctly with 'spellcheck' attribute.", ); } @@ -675,9 +663,10 @@ public function testRenderWithStart(): void HTML, - LineEndingNormalizer::normalize( - Ol::tag()->start(5)->li('Item')->render(), - ), + Ol::tag() + ->li('Item') + ->start(5) + ->render(), "Failed asserting that element renders correctly with 'start' attribute.", ); } @@ -686,7 +675,7 @@ public function testRenderWithStartAndReversed(): void { self::assertSame( << +
    1. First
    2. @@ -695,9 +684,12 @@ public function testRenderWithStartAndReversed(): void
    HTML, - LineEndingNormalizer::normalize( - Ol::tag()->start(10)->reversed(true)->li('First')->li('Second')->render(), - ), + Ol::tag() + ->li('First') + ->li('Second') + ->reversed(true) + ->start(10) + ->render(), "Failed asserting that element renders correctly with both 'start' and 'reversed' attributes.", ); } @@ -709,9 +701,9 @@ public function testRenderWithStyle(): void
    HTML, - LineEndingNormalizer::normalize( - Ol::tag()->style('value')->render(), - ), + Ol::tag() + ->style('value') + ->render(), "Failed asserting that element renders correctly with 'style' attribute.", ); } @@ -723,9 +715,9 @@ public function testRenderWithTabindex(): void
    HTML, - LineEndingNormalizer::normalize( - Ol::tag()->tabIndex(3)->render(), - ), + Ol::tag() + ->tabIndex(3) + ->render(), "Failed asserting that element renders correctly with 'tabindex' attribute.", ); } @@ -737,9 +729,9 @@ public function testRenderWithThemeProvider(): void
    HTML, - LineEndingNormalizer::normalize( - Ol::tag()->addThemeProvider('muted', DefaultThemeProvider::class)->render(), - ), + Ol::tag() + ->addThemeProvider('muted', DefaultThemeProvider::class) + ->render(), "Failed asserting that element renders correctly with 'addThemeProvider()' method.", ); } @@ -751,9 +743,9 @@ public function testRenderWithTitle(): void
    HTML, - LineEndingNormalizer::normalize( - Ol::tag()->title('value')->render(), - ), + Ol::tag() + ->title('value') + ->render(), "Failed asserting that element renders correctly with 'title' attribute.", ); } @@ -765,9 +757,7 @@ public function testRenderWithToString(): void
    HTML, - LineEndingNormalizer::normalize( - (string) Ol::tag(), - ), + Ol::tag()->render(), "Failed asserting that '__toString()' method renders correctly.", ); } @@ -779,9 +769,9 @@ public function testRenderWithTranslate(): void
    HTML, - LineEndingNormalizer::normalize( - Ol::tag()->translate(false)->render(), - ), + Ol::tag() + ->translate(false) + ->render(), "Failed asserting that element renders correctly with 'translate' attribute.", ); } @@ -793,9 +783,9 @@ public function testRenderWithTranslateUsingEnum(): void
    HTML, - LineEndingNormalizer::normalize( - Ol::tag()->translate(Translate::NO)->render(), - ), + Ol::tag() + ->translate(Translate::NO) + ->render(), "Failed asserting that element renders correctly with 'translate' attribute using enum.", ); } @@ -809,9 +799,7 @@ public function testRenderWithUserOverridesGlobalDefaults(): void
    HTML, - LineEndingNormalizer::normalize( - Ol::tag(['id' => 'id-user'])->render(), - ), + Ol::tag(['id' => 'id-user'])->render(), 'Failed asserting that user-defined attributes override global defaults correctly.', ); diff --git a/tests/List/UlTest.php b/tests/List/UlTest.php index f44c2ef..432b26e 100644 --- a/tests/List/UlTest.php +++ b/tests/List/UlTest.php @@ -4,7 +4,6 @@ namespace UIAwesome\Html\Tests\List; -use PHPForge\Support\LineEndingNormalizer; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use UIAwesome\Html\Attribute\Values\{ @@ -34,17 +33,16 @@ * @copyright Copyright (C) 2026 Terabytesoftw. * @license https://opensource.org/license/bsd-3-clause BSD 3-Clause License. */ -#[Group('html')] #[Group('list')] final class UlTest extends TestCase { public function testContentEncodesValues(): void { - $ul = Ul::tag()->content(''); - self::assertSame( '<value>', - $ul->getContent(), + Ul::tag() + ->content('') + ->getContent(), "Failed asserting that 'content()' method encodes values correctly.", ); } @@ -62,7 +60,9 @@ public function testGetAttributesReturnsAssignedAttributes(): void { self::assertSame( ['data-test' => 'value'], - Ul::tag()->addAttribute('data-test', 'value')->getAttributes(), + Ul::tag() + ->addAttribute('data-test', 'value') + ->getAttributes(), "Failed asserting that 'getAttributes()' returns the assigned attributes.", ); } @@ -75,9 +75,9 @@ public function testHtmlDoesNotEncodeValues(): void HTML, - LineEndingNormalizer::normalize( - Ul::tag()->html('')->render(), - ), + Ul::tag() + ->html('') + ->render(), "Failed asserting that element renders correctly with 'html()' method.", ); } @@ -89,9 +89,9 @@ public function testRenderWithAccesskey(): void
    HTML, - LineEndingNormalizer::normalize( - Ul::tag()->accesskey('k')->render(), - ), + Ul::tag() + ->accesskey('k') + ->render(), "Failed asserting that element renders correctly with 'accesskey' attribute.", ); } @@ -103,9 +103,9 @@ public function testRenderWithAddAriaAttribute(): void
    HTML, - LineEndingNormalizer::normalize( - Ul::tag()->addAriaAttribute('pressed', true)->render(), - ), + Ul::tag() + ->addAriaAttribute('pressed', true) + ->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method.", ); } @@ -117,9 +117,9 @@ public function testRenderWithAddAriaAttributeUsingEnum(): void
    HTML, - LineEndingNormalizer::normalize( - Ul::tag()->addAriaAttribute(Aria::PRESSED, true)->render(), - ), + Ul::tag() + ->addAriaAttribute(Aria::PRESSED, true) + ->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method.", ); } @@ -131,9 +131,9 @@ public function testRenderWithAddAttribute(): void
    HTML, - LineEndingNormalizer::normalize( - Ul::tag()->addAttribute('data-test', 'value')->render(), - ), + Ul::tag() + ->addAttribute('data-test', 'value') + ->render(), "Failed asserting that element renders correctly with 'addAttribute()' method.", ); } @@ -145,9 +145,9 @@ public function testRenderWithAddAttributeUsingEnum(): void
    HTML, - LineEndingNormalizer::normalize( - Ul::tag()->addAttribute(GlobalAttribute::TITLE, 'value')->render(), - ), + Ul::tag() + ->addAttribute(GlobalAttribute::TITLE, 'value') + ->render(), "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", ); } @@ -159,9 +159,9 @@ public function testRenderWithAddDataAttribute(): void
    HTML, - LineEndingNormalizer::normalize( - Ul::tag()->addDataAttribute('value', 'value')->render(), - ), + Ul::tag() + ->addDataAttribute('value', 'value') + ->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method.", ); } @@ -173,9 +173,9 @@ public function testRenderWithAddDataAttributeUsingEnum(): void
    HTML, - LineEndingNormalizer::normalize( - Ul::tag()->addDataAttribute(Data::VALUE, 'value')->render(), - ), + Ul::tag() + ->addDataAttribute(Data::VALUE, 'value') + ->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method.", ); } @@ -187,17 +187,15 @@ public function testRenderWithAriaAttributes(): void
    HTML, - LineEndingNormalizer::normalize( - Ul::tag() - ->ariaAttributes( - [ - 'controls' => static fn(): string => 'modal-1', - 'hidden' => false, - 'label' => 'Close', - ], - ) - ->render(), - ), + Ul::tag() + ->ariaAttributes( + [ + 'controls' => static fn(): string => 'modal-1', + 'hidden' => false, + 'label' => 'Close', + ], + ) + ->render(), "Failed asserting that element renders correctly with 'ariaAttributes()' method.", ); } @@ -209,9 +207,9 @@ public function testRenderWithAttributes(): void
    HTML, - LineEndingNormalizer::normalize( - Ul::tag()->attributes(['class' => 'value'])->render(), - ), + Ul::tag() + ->attributes(['class' => 'value']) + ->render(), "Failed asserting that element renders correctly with 'attributes()' method.", ); } @@ -223,9 +221,9 @@ public function testRenderWithAutofocus(): void
    HTML, - LineEndingNormalizer::normalize( - Ul::tag()->autofocus(true)->render(), - ), + Ul::tag() + ->autofocus(true) + ->render(), "Failed asserting that element renders correctly with 'autofocus' attribute.", ); } @@ -238,9 +236,7 @@ public function testRenderWithBeginEnd(): void Content HTML, - LineEndingNormalizer::normalize( - Ul::tag()->begin() . 'Content' . Ul::end(), - ), + Ul::tag()->begin() . 'Content' . Ul::end(), "Failed asserting that element renders correctly with 'begin()' and 'end()' methods.", ); } @@ -252,9 +248,9 @@ public function testRenderWithClass(): void
    HTML, - LineEndingNormalizer::normalize( - Ul::tag()->class('value')->render(), - ), + Ul::tag() + ->class('value') + ->render(), "Failed asserting that element renders correctly with 'class' attribute.", ); } @@ -267,9 +263,9 @@ public function testRenderWithContent(): void value HTML, - LineEndingNormalizer::normalize( - Ul::tag()->content('value')->render(), - ), + Ul::tag() + ->content('value') + ->render(), 'Failed asserting that element renders correctly with default values.', ); } @@ -281,9 +277,9 @@ public function testRenderWithContentEditable(): void
    HTML, - LineEndingNormalizer::normalize( - Ul::tag()->contentEditable(true)->render(), - ), + Ul::tag() + ->contentEditable(true) + ->render(), "Failed asserting that element renders correctly with 'contentEditable' attribute.", ); } @@ -295,9 +291,9 @@ public function testRenderWithContentEditableUsingEnum(): void
    HTML, - LineEndingNormalizer::normalize( - Ul::tag()->contentEditable(ContentEditable::TRUE)->render(), - ), + Ul::tag() + ->contentEditable(ContentEditable::TRUE) + ->render(), "Failed asserting that element renders correctly with 'contentEditable' attribute using enum.", ); } @@ -309,9 +305,9 @@ public function testRenderWithDataAttributes(): void
    HTML, - LineEndingNormalizer::normalize( - Ul::tag()->dataAttributes(['value' => 'value'])->render(), - ), + Ul::tag() + ->dataAttributes(['value' => 'value']) + ->render(), "Failed asserting that element renders correctly with 'dataAttributes()' method.", ); } @@ -323,9 +319,7 @@ public function testRenderWithDefaultConfigurationValues(): void
    HTML, - LineEndingNormalizer::normalize( - Ul::tag(['class' => 'default-class'])->render(), - ), + Ul::tag(['class' => 'default-class'])->render(), 'Failed asserting that default configuration values are applied correctly.', ); } @@ -337,9 +331,9 @@ public function testRenderWithDefaultProvider(): void
    HTML, - LineEndingNormalizer::normalize( - Ul::tag()->addDefaultProvider(DefaultProvider::class)->render(), - ), + Ul::tag() + ->addDefaultProvider(DefaultProvider::class) + ->render(), 'Failed asserting that default provider is applied correctly.', ); } @@ -351,9 +345,9 @@ public function testRenderWithDir(): void
    HTML, - LineEndingNormalizer::normalize( - Ul::tag()->dir('ltr')->render(), - ), + Ul::tag() + ->dir('ltr') + ->render(), "Failed asserting that element renders correctly with 'dir' attribute.", ); } @@ -365,9 +359,9 @@ public function testRenderWithDirUsingEnum(): void
    HTML, - LineEndingNormalizer::normalize( - Ul::tag()->dir(Direction::LTR)->render(), - ), + Ul::tag() + ->dir(Direction::LTR) + ->render(), "Failed asserting that element renders correctly with 'dir' attribute using enum.", ); } @@ -379,9 +373,9 @@ public function testRenderWithDraggable(): void
    HTML, - LineEndingNormalizer::normalize( - Ul::tag()->draggable(true)->render(), - ), + Ul::tag() + ->draggable(true) + ->render(), "Failed asserting that element renders correctly with 'draggable' attribute.", ); } @@ -393,9 +387,9 @@ public function testRenderWithDraggableUsingEnum(): void
    HTML, - LineEndingNormalizer::normalize( - Ul::tag()->draggable(Draggable::TRUE)->render(), - ), + Ul::tag() + ->draggable(Draggable::TRUE) + ->render(), "Failed asserting that element renders correctly with 'draggable' attribute using enum.", ); } @@ -409,9 +403,7 @@ public function testRenderWithGlobalDefaultsAreApplied(): void
    HTML, - LineEndingNormalizer::normalize( - Ul::tag()->render(), - ), + Ul::tag()->render(), 'Failed asserting that global defaults are applied correctly.', ); @@ -425,9 +417,9 @@ public function testRenderWithHidden(): void HTML, - LineEndingNormalizer::normalize( - Ul::tag()->hidden(true)->render(), - ), + Ul::tag() + ->hidden(true) + ->render(), "Failed asserting that element renders correctly with 'hidden' attribute.", ); } @@ -439,9 +431,9 @@ public function testRenderWithId(): void
    HTML, - LineEndingNormalizer::normalize( - Ul::tag()->id('test-id')->render(), - ), + Ul::tag() + ->id('test-id') + ->render(), "Failed asserting that element renders correctly with 'id' attribute.", ); } @@ -462,9 +454,9 @@ public function testRenderWithItems(): void HTML, - LineEndingNormalizer::normalize( - Ul::tag()->items('Apple', 'Banana', 'Cherry')->render(), - ), + Ul::tag() + ->items('Apple', 'Banana', 'Cherry') + ->render(), "Failed asserting that element renders correctly with 'items()' method.", ); } @@ -476,9 +468,9 @@ public function testRenderWithLang(): void
    HTML, - LineEndingNormalizer::normalize( - Ul::tag()->lang('es')->render(), - ), + Ul::tag() + ->lang('es') + ->render(), "Failed asserting that element renders correctly with 'lang' attribute.", ); } @@ -490,9 +482,9 @@ public function testRenderWithLangUsingEnum(): void
    HTML, - LineEndingNormalizer::normalize( - Ul::tag()->lang(Language::SPANISH)->render(), - ), + Ul::tag() + ->lang(Language::SPANISH) + ->render(), "Failed asserting that element renders correctly with 'lang' attribute using enum.", ); } @@ -510,9 +502,10 @@ public function testRenderWithLi(): void HTML, - LineEndingNormalizer::normalize( - Ul::tag()->li('First item')->li('Second item')->render(), - ), + Ul::tag() + ->li('First item') + ->li('Second item') + ->render(), "Failed asserting that element renders correctly with 'li()' method.", ); } @@ -527,9 +520,9 @@ public function testRenderWithLiValue(): void HTML, - LineEndingNormalizer::normalize( - Ul::tag()->li('Item', 3)->render(), - ), + Ul::tag() + ->li('Item', 3) + ->render(), "Failed asserting that element renders correctly with 'li()' method using a value.", ); } @@ -541,15 +534,13 @@ public function testRenderWithMicroData(): void
    HTML, - LineEndingNormalizer::normalize( - Ul::tag() - ->itemId('https://example.com/item') - ->itemProp('name') - ->itemRef('info') - ->itemScope(true) - ->itemType('https://schema.org/Thing') - ->render(), - ), + Ul::tag() + ->itemId('https://example.com/item') + ->itemProp('name') + ->itemRef('info') + ->itemScope(true) + ->itemType('https://schema.org/Thing') + ->render(), 'Failed asserting that element renders correctly with microdata attributes.', ); } @@ -561,12 +552,10 @@ public function testRenderWithRemoveAriaAttribute(): void
    HTML, - LineEndingNormalizer::normalize( - Ul::tag() - ->addAriaAttribute('label', 'Close') - ->removeAriaAttribute('label') - ->render(), - ), + Ul::tag() + ->addAriaAttribute('label', 'Close') + ->removeAriaAttribute('label') + ->render(), "Failed asserting that element renders correctly with 'removeAriaAttribute()' method.", ); } @@ -578,12 +567,10 @@ public function testRenderWithRemoveAttribute(): void
    HTML, - LineEndingNormalizer::normalize( - Ul::tag() - ->addAttribute('data-test', 'value') - ->removeAttribute('data-test') - ->render(), - ), + Ul::tag() + ->addAttribute('data-test', 'value') + ->removeAttribute('data-test') + ->render(), "Failed asserting that element renders correctly with 'removeAttribute()' method.", ); } @@ -595,12 +582,10 @@ public function testRenderWithRemoveDataAttribute(): void
    HTML, - LineEndingNormalizer::normalize( - Ul::tag() - ->addDataAttribute('value', 'test') - ->removeDataAttribute('value') - ->render(), - ), + Ul::tag() + ->addDataAttribute('value', 'test') + ->removeDataAttribute('value') + ->render(), "Failed asserting that element renders correctly with 'removeDataAttribute()' method.", ); } @@ -612,9 +597,9 @@ public function testRenderWithRole(): void
    HTML, - LineEndingNormalizer::normalize( - Ul::tag()->role('list')->render(), - ), + Ul::tag() + ->role('list') + ->render(), "Failed asserting that element renders correctly with 'role' attribute.", ); } @@ -626,9 +611,9 @@ public function testRenderWithRoleUsingEnum(): void
    HTML, - LineEndingNormalizer::normalize( - Ul::tag()->role(Role::LIST)->render(), - ), + Ul::tag() + ->role(Role::LIST) + ->render(), "Failed asserting that element renders correctly with 'role' attribute using enum.", ); } @@ -640,9 +625,9 @@ public function testRenderWithSpellcheck(): void
    HTML, - LineEndingNormalizer::normalize( - Ul::tag()->spellcheck(true)->render(), - ), + Ul::tag() + ->spellcheck(true) + ->render(), "Failed asserting that element renders correctly with 'spellcheck' attribute.", ); } @@ -654,9 +639,9 @@ public function testRenderWithStyle(): void
    HTML, - LineEndingNormalizer::normalize( - Ul::tag()->style('value')->render(), - ), + Ul::tag() + ->style('value') + ->render(), "Failed asserting that element renders correctly with 'style' attribute.", ); } @@ -668,9 +653,9 @@ public function testRenderWithTabindex(): void
    HTML, - LineEndingNormalizer::normalize( - Ul::tag()->tabIndex(3)->render(), - ), + Ul::tag() + ->tabIndex(3) + ->render(), "Failed asserting that element renders correctly with 'tabindex' attribute.", ); } @@ -682,9 +667,9 @@ public function testRenderWithThemeProvider(): void
    HTML, - LineEndingNormalizer::normalize( - Ul::tag()->addThemeProvider('muted', DefaultThemeProvider::class)->render(), - ), + Ul::tag() + ->addThemeProvider('muted', DefaultThemeProvider::class) + ->render(), "Failed asserting that element renders correctly with 'addThemeProvider()' method.", ); } @@ -696,9 +681,9 @@ public function testRenderWithTitle(): void
    HTML, - LineEndingNormalizer::normalize( - Ul::tag()->title('value')->render(), - ), + Ul::tag() + ->title('value') + ->render(), "Failed asserting that element renders correctly with 'title' attribute.", ); } @@ -710,9 +695,7 @@ public function testRenderWithToString(): void
    HTML, - LineEndingNormalizer::normalize( - (string) Ul::tag(), - ), + (string) Ul::tag(), "Failed asserting that '__toString()' method renders correctly.", ); } @@ -724,9 +707,9 @@ public function testRenderWithTranslate(): void
    HTML, - LineEndingNormalizer::normalize( - Ul::tag()->translate(false)->render(), - ), + Ul::tag() + ->translate(false) + ->render(), "Failed asserting that element renders correctly with 'translate' attribute.", ); } @@ -738,9 +721,9 @@ public function testRenderWithTranslateUsingEnum(): void
    HTML, - LineEndingNormalizer::normalize( - Ul::tag()->translate(Translate::NO)->render(), - ), + Ul::tag() + ->translate(Translate::NO) + ->render(), "Failed asserting that element renders correctly with 'translate' attribute using enum.", ); } @@ -754,9 +737,7 @@ public function testRenderWithUserOverridesGlobalDefaults(): void
    HTML, - LineEndingNormalizer::normalize( - Ul::tag(['id' => 'id-user'])->render(), - ), + Ul::tag(['id' => 'id-user'])->render(), 'Failed asserting that user-defined attributes override global defaults correctly.', ); diff --git a/tests/Metadata/BaseTest.php b/tests/Metadata/BaseTest.php index bdf0a17..36dfa20 100644 --- a/tests/Metadata/BaseTest.php +++ b/tests/Metadata/BaseTest.php @@ -5,7 +5,6 @@ namespace UIAwesome\Html\Tests\Metadata; use InvalidArgumentException; -use PHPForge\Support\LineEndingNormalizer; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use UIAwesome\Html\Attribute\Values\{ @@ -38,7 +37,6 @@ * @copyright Copyright (C) 2026 Terabytesoftw. * @license https://opensource.org/license/bsd-3-clause BSD 3-Clause License. */ -#[Group('html')] #[Group('metadata')] final class BaseTest extends TestCase { @@ -55,7 +53,9 @@ public function testGetAttributesReturnsAssignedAttributes(): void { self::assertSame( ['data-test' => 'value'], - Base::tag()->addAttribute('data-test', 'value')->getAttributes(), + Base::tag() + ->addAttribute('data-test', 'value') + ->getAttributes(), "Failed asserting that 'getAttributes()' returns the assigned attributes.", ); } @@ -66,7 +66,9 @@ public function testRenderWithAccesskey(): void << HTML, - Base::tag()->accesskey('k')->render(), + Base::tag() + ->accesskey('k') + ->render(), "Failed asserting that element renders correctly with 'accesskey' attribute.", ); } @@ -77,7 +79,9 @@ public function testRenderWithAddAriaAttribute(): void << HTML, - Base::tag()->addAriaAttribute('label', 'Base URL')->render(), + Base::tag() + ->addAriaAttribute('label', 'Base URL') + ->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method.", ); } @@ -88,7 +92,9 @@ public function testRenderWithAddAriaAttributeUsingEnum(): void << HTML, - Base::tag()->addAriaAttribute(Aria::HIDDEN, true)->render(), + Base::tag() + ->addAriaAttribute(Aria::HIDDEN, true) + ->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method using enum.", ); } @@ -99,7 +105,9 @@ public function testRenderWithAddAttribute(): void << HTML, - Base::tag()->addAttribute('data-test', 'value')->render(), + Base::tag() + ->addAttribute('data-test', 'value') + ->render(), "Failed asserting that element renders correctly with 'addAttribute()' method.", ); } @@ -110,7 +118,9 @@ public function testRenderWithAddAttributeUsingEnum(): void << HTML, - Base::tag()->addAttribute(GlobalAttribute::TITLE, 'Base URL')->render(), + Base::tag() + ->addAttribute(GlobalAttribute::TITLE, 'Base URL') + ->render(), "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", ); } @@ -121,7 +131,9 @@ public function testRenderWithAddDataAttribute(): void << HTML, - Base::tag()->addDataAttribute('value', 'value')->render(), + Base::tag() + ->addDataAttribute('value', 'value') + ->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method.", ); } @@ -132,7 +144,9 @@ public function testRenderWithAddDataAttributeUsingEnum(): void << HTML, - Base::tag()->addDataAttribute(Data::VALUE, 'value')->render(), + Base::tag() + ->addDataAttribute(Data::VALUE, 'value') + ->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method using enum.", ); } @@ -143,13 +157,14 @@ public function testRenderWithAriaAttributes(): void << HTML, - Base::tag()->ariaAttributes( - [ - 'controls' => static fn(): string => 'modal-1', - 'hidden' => false, - 'label' => 'Close', - ], - ) + Base::tag() + ->ariaAttributes( + [ + 'controls' => static fn(): string => 'modal-1', + 'hidden' => false, + 'label' => 'Close', + ], + ) ->render(), "Failed asserting that element renders correctly with 'ariaAttributes()' method.", ); @@ -161,7 +176,9 @@ public function testRenderWithAttributes(): void << HTML, - Base::tag()->attributes(['class' => 'value'])->render(), + Base::tag() + ->attributes(['class' => 'value']) + ->render(), "Failed asserting that element renders correctly with 'attributes()' method.", ); } @@ -172,7 +189,9 @@ public function testRenderWithClass(): void << HTML, - Base::tag()->class('value')->render(), + Base::tag() + ->class('value') + ->render(), "Failed asserting that element renders correctly with 'class' attribute.", ); } @@ -183,7 +202,9 @@ public function testRenderWithDataAttributes(): void << HTML, - Base::tag()->dataAttributes(['value' => 'value'])->render(), + Base::tag() + ->dataAttributes(['value' => 'value']) + ->render(), "Failed asserting that element renders correctly with 'dataAttributes()' method.", ); } @@ -205,7 +226,9 @@ public function testRenderWithDefaultProvider(): void << HTML, - Base::tag()->addDefaultProvider(DefaultProvider::class)->render(), + Base::tag() + ->addDefaultProvider(DefaultProvider::class) + ->render(), 'Failed asserting that default provider is applied correctly.', ); } @@ -227,7 +250,9 @@ public function testRenderWithDir(): void << HTML, - Base::tag()->dir('ltr')->render(), + Base::tag() + ->dir('ltr') + ->render(), "Failed asserting that element renders correctly with 'dir' attribute.", ); } @@ -238,7 +263,9 @@ public function testRenderWithDirUsingEnum(): void << HTML, - Base::tag()->dir(Direction::LTR)->render(), + Base::tag() + ->dir(Direction::LTR) + ->render(), "Failed asserting that element renders correctly with 'dir' attribute using enum.", ); } @@ -262,7 +289,9 @@ public function testRenderWithHidden(): void << HTML, - Base::tag()->hidden(true)->render(), + Base::tag() + ->hidden(true) + ->render(), "Failed asserting that element renders correctly with 'hidden' attribute.", ); } @@ -273,7 +302,9 @@ public function testRenderWithHref(): void << HTML, - Base::tag()->href('https://example.com/')->render(), + Base::tag() + ->href('https://example.com/') + ->render(), "Failed asserting that element renders correctly with 'href' attribute.", ); } @@ -284,7 +315,10 @@ public function testRenderWithHrefAndTarget(): void << HTML, - Base::tag()->href('https://example.com/')->target('_blank')->render(), + Base::tag() + ->href('https://example.com/') + ->target('_blank') + ->render(), "Failed asserting that element renders correctly with both 'href' and 'target' attributes.", ); } @@ -295,7 +329,9 @@ public function testRenderWithId(): void << HTML, - Base::tag()->id('test-id')->render(), + Base::tag() + ->id('test-id') + ->render(), "Failed asserting that element renders correctly with 'id' attribute.", ); } @@ -306,7 +342,9 @@ public function testRenderWithLang(): void << HTML, - Base::tag()->lang('es')->render(), + Base::tag() + ->lang('es') + ->render(), "Failed asserting that element renders correctly with 'lang' attribute.", ); } @@ -317,7 +355,9 @@ public function testRenderWithLangUsingEnum(): void << HTML, - Base::tag()->lang(Language::SPANISH)->render(), + Base::tag() + ->lang(Language::SPANISH) + ->render(), "Failed asserting that element renders correctly with 'lang' attribute using enum.", ); } @@ -370,7 +410,9 @@ public function testRenderWithRole(): void << HTML, - Base::tag()->role('banner')->render(), + Base::tag() + ->role('banner') + ->render(), "Failed asserting that element renders correctly with 'role' attribute.", ); } @@ -381,7 +423,9 @@ public function testRenderWithRoleUsingEnum(): void << HTML, - Base::tag()->role(Role::BANNER)->render(), + Base::tag() + ->role(Role::BANNER) + ->render(), "Failed asserting that element renders correctly with 'role' attribute using enum.", ); } @@ -392,7 +436,9 @@ public function testRenderWithStyle(): void << HTML, - Base::tag()->style('value')->render(), + Base::tag() + ->style('value') + ->render(), "Failed asserting that element renders correctly with 'style' attribute.", ); } @@ -403,7 +449,9 @@ public function testRenderWithTarget(): void << HTML, - Base::tag()->target('_blank')->render(), + Base::tag() + ->target('_blank') + ->render(), "Failed asserting that element renders correctly with 'target' attribute.", ); } @@ -414,7 +462,9 @@ public function testRenderWithTargetBlankUsingEnum(): void << HTML, - Base::tag()->target(Target::BLANK)->render(), + Base::tag() + ->target(Target::BLANK) + ->render(), "Failed asserting that element renders correctly with 'target' attribute using Target::BLANK enum.", ); } @@ -436,7 +486,9 @@ public function testRenderWithTargetSelfUsingEnum(): void << HTML, - Base::tag()->target(Target::SELF)->render(), + Base::tag() + ->target(Target::SELF) + ->render(), "Failed asserting that element renders correctly with 'target' attribute using Target::SELF enum.", ); } @@ -447,7 +499,9 @@ public function testRenderWithTargetTopUsingEnum(): void << HTML, - Base::tag()->target(Target::TOP)->render(), + Base::tag() + ->target(Target::TOP) + ->render(), "Failed asserting that element renders correctly with 'target' attribute using Target::TOP enum.", ); } @@ -458,7 +512,9 @@ public function testRenderWithThemeProvider(): void << HTML, - Base::tag()->addThemeProvider('muted', DefaultThemeProvider::class)->render(), + Base::tag() + ->addThemeProvider('muted', DefaultThemeProvider::class) + ->render(), "Failed asserting that element renders correctly with 'addThemeProvider()' method.", ); } @@ -469,7 +525,9 @@ public function testRenderWithTitle(): void << HTML, - Base::tag()->title('value')->render(), + Base::tag() + ->title('value') + ->render(), "Failed asserting that element renders correctly with 'title' attribute.", ); } @@ -478,9 +536,7 @@ public function testRenderWithToString(): void { self::assertSame( '', - LineEndingNormalizer::normalize( - (string) Base::tag(), - ), + (string) Base::tag(), "Failed asserting that '__toString()' method renders correctly.", ); } @@ -491,7 +547,9 @@ public function testRenderWithTranslate(): void << HTML, - Base::tag()->translate(false)->render(), + Base::tag() + ->translate(false) + ->render(), "Failed asserting that element renders correctly with 'translate' attribute.", ); } @@ -502,7 +560,9 @@ public function testRenderWithTranslateUsingEnum(): void << HTML, - Base::tag()->translate(Translate::NO)->render(), + Base::tag() + ->translate(Translate::NO) + ->render(), "Failed asserting that element renders correctly with 'translate' attribute using enum.", ); } diff --git a/tests/Metadata/LinkTest.php b/tests/Metadata/LinkTest.php index 608080f..708e5e7 100644 --- a/tests/Metadata/LinkTest.php +++ b/tests/Metadata/LinkTest.php @@ -5,7 +5,6 @@ namespace UIAwesome\Html\Tests\Metadata; use InvalidArgumentException; -use PHPForge\Support\LineEndingNormalizer; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use UIAwesome\Html\Attribute\Values\{ @@ -43,7 +42,6 @@ * @copyright Copyright (C) 2026 Terabytesoftw. * @license https://opensource.org/license/bsd-3-clause BSD 3-Clause License. */ -#[Group('html')] #[Group('metadata')] final class LinkTest extends TestCase { @@ -60,7 +58,9 @@ public function testGetAttributesReturnsAssignedAttributes(): void { self::assertSame( ['data-test' => 'value'], - Link::tag()->addAttribute('data-test', 'value')->getAttributes(), + Link::tag() + ->addAttribute('data-test', 'value') + ->getAttributes(), "Failed asserting that 'getAttributes()' returns the assigned attributes.", ); } @@ -71,7 +71,9 @@ public function testRenderWithAccesskey(): void << HTML, - Link::tag()->accesskey('k')->render(), + Link::tag() + ->accesskey('k') + ->render(), "Failed asserting that element renders correctly with 'accesskey' attribute.", ); } @@ -82,7 +84,9 @@ public function testRenderWithAddAriaAttribute(): void << HTML, - Link::tag()->addAriaAttribute('label', 'Stylesheet')->render(), + Link::tag() + ->addAriaAttribute('label', 'Stylesheet') + ->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method.", ); } @@ -93,7 +97,9 @@ public function testRenderWithAddAriaAttributeUsingEnum(): void << HTML, - Link::tag()->addAriaAttribute(Aria::HIDDEN, true)->render(), + Link::tag() + ->addAriaAttribute(Aria::HIDDEN, true) + ->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method using enum.", ); } @@ -104,7 +110,9 @@ public function testRenderWithAddAttribute(): void << HTML, - Link::tag()->addAttribute('data-test', 'value')->render(), + Link::tag() + ->addAttribute('data-test', 'value') + ->render(), "Failed asserting that element renders correctly with 'addAttribute()' method.", ); } @@ -115,7 +123,9 @@ public function testRenderWithAddAttributeUsingEnum(): void << HTML, - Link::tag()->addAttribute(GlobalAttribute::TITLE, 'Stylesheet')->render(), + Link::tag() + ->addAttribute(GlobalAttribute::TITLE, 'Stylesheet') + ->render(), "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", ); } @@ -126,7 +136,9 @@ public function testRenderWithAddDataAttribute(): void << HTML, - Link::tag()->addDataAttribute('value', 'value')->render(), + Link::tag() + ->addDataAttribute('value', 'value') + ->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method.", ); } @@ -137,7 +149,9 @@ public function testRenderWithAddDataAttributeUsingEnum(): void << HTML, - Link::tag()->addDataAttribute(Data::VALUE, 'value')->render(), + Link::tag() + ->addDataAttribute(Data::VALUE, 'value') + ->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method using enum.", ); } @@ -148,13 +162,14 @@ public function testRenderWithAriaAttributes(): void << HTML, - Link::tag()->ariaAttributes( - [ - 'controls' => static fn(): string => 'modal-1', - 'hidden' => false, - 'label' => 'Close', - ], - ) + Link::tag() + ->ariaAttributes( + [ + 'controls' => static fn(): string => 'modal-1', + 'hidden' => false, + 'label' => 'Close', + ], + ) ->render(), "Failed asserting that element renders correctly with 'ariaAttributes()' method.", ); @@ -166,7 +181,9 @@ public function testRenderWithAs(): void << HTML, - Link::tag()->as('style')->render(), + Link::tag() + ->as('style') + ->render(), "Failed asserting that element renders correctly with 'as' attribute.", ); } @@ -177,7 +194,9 @@ public function testRenderWithAttributes(): void << HTML, - Link::tag()->attributes(['class' => 'value'])->render(), + Link::tag() + ->attributes(['class' => 'value']) + ->render(), "Failed asserting that element renders correctly with 'attributes()' method.", ); } @@ -188,7 +207,9 @@ public function testRenderWithBlocking(): void << HTML, - Link::tag()->blocking('render')->render(), + Link::tag() + ->blocking('render') + ->render(), "Failed asserting that element renders correctly with 'blocking' attribute.", ); } @@ -199,7 +220,9 @@ public function testRenderWithBlockingUsingEnum(): void << HTML, - Link::tag()->blocking(Blocking::RENDER)->render(), + Link::tag() + ->blocking(Blocking::RENDER) + ->render(), "Failed asserting that element renders correctly with 'blocking' attribute using enum.", ); } @@ -210,7 +233,9 @@ public function testRenderWithClass(): void << HTML, - Link::tag()->class('value')->render(), + Link::tag() + ->class('value') + ->render(), "Failed asserting that element renders correctly with 'class' attribute.", ); } @@ -221,7 +246,9 @@ public function testRenderWithCrossorigin(): void << HTML, - Link::tag()->crossorigin('anonymous')->render(), + Link::tag() + ->crossorigin('anonymous') + ->render(), "Failed asserting that element renders correctly with 'crossorigin' attribute.", ); } @@ -232,7 +259,9 @@ public function testRenderWithCrossoriginUsingEnum(): void << HTML, - Link::tag()->crossorigin(Crossorigin::ANONYMOUS)->render(), + Link::tag() + ->crossorigin(Crossorigin::ANONYMOUS) + ->render(), "Failed asserting that element renders correctly with 'crossorigin' attribute using enum.", ); } @@ -243,7 +272,9 @@ public function testRenderWithDataAttributes(): void << HTML, - Link::tag()->dataAttributes(['value' => 'value'])->render(), + Link::tag() + ->dataAttributes(['value' => 'value']) + ->render(), "Failed asserting that element renders correctly with 'dataAttributes()' method.", ); } @@ -265,7 +296,9 @@ public function testRenderWithDefaultProvider(): void << HTML, - Link::tag()->addDefaultProvider(DefaultProvider::class)->render(), + Link::tag() + ->addDefaultProvider(DefaultProvider::class) + ->render(), 'Failed asserting that default provider is applied correctly.', ); } @@ -287,7 +320,9 @@ public function testRenderWithDir(): void << HTML, - Link::tag()->dir('ltr')->render(), + Link::tag() + ->dir('ltr') + ->render(), "Failed asserting that element renders correctly with 'dir' attribute.", ); } @@ -298,7 +333,9 @@ public function testRenderWithDirUsingEnum(): void << HTML, - Link::tag()->dir(Direction::LTR)->render(), + Link::tag() + ->dir(Direction::LTR) + ->render(), "Failed asserting that element renders correctly with 'dir' attribute using enum.", ); } @@ -309,7 +346,9 @@ public function testRenderWithDisabled(): void << HTML, - Link::tag()->disabled(true)->render(), + Link::tag() + ->disabled(true) + ->render(), "Failed asserting that element renders correctly with 'disabled' attribute.", ); } @@ -320,7 +359,9 @@ public function testRenderWithFetchpriority(): void << HTML, - Link::tag()->fetchpriority('high')->render(), + Link::tag() + ->fetchpriority('high') + ->render(), "Failed asserting that element renders correctly with 'fetchpriority' attribute.", ); } @@ -331,7 +372,9 @@ public function testRenderWithFetchpriorityUsingEnum(): void << HTML, - Link::tag()->fetchpriority(Fetchpriority::HIGH)->render(), + Link::tag() + ->fetchpriority(Fetchpriority::HIGH) + ->render(), "Failed asserting that element renders correctly with 'fetchpriority' attribute using enum.", ); } @@ -355,7 +398,9 @@ public function testRenderWithHidden(): void << HTML, - Link::tag()->hidden(true)->render(), + Link::tag() + ->hidden(true) + ->render(), "Failed asserting that element renders correctly with 'hidden' attribute.", ); } @@ -366,7 +411,9 @@ public function testRenderWithHref(): void << HTML, - Link::tag()->href('https://example.com/style.css')->render(), + Link::tag() + ->href('https://example.com/style.css') + ->render(), "Failed asserting that element renders correctly with 'href' attribute.", ); } @@ -377,7 +424,10 @@ public function testRenderWithHrefAndRel(): void << HTML, - Link::tag()->href('https://example.com/style.css')->rel('stylesheet')->render(), + Link::tag() + ->href('https://example.com/style.css') + ->rel('stylesheet') + ->render(), "Failed asserting that element renders correctly with both 'href' and 'rel' attributes.", ); } @@ -388,7 +438,9 @@ public function testRenderWithHreflang(): void << HTML, - Link::tag()->hreflang('es')->render(), + Link::tag() + ->hreflang('es') + ->render(), "Failed asserting that element renders correctly with 'hreflang' attribute.", ); } @@ -399,7 +451,9 @@ public function testRenderWithId(): void << HTML, - Link::tag()->id('test-id')->render(), + Link::tag() + ->id('test-id') + ->render(), "Failed asserting that element renders correctly with 'id' attribute.", ); } @@ -410,7 +464,9 @@ public function testRenderWithImagesizes(): void << HTML, - Link::tag()->imagesizes('100vw')->render(), + Link::tag() + ->imagesizes('100vw') + ->render(), "Failed asserting that element renders correctly with 'imagesizes' attribute.", ); } @@ -421,7 +477,9 @@ public function testRenderWithImagesrcset(): void << HTML, - Link::tag()->imagesrcset('image-480.jpg 480w, image-800.jpg 800w')->render(), + Link::tag() + ->imagesrcset('image-480.jpg 480w, image-800.jpg 800w') + ->render(), "Failed asserting that element renders correctly with 'imagesrcset' attribute.", ); } @@ -432,7 +490,9 @@ public function testRenderWithIntegrity(): void << HTML, - Link::tag()->integrity('sha384-abc123')->render(), + Link::tag() + ->integrity('sha384-abc123') + ->render(), "Failed asserting that element renders correctly with 'integrity' attribute.", ); } @@ -443,7 +503,9 @@ public function testRenderWithLang(): void << HTML, - Link::tag()->lang('es')->render(), + Link::tag() + ->lang('es') + ->render(), "Failed asserting that element renders correctly with 'lang' attribute.", ); } @@ -454,7 +516,9 @@ public function testRenderWithLangUsingEnum(): void << HTML, - Link::tag()->lang(Language::SPANISH)->render(), + Link::tag() + ->lang(Language::SPANISH) + ->render(), "Failed asserting that element renders correctly with 'lang' attribute using enum.", ); } @@ -465,7 +529,9 @@ public function testRenderWithMedia(): void << HTML, - Link::tag()->media('screen and (min-width: 768px)')->render(), + Link::tag() + ->media('screen and (min-width: 768px)') + ->render(), "Failed asserting that element renders correctly with 'media' attribute.", ); } @@ -476,7 +542,9 @@ public function testRenderWithReferrerpolicy(): void << HTML, - Link::tag()->referrerpolicy('no-referrer')->render(), + Link::tag() + ->referrerpolicy('no-referrer') + ->render(), "Failed asserting that element renders correctly with 'referrerpolicy' attribute.", ); } @@ -487,7 +555,9 @@ public function testRenderWithReferrerpolicyUsingEnum(): void << HTML, - Link::tag()->referrerpolicy(Referrerpolicy::NO_REFERRER)->render(), + Link::tag() + ->referrerpolicy(Referrerpolicy::NO_REFERRER) + ->render(), "Failed asserting that element renders correctly with 'referrerpolicy' attribute using enum.", ); } @@ -498,7 +568,9 @@ public function testRenderWithRel(): void << HTML, - Link::tag()->rel('stylesheet')->render(), + Link::tag() + ->rel('stylesheet') + ->render(), "Failed asserting that element renders correctly with 'rel' attribute.", ); } @@ -551,7 +623,9 @@ public function testRenderWithRole(): void << HTML, - Link::tag()->role('banner')->render(), + Link::tag() + ->role('banner') + ->render(), "Failed asserting that element renders correctly with 'role' attribute.", ); } @@ -562,7 +636,9 @@ public function testRenderWithRoleUsingEnum(): void << HTML, - Link::tag()->role(Role::BANNER)->render(), + Link::tag() + ->role(Role::BANNER) + ->render(), "Failed asserting that element renders correctly with 'role' attribute using enum.", ); } @@ -573,7 +649,9 @@ public function testRenderWithSizes(): void << HTML, - Link::tag()->sizes('16x16')->render(), + Link::tag() + ->sizes('16x16') + ->render(), "Failed asserting that element renders correctly with 'sizes' attribute.", ); } @@ -584,7 +662,9 @@ public function testRenderWithStyle(): void << HTML, - Link::tag()->style('value')->render(), + Link::tag() + ->style('value') + ->render(), "Failed asserting that element renders correctly with 'style' attribute.", ); } @@ -595,7 +675,10 @@ public function testRenderWithStylesheet(): void << HTML, - Link::tag()->href('/css/site.css')->rel('stylesheet')->render(), + Link::tag() + ->href('/css/site.css') + ->rel('stylesheet') + ->render(), 'Failed asserting that element renders correctly as stylesheet link.', ); } @@ -606,7 +689,9 @@ public function testRenderWithThemeProvider(): void << HTML, - Link::tag()->addThemeProvider('muted', DefaultThemeProvider::class)->render(), + Link::tag() + ->addThemeProvider('muted', DefaultThemeProvider::class) + ->render(), "Failed asserting that element renders correctly with 'addThemeProvider()' method.", ); } @@ -617,7 +702,9 @@ public function testRenderWithTitle(): void << HTML, - Link::tag()->title('value')->render(), + Link::tag() + ->title('value') + ->render(), "Failed asserting that element renders correctly with 'title' attribute.", ); } @@ -626,9 +713,7 @@ public function testRenderWithToString(): void { self::assertSame( '', - LineEndingNormalizer::normalize( - (string) Link::tag(), - ), + (string) Link::tag(), "Failed asserting that '__toString()' method renders correctly.", ); } @@ -639,7 +724,9 @@ public function testRenderWithTranslate(): void << HTML, - Link::tag()->translate(false)->render(), + Link::tag() + ->translate(false) + ->render(), "Failed asserting that element renders correctly with 'translate' attribute.", ); } @@ -650,7 +737,9 @@ public function testRenderWithTranslateUsingEnum(): void << HTML, - Link::tag()->translate(Translate::NO)->render(), + Link::tag() + ->translate(Translate::NO) + ->render(), "Failed asserting that element renders correctly with 'translate' attribute using enum.", ); } @@ -661,7 +750,9 @@ public function testRenderWithType(): void << HTML, - Link::tag()->type('text/css')->render(), + Link::tag() + ->type('text/css') + ->render(), "Failed asserting that element renders correctly with 'type' attribute.", ); } diff --git a/tests/Metadata/MetaTest.php b/tests/Metadata/MetaTest.php index b389a53..c69c7f9 100644 --- a/tests/Metadata/MetaTest.php +++ b/tests/Metadata/MetaTest.php @@ -5,7 +5,6 @@ namespace UIAwesome\Html\Tests\Metadata; use InvalidArgumentException; -use PHPForge\Support\LineEndingNormalizer; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use UIAwesome\Html\Attribute\Values\{ @@ -38,7 +37,6 @@ * @copyright Copyright (C) 2025 Terabytesoftw. * @license https://opensource.org/license/bsd-3-clause BSD 3-Clause License. */ -#[Group('html')] #[Group('metadata')] final class MetaTest extends TestCase { @@ -55,7 +53,9 @@ public function testGetAttributesReturnsAssignedAttributes(): void { self::assertSame( ['data-test' => 'value'], - Meta::tag()->addAttribute('data-test', 'value')->getAttributes(), + Meta::tag() + ->addAttribute('data-test', 'value') + ->getAttributes(), "Failed asserting that 'getAttributes()' returns the assigned attributes.", ); } @@ -66,7 +66,9 @@ public function testRenderWithAccesskey(): void << HTML, - Meta::tag()->accesskey('k')->render(), + Meta::tag() + ->accesskey('k') + ->render(), "Failed asserting that element renders correctly with 'accesskey' attribute.", ); } @@ -77,7 +79,9 @@ public function testRenderWithAddAriaAttribute(): void << HTML, - Meta::tag()->addAriaAttribute('label', 'Meta tag')->render(), + Meta::tag() + ->addAriaAttribute('label', 'Meta tag') + ->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method.", ); } @@ -88,7 +92,9 @@ public function testRenderWithAddAriaAttributeUsingEnum(): void << HTML, - Meta::tag()->addAriaAttribute(Aria::HIDDEN, true)->render(), + Meta::tag() + ->addAriaAttribute(Aria::HIDDEN, true) + ->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method using enum.", ); } @@ -99,7 +105,9 @@ public function testRenderWithAddAttribute(): void << HTML, - Meta::tag()->addAttribute('data-test', 'value')->render(), + Meta::tag() + ->addAttribute('data-test', 'value') + ->render(), "Failed asserting that element renders correctly with 'addAttribute()' method.", ); } @@ -110,7 +118,9 @@ public function testRenderWithAddAttributeUsingEnum(): void << HTML, - Meta::tag()->addAttribute(GlobalAttribute::TITLE, 'Meta tag')->render(), + Meta::tag() + ->addAttribute(GlobalAttribute::TITLE, 'Meta tag') + ->render(), "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", ); } @@ -121,7 +131,9 @@ public function testRenderWithAddDataAttribute(): void << HTML, - Meta::tag()->addDataAttribute('value', 'value')->render(), + Meta::tag() + ->addDataAttribute('value', 'value') + ->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method.", ); } @@ -132,7 +144,9 @@ public function testRenderWithAddDataAttributeUsingEnum(): void << HTML, - Meta::tag()->addDataAttribute(Data::VALUE, 'value')->render(), + Meta::tag() + ->addDataAttribute(Data::VALUE, 'value') + ->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method using enum.", ); } @@ -143,13 +157,14 @@ public function testRenderWithAriaAttributes(): void << HTML, - Meta::tag()->ariaAttributes( - [ - 'controls' => static fn(): string => 'modal-1', - 'hidden' => false, - 'label' => 'Close', - ], - ) + Meta::tag() + ->ariaAttributes( + [ + 'controls' => static fn(): string => 'modal-1', + 'hidden' => false, + 'label' => 'Close', + ], + ) ->render(), "Failed asserting that element renders correctly with 'ariaAttributes()' method.", ); @@ -161,7 +176,9 @@ public function testRenderWithAttributes(): void << HTML, - Meta::tag()->attributes(['class' => 'value'])->render(), + Meta::tag() + ->attributes(['class' => 'value']) + ->render(), "Failed asserting that element renders correctly with 'attributes()' method.", ); } @@ -172,7 +189,9 @@ public function testRenderWithCharset(): void << HTML, - Meta::tag()->charset('utf-8')->render(), + Meta::tag() + ->charset('utf-8') + ->render(), "Failed asserting that element renders correctly with 'charset' attribute.", ); } @@ -183,7 +202,9 @@ public function testRenderWithClass(): void << HTML, - Meta::tag()->class('value')->render(), + Meta::tag() + ->class('value') + ->render(), "Failed asserting that element renders correctly with 'class' attribute.", ); } @@ -194,7 +215,9 @@ public function testRenderWithContent(): void << HTML, - Meta::tag()->content('width=device-width, initial-scale=1')->render(), + Meta::tag() + ->content('width=device-width, initial-scale=1') + ->render(), "Failed asserting that element renders correctly with 'content' attribute.", ); } @@ -205,7 +228,9 @@ public function testRenderWithDataAttributes(): void << HTML, - Meta::tag()->dataAttributes(['value' => 'value'])->render(), + Meta::tag() + ->dataAttributes(['value' => 'value']) + ->render(), "Failed asserting that element renders correctly with 'dataAttributes()' method.", ); } @@ -227,7 +252,9 @@ public function testRenderWithDefaultProvider(): void << HTML, - Meta::tag()->addDefaultProvider(DefaultProvider::class)->render(), + Meta::tag() + ->addDefaultProvider(DefaultProvider::class) + ->render(), 'Failed asserting that default provider is applied correctly.', ); } @@ -249,7 +276,10 @@ public function testRenderWithDescription(): void << HTML, - Meta::tag()->name('description')->content('A description of the page')->render(), + Meta::tag() + ->name('description') + ->content('A description of the page') + ->render(), 'Failed asserting that element renders correctly with description metadata.', ); } @@ -260,7 +290,9 @@ public function testRenderWithDir(): void << HTML, - Meta::tag()->dir('ltr')->render(), + Meta::tag() + ->dir('ltr') + ->render(), "Failed asserting that element renders correctly with 'dir' attribute.", ); } @@ -271,7 +303,9 @@ public function testRenderWithDirUsingEnum(): void << HTML, - Meta::tag()->dir(Direction::LTR)->render(), + Meta::tag() + ->dir(Direction::LTR) + ->render(), "Failed asserting that element renders correctly with 'dir' attribute using enum.", ); } @@ -295,7 +329,9 @@ public function testRenderWithHidden(): void << HTML, - Meta::tag()->hidden(true)->render(), + Meta::tag() + ->hidden(true) + ->render(), "Failed asserting that element renders correctly with 'hidden' attribute.", ); } @@ -306,7 +342,10 @@ public function testRenderWithHttpEquiv(): void << HTML, - Meta::tag()->httpEquiv('refresh')->content('3;url=https://example.com')->render(), + Meta::tag() + ->content('3;url=https://example.com') + ->httpEquiv('refresh') + ->render(), "Failed asserting that element renders correctly with 'http-equiv' attribute.", ); } @@ -317,7 +356,9 @@ public function testRenderWithId(): void << HTML, - Meta::tag()->id('test-id')->render(), + Meta::tag() + ->id('test-id') + ->render(), "Failed asserting that element renders correctly with 'id' attribute.", ); } @@ -328,7 +369,9 @@ public function testRenderWithLang(): void << HTML, - Meta::tag()->lang('es')->render(), + Meta::tag() + ->lang('es') + ->render(), "Failed asserting that element renders correctly with 'lang' attribute.", ); } @@ -339,7 +382,9 @@ public function testRenderWithLangUsingEnum(): void << HTML, - Meta::tag()->lang(Language::SPANISH)->render(), + Meta::tag() + ->lang(Language::SPANISH) + ->render(), "Failed asserting that element renders correctly with 'lang' attribute using enum.", ); } @@ -350,7 +395,9 @@ public function testRenderWithMedia(): void << HTML, - Meta::tag()->media('screen')->render(), + Meta::tag() + ->media('screen') + ->render(), "Failed asserting that element renders correctly with 'media' attribute.", ); } @@ -361,7 +408,9 @@ public function testRenderWithName(): void << HTML, - Meta::tag()->name('viewport')->render(), + Meta::tag() + ->name('viewport') + ->render(), "Failed asserting that element renders correctly with 'name' attribute.", ); } @@ -372,7 +421,10 @@ public function testRenderWithNameAndContent(): void << HTML, - Meta::tag()->name('viewport')->content('width=device-width, initial-scale=1')->render(), + Meta::tag() + ->content('width=device-width, initial-scale=1') + ->name('viewport') + ->render(), "Failed asserting that element renders correctly with 'name' and 'content' attributes.", ); } @@ -436,7 +488,9 @@ public function testRenderWithRoleUsingEnum(): void << HTML, - Meta::tag()->role(Role::BANNER)->render(), + Meta::tag() + ->role(Role::BANNER) + ->render(), "Failed asserting that element renders correctly with 'role' attribute using enum.", ); } @@ -447,7 +501,9 @@ public function testRenderWithStyle(): void << HTML, - Meta::tag()->style('value')->render(), + Meta::tag() + ->style('value') + ->render(), "Failed asserting that element renders correctly with 'style' attribute.", ); } @@ -458,7 +514,9 @@ public function testRenderWithThemeProvider(): void << HTML, - Meta::tag()->addThemeProvider('muted', DefaultThemeProvider::class)->render(), + Meta::tag() + ->addThemeProvider('muted', DefaultThemeProvider::class) + ->render(), "Failed asserting that element renders correctly with 'addThemeProvider()' method.", ); } @@ -469,7 +527,9 @@ public function testRenderWithTitle(): void << HTML, - Meta::tag()->title('value')->render(), + Meta::tag() + ->title('value') + ->render(), "Failed asserting that element renders correctly with 'title' attribute.", ); } @@ -478,9 +538,7 @@ public function testRenderWithToString(): void { self::assertSame( '', - LineEndingNormalizer::normalize( - (string) Meta::tag(), - ), + (string) Meta::tag(), "Failed asserting that '__toString()' method renders correctly.", ); } @@ -491,7 +549,9 @@ public function testRenderWithTranslate(): void << HTML, - Meta::tag()->translate(false)->render(), + Meta::tag() + ->translate(false) + ->render(), "Failed asserting that element renders correctly with 'translate' attribute.", ); } @@ -502,7 +562,9 @@ public function testRenderWithTranslateUsingEnum(): void << HTML, - Meta::tag()->translate(Translate::NO)->render(), + Meta::tag() + ->translate(Translate::NO) + ->render(), "Failed asserting that element renders correctly with 'translate' attribute using enum.", ); } @@ -528,7 +590,10 @@ public function testRenderWithViewport(): void << HTML, - Meta::tag()->name('viewport')->content('width=device-width, initial-scale=1')->render(), + Meta::tag() + ->content('width=device-width, initial-scale=1') + ->name('viewport') + ->render(), 'Failed asserting that element renders correctly with viewport metadata.', ); } diff --git a/tests/Metadata/NoScriptTest.php b/tests/Metadata/NoScriptTest.php index 987d909..805b2a2 100644 --- a/tests/Metadata/NoScriptTest.php +++ b/tests/Metadata/NoScriptTest.php @@ -4,7 +4,6 @@ namespace UIAwesome\Html\Tests\Metadata; -use PHPForge\Support\LineEndingNormalizer; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use UIAwesome\Html\Attribute\Values\{ @@ -34,17 +33,16 @@ * @copyright Copyright (C) 2026 Terabytesoftw. * @license https://opensource.org/license/bsd-3-clause BSD 3-Clause License. */ -#[Group('html')] #[Group('metadata')] final class NoScriptTest extends TestCase { public function testContentEncodesValues(): void { - $noscript = NoScript::tag()->content(''); - self::assertSame( '<value>', - $noscript->getContent(), + NoScript::tag() + ->content('') + ->getContent(), "Failed asserting that 'content()' method encodes values correctly.", ); } @@ -62,7 +60,9 @@ public function testGetAttributesReturnsAssignedAttributes(): void { self::assertSame( ['data-test' => 'value'], - NoScript::tag()->addAttribute('data-test', 'value')->getAttributes(), + NoScript::tag() + ->addAttribute('data-test', 'value') + ->getAttributes(), "Failed asserting that 'getAttributes()' returns the assigned attributes.", ); } @@ -75,9 +75,9 @@ public function testHtmlDoesNotEncodeValues(): void HTML, - LineEndingNormalizer::normalize( - NoScript::tag()->html('')->render(), - ), + NoScript::tag() + ->html('') + ->render(), "Failed asserting that element renders correctly with 'html()' method.", ); } @@ -89,9 +89,9 @@ public function testRenderWithAccesskey(): void HTML, - LineEndingNormalizer::normalize( - NoScript::tag()->accesskey('k')->render(), - ), + NoScript::tag() + ->accesskey('k') + ->render(), "Failed asserting that element renders correctly with 'accesskey' attribute.", ); } @@ -103,9 +103,9 @@ public function testRenderWithAddAriaAttribute(): void HTML, - LineEndingNormalizer::normalize( - NoScript::tag()->addAriaAttribute('label', 'JavaScript required')->render(), - ), + NoScript::tag() + ->addAriaAttribute('label', 'JavaScript required') + ->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method.", ); } @@ -117,9 +117,9 @@ public function testRenderWithAddAriaAttributeUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - NoScript::tag()->addAriaAttribute(Aria::HIDDEN, true)->render(), - ), + NoScript::tag() + ->addAriaAttribute(Aria::HIDDEN, true) + ->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method using enum.", ); } @@ -131,9 +131,9 @@ public function testRenderWithAddAttribute(): void HTML, - LineEndingNormalizer::normalize( - NoScript::tag()->addAttribute('data-test', 'value')->render(), - ), + NoScript::tag() + ->addAttribute('data-test', 'value') + ->render(), "Failed asserting that element renders correctly with 'addAttribute()' method.", ); } @@ -145,9 +145,9 @@ public function testRenderWithAddAttributeUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - NoScript::tag()->addAttribute(GlobalAttribute::TITLE, 'Fallback content')->render(), - ), + NoScript::tag() + ->addAttribute(GlobalAttribute::TITLE, 'Fallback content') + ->render(), "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", ); } @@ -159,9 +159,9 @@ public function testRenderWithAddDataAttribute(): void HTML, - LineEndingNormalizer::normalize( - NoScript::tag()->addDataAttribute('message', 'enable-js')->render(), - ), + NoScript::tag() + ->addDataAttribute('message', 'enable-js') + ->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method.", ); } @@ -173,9 +173,9 @@ public function testRenderWithAddDataAttributeUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - NoScript::tag()->addDataAttribute(Data::VALUE, 'test')->render(), - ), + NoScript::tag() + ->addDataAttribute(Data::VALUE, 'test') + ->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method using enum.", ); } @@ -187,16 +187,14 @@ public function testRenderWithAriaAttributes(): void HTML, - LineEndingNormalizer::normalize( - NoScript::tag() - ->ariaAttributes( - [ - 'hidden' => true, - 'label' => 'No JavaScript', - ], - ) - ->render(), - ), + NoScript::tag() + ->ariaAttributes( + [ + 'hidden' => true, + 'label' => 'No JavaScript', + ], + ) + ->render(), "Failed asserting that element renders correctly with 'ariaAttributes()' method.", ); } @@ -208,9 +206,9 @@ public function testRenderWithAttributes(): void HTML, - LineEndingNormalizer::normalize( - NoScript::tag()->attributes(['class' => 'fallback-message'])->render(), - ), + NoScript::tag() + ->attributes(['class' => 'fallback-message']) + ->render(), "Failed asserting that element renders correctly with 'attributes()' method.", ); } @@ -222,9 +220,9 @@ public function testRenderWithAutofocus(): void HTML, - LineEndingNormalizer::normalize( - NoScript::tag()->autofocus(true)->render(), - ), + NoScript::tag() + ->autofocus(true) + ->render(), "Failed asserting that element renders correctly with 'autofocus' attribute.", ); } @@ -237,9 +235,7 @@ public function testRenderWithBeginEnd(): void Please enable JavaScript HTML, - LineEndingNormalizer::normalize( - NoScript::tag()->begin() . 'Please enable JavaScript' . NoScript::end(), - ), + NoScript::tag()->begin() . 'Please enable JavaScript' . NoScript::end(), "Failed asserting that element renders correctly with 'begin()' and 'end()' methods.", ); } @@ -251,9 +247,9 @@ public function testRenderWithClass(): void HTML, - LineEndingNormalizer::normalize( - NoScript::tag()->class('no-js-message')->render(), - ), + NoScript::tag() + ->class('no-js-message') + ->render(), "Failed asserting that element renders correctly with 'class' attribute.", ); } @@ -266,9 +262,9 @@ public function testRenderWithContent(): void JavaScript is required for this application HTML, - LineEndingNormalizer::normalize( - NoScript::tag()->content('JavaScript is required for this application')->render(), - ), + NoScript::tag() + ->content('JavaScript is required for this application') + ->render(), 'Failed asserting that element renders correctly with content.', ); } @@ -280,9 +276,9 @@ public function testRenderWithContentEditable(): void HTML, - LineEndingNormalizer::normalize( - NoScript::tag()->contentEditable(true)->render(), - ), + NoScript::tag() + ->contentEditable(true) + ->render(), "Failed asserting that element renders correctly with 'contentEditable' attribute.", ); } @@ -294,9 +290,9 @@ public function testRenderWithContentEditableUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - NoScript::tag()->contentEditable(ContentEditable::TRUE)->render(), - ), + NoScript::tag() + ->contentEditable(ContentEditable::TRUE) + ->render(), "Failed asserting that element renders correctly with 'contentEditable' attribute using enum.", ); } @@ -308,9 +304,9 @@ public function testRenderWithDataAttributes(): void HTML, - LineEndingNormalizer::normalize( - NoScript::tag()->dataAttributes(['fallback' => 'true'])->render(), - ), + NoScript::tag() + ->dataAttributes(['fallback' => 'true']) + ->render(), "Failed asserting that element renders correctly with 'dataAttributes()' method.", ); } @@ -322,9 +318,7 @@ public function testRenderWithDefaultConfigurationValues(): void HTML, - LineEndingNormalizer::normalize( - NoScript::tag(['class' => 'default-class'])->render(), - ), + NoScript::tag(['class' => 'default-class'])->render(), 'Failed asserting that default configuration values are applied correctly.', ); } @@ -336,9 +330,9 @@ public function testRenderWithDefaultProvider(): void HTML, - LineEndingNormalizer::normalize( - NoScript::tag()->addDefaultProvider(DefaultProvider::class)->render(), - ), + NoScript::tag() + ->addDefaultProvider(DefaultProvider::class) + ->render(), 'Failed asserting that default provider is applied correctly.', ); } @@ -350,9 +344,7 @@ public function testRenderWithDefaultValues(): void HTML, - LineEndingNormalizer::normalize( - NoScript::tag()->render(), - ), + NoScript::tag()->render(), 'Failed asserting that element renders correctly with default values.', ); } @@ -364,9 +356,9 @@ public function testRenderWithDir(): void HTML, - LineEndingNormalizer::normalize( - NoScript::tag()->dir('ltr')->render(), - ), + NoScript::tag() + ->dir('ltr') + ->render(), "Failed asserting that element renders correctly with 'dir' attribute.", ); } @@ -378,9 +370,9 @@ public function testRenderWithDirUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - NoScript::tag()->dir(Direction::RTL)->render(), - ), + NoScript::tag() + ->dir(Direction::RTL) + ->render(), "Failed asserting that element renders correctly with 'dir' attribute using enum.", ); } @@ -392,9 +384,9 @@ public function testRenderWithDraggable(): void HTML, - LineEndingNormalizer::normalize( - NoScript::tag()->draggable(true)->render(), - ), + NoScript::tag() + ->draggable(true) + ->render(), "Failed asserting that element renders correctly with 'draggable' attribute.", ); } @@ -406,9 +398,9 @@ public function testRenderWithDraggableUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - NoScript::tag()->draggable(Draggable::TRUE)->render(), - ), + NoScript::tag() + ->draggable(Draggable::TRUE) + ->render(), "Failed asserting that element renders correctly with 'draggable' attribute using enum.", ); } @@ -422,9 +414,7 @@ public function testRenderWithGlobalDefaultsAreApplied(): void HTML, - LineEndingNormalizer::normalize( - NoScript::tag()->render(), - ), + NoScript::tag()->render(), 'Failed asserting that global defaults are applied correctly.', ); @@ -438,9 +428,9 @@ public function testRenderWithHidden(): void HTML, - LineEndingNormalizer::normalize( - NoScript::tag()->hidden(true)->render(), - ), + NoScript::tag() + ->hidden(true) + ->render(), "Failed asserting that element renders correctly with 'hidden' attribute.", ); } @@ -452,9 +442,9 @@ public function testRenderWithId(): void HTML, - LineEndingNormalizer::normalize( - NoScript::tag()->id('noscript-fallback')->render(), - ), + NoScript::tag() + ->id('noscript-fallback') + ->render(), "Failed asserting that element renders correctly with 'id' attribute.", ); } @@ -466,9 +456,9 @@ public function testRenderWithLang(): void HTML, - LineEndingNormalizer::normalize( - NoScript::tag()->lang('en')->render(), - ), + NoScript::tag() + ->lang('en') + ->render(), "Failed asserting that element renders correctly with 'lang' attribute.", ); } @@ -480,9 +470,9 @@ public function testRenderWithLangUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - NoScript::tag()->lang(Language::SPANISH)->render(), - ), + NoScript::tag() + ->lang(Language::SPANISH) + ->render(), "Failed asserting that element renders correctly with 'lang' attribute using enum.", ); } @@ -494,15 +484,13 @@ public function testRenderWithMicroData(): void HTML, - LineEndingNormalizer::normalize( - NoScript::tag() - ->itemId('https://example.com/item') - ->itemProp('name') - ->itemRef('info') - ->itemScope(true) - ->itemType('https://schema.org/Thing') - ->render(), - ), + NoScript::tag() + ->itemId('https://example.com/item') + ->itemProp('name') + ->itemRef('info') + ->itemScope(true) + ->itemType('https://schema.org/Thing') + ->render(), 'Failed asserting that element renders correctly with microdata attributes.', ); } @@ -514,12 +502,10 @@ public function testRenderWithRemoveAriaAttribute(): void HTML, - LineEndingNormalizer::normalize( - NoScript::tag() - ->addAriaAttribute('label', 'Test') - ->removeAriaAttribute('label') - ->render(), - ), + NoScript::tag() + ->addAriaAttribute('label', 'Test') + ->removeAriaAttribute('label') + ->render(), "Failed asserting that element renders correctly with 'removeAriaAttribute()' method.", ); } @@ -531,12 +517,10 @@ public function testRenderWithRemoveAttribute(): void HTML, - LineEndingNormalizer::normalize( - NoScript::tag() - ->addAttribute('data-test', 'value') - ->removeAttribute('data-test') - ->render(), - ), + NoScript::tag() + ->addAttribute('data-test', 'value') + ->removeAttribute('data-test') + ->render(), "Failed asserting that element renders correctly with 'removeAttribute()' method.", ); } @@ -548,12 +532,10 @@ public function testRenderWithRemoveDataAttribute(): void HTML, - LineEndingNormalizer::normalize( - NoScript::tag() - ->addDataAttribute('test', 'value') - ->removeDataAttribute('test') - ->render(), - ), + NoScript::tag() + ->addDataAttribute('test', 'value') + ->removeDataAttribute('test') + ->render(), "Failed asserting that element renders correctly with 'removeDataAttribute()' method.", ); } @@ -565,9 +547,9 @@ public function testRenderWithRole(): void HTML, - LineEndingNormalizer::normalize( - NoScript::tag()->role('alert')->render(), - ), + NoScript::tag() + ->role('alert') + ->render(), "Failed asserting that element renders correctly with 'role' attribute.", ); } @@ -579,9 +561,9 @@ public function testRenderWithRoleUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - NoScript::tag()->role(Role::ALERT)->render(), - ), + NoScript::tag() + ->role(Role::ALERT) + ->render(), "Failed asserting that element renders correctly with 'role' attribute using enum.", ); } @@ -593,9 +575,9 @@ public function testRenderWithSpellcheck(): void HTML, - LineEndingNormalizer::normalize( - NoScript::tag()->spellcheck(true)->render(), - ), + NoScript::tag() + ->spellcheck(true) + ->render(), "Failed asserting that element renders correctly with 'spellcheck' attribute.", ); } @@ -607,9 +589,9 @@ public function testRenderWithStyle(): void HTML, - LineEndingNormalizer::normalize( - NoScript::tag()->style('color: red;')->render(), - ), + NoScript::tag() + ->style('color: red;') + ->render(), "Failed asserting that element renders correctly with 'style' attribute.", ); } @@ -621,9 +603,9 @@ public function testRenderWithTabindex(): void HTML, - LineEndingNormalizer::normalize( - NoScript::tag()->tabIndex(0)->render(), - ), + NoScript::tag() + ->tabIndex(0) + ->render(), "Failed asserting that element renders correctly with 'tabindex' attribute.", ); } @@ -635,9 +617,9 @@ public function testRenderWithThemeProvider(): void HTML, - LineEndingNormalizer::normalize( - NoScript::tag()->addThemeProvider('muted', DefaultThemeProvider::class)->render(), - ), + NoScript::tag() + ->addThemeProvider('muted', DefaultThemeProvider::class) + ->render(), "Failed asserting that element renders correctly with 'addThemeProvider()' method.", ); } @@ -649,9 +631,9 @@ public function testRenderWithTitle(): void HTML, - LineEndingNormalizer::normalize( - NoScript::tag()->title('JavaScript fallback')->render(), - ), + NoScript::tag() + ->title('JavaScript fallback') + ->render(), "Failed asserting that element renders correctly with 'title' attribute.", ); } @@ -663,9 +645,7 @@ public function testRenderWithToString(): void HTML, - LineEndingNormalizer::normalize( - (string) NoScript::tag(), - ), + (string) NoScript::tag(), "Failed asserting that '__toString()' method renders correctly.", ); } @@ -677,9 +657,9 @@ public function testRenderWithTranslate(): void HTML, - LineEndingNormalizer::normalize( - NoScript::tag()->translate(false)->render(), - ), + NoScript::tag() + ->translate(false) + ->render(), "Failed asserting that element renders correctly with 'translate' attribute.", ); } @@ -691,9 +671,9 @@ public function testRenderWithTranslateUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - NoScript::tag()->translate(Translate::NO)->render(), - ), + NoScript::tag() + ->translate(Translate::NO) + ->render(), "Failed asserting that element renders correctly with 'translate' attribute using enum.", ); } @@ -707,9 +687,7 @@ public function testRenderWithUserOverridesGlobalDefaults(): void HTML, - LineEndingNormalizer::normalize( - NoScript::tag(['id' => 'id-user'])->render(), - ), + NoScript::tag(['id' => 'id-user'])->render(), 'Failed asserting that user-defined attributes override global defaults correctly.', ); diff --git a/tests/Metadata/ScriptTest.php b/tests/Metadata/ScriptTest.php index 12e08e2..284805b 100644 --- a/tests/Metadata/ScriptTest.php +++ b/tests/Metadata/ScriptTest.php @@ -5,7 +5,6 @@ namespace UIAwesome\Html\Tests\Metadata; use InvalidArgumentException; -use PHPForge\Support\LineEndingNormalizer; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use UIAwesome\Html\Attribute\Values\{ @@ -44,17 +43,16 @@ * @copyright Copyright (C) 2026 Terabytesoftw. * @license https://opensource.org/license/bsd-3-clause BSD 3-Clause License. */ -#[Group('html')] #[Group('metadata')] final class ScriptTest extends TestCase { public function testContentEncodesValues(): void { - $script = Script::tag()->content(''); - self::assertSame( '<value>', - $script->getContent(), + Script::tag() + ->content('') + ->getContent(), "Failed asserting that 'content()' method encodes values correctly.", ); } @@ -72,7 +70,9 @@ public function testGetAttributesReturnsAssignedAttributes(): void { self::assertSame( ['data-test' => 'value'], - Script::tag()->addAttribute('data-test', 'value')->getAttributes(), + Script::tag() + ->addAttribute('data-test', 'value') + ->getAttributes(), "Failed asserting that 'getAttributes()' returns the assigned attributes.", ); } @@ -85,9 +85,9 @@ public function testHtmlDoesNotEncodeValues(): void HTML, - LineEndingNormalizer::normalize( - Script::tag()->html('')->render(), - ), + Script::tag() + ->html('') + ->render(), "Failed asserting that element renders correctly with 'html()' method.", ); } @@ -99,9 +99,9 @@ public function testRenderWithAccesskey(): void HTML, - LineEndingNormalizer::normalize( - Script::tag()->accesskey('k')->render(), - ), + Script::tag() + ->accesskey('k') + ->render(), "Failed asserting that element renders correctly with 'accesskey' attribute.", ); } @@ -113,9 +113,9 @@ public function testRenderWithAddAriaAttribute(): void HTML, - LineEndingNormalizer::normalize( - Script::tag()->addAriaAttribute('pressed', true)->render(), - ), + Script::tag() + ->addAriaAttribute('pressed', true) + ->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method.", ); } @@ -127,9 +127,9 @@ public function testRenderWithAddAriaAttributeUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - Script::tag()->addAriaAttribute(Aria::PRESSED, true)->render(), - ), + Script::tag() + ->addAriaAttribute(Aria::PRESSED, true) + ->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method.", ); } @@ -141,9 +141,9 @@ public function testRenderWithAddAttribute(): void HTML, - LineEndingNormalizer::normalize( - Script::tag()->addAttribute('data-test', 'value')->render(), - ), + Script::tag() + ->addAttribute('data-test', 'value') + ->render(), "Failed asserting that element renders correctly with 'addAttribute()' method.", ); } @@ -155,9 +155,9 @@ public function testRenderWithAddAttributeUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - Script::tag()->addAttribute(GlobalAttribute::TITLE, 'value')->render(), - ), + Script::tag() + ->addAttribute(GlobalAttribute::TITLE, 'value') + ->render(), "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", ); } @@ -169,9 +169,9 @@ public function testRenderWithAddDataAttribute(): void HTML, - LineEndingNormalizer::normalize( - Script::tag()->addDataAttribute('value', 'value')->render(), - ), + Script::tag() + ->addDataAttribute('value', 'value') + ->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method.", ); } @@ -183,9 +183,9 @@ public function testRenderWithAddDataAttributeUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - Script::tag()->addDataAttribute(Data::VALUE, 'value')->render(), - ), + Script::tag() + ->addDataAttribute(Data::VALUE, 'value') + ->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method.", ); } @@ -197,17 +197,15 @@ public function testRenderWithAriaAttributes(): void HTML, - LineEndingNormalizer::normalize( - Script::tag() - ->ariaAttributes( - [ - 'controls' => static fn(): string => 'modal-1', - 'hidden' => false, - 'label' => 'Close', - ], - ) - ->render(), - ), + Script::tag() + ->ariaAttributes( + [ + 'controls' => static fn(): string => 'modal-1', + 'hidden' => false, + 'label' => 'Close', + ], + ) + ->render(), "Failed asserting that element renders correctly with 'ariaAttributes()' method.", ); } @@ -219,9 +217,9 @@ public function testRenderWithAsync(): void HTML, - LineEndingNormalizer::normalize( - Script::tag()->async(true)->render(), - ), + Script::tag() + ->async(true) + ->render(), "Failed asserting that element renders correctly with 'async' attribute.", ); } @@ -233,9 +231,9 @@ public function testRenderWithAttributes(): void HTML, - LineEndingNormalizer::normalize( - Script::tag()->attributes(['class' => 'value'])->render(), - ), + Script::tag() + ->attributes(['class' => 'value']) + ->render(), "Failed asserting that element renders correctly with 'attributes()' method.", ); } @@ -247,9 +245,9 @@ public function testRenderWithAutofocus(): void HTML, - LineEndingNormalizer::normalize( - Script::tag()->autofocus(true)->render(), - ), + Script::tag() + ->autofocus(true) + ->render(), "Failed asserting that element renders correctly with 'autofocus' attribute.", ); } @@ -262,9 +260,7 @@ public function testRenderWithBeginEnd(): void console.log('test'); HTML, - LineEndingNormalizer::normalize( - Script::tag()->begin() . "console.log('test');" . Script::end(), - ), + Script::tag()->begin() . "console.log('test');" . Script::end(), "Failed asserting that element renders correctly with 'begin()' and 'end()' methods.", ); } @@ -276,9 +272,9 @@ public function testRenderWithBlocking(): void HTML, - LineEndingNormalizer::normalize( - Script::tag()->blocking('render')->render(), - ), + Script::tag() + ->blocking('render') + ->render(), "Failed asserting that element renders correctly with 'blocking' attribute.", ); } @@ -290,9 +286,9 @@ public function testRenderWithBlockingUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - Script::tag()->blocking(Blocking::RENDER)->render(), - ), + Script::tag() + ->blocking(Blocking::RENDER) + ->render(), "Failed asserting that element renders correctly with 'blocking' attribute using enum.", ); } @@ -304,9 +300,9 @@ public function testRenderWithClass(): void HTML, - LineEndingNormalizer::normalize( - Script::tag()->class('value')->render(), - ), + Script::tag() + ->class('value') + ->render(), "Failed asserting that element renders correctly with 'class' attribute.", ); } @@ -319,9 +315,9 @@ public function testRenderWithContent(): void console.log('Hello'); HTML, - LineEndingNormalizer::normalize( - Script::tag()->content("console.log('Hello');")->render(), - ), + Script::tag() + ->content("console.log('Hello');") + ->render(), 'Failed asserting that element renders correctly with default values.', ); } @@ -333,9 +329,9 @@ public function testRenderWithContentEditable(): void HTML, - LineEndingNormalizer::normalize( - Script::tag()->contentEditable(true)->render(), - ), + Script::tag() + ->contentEditable(true) + ->render(), "Failed asserting that element renders correctly with 'contentEditable' attribute.", ); } @@ -347,9 +343,9 @@ public function testRenderWithContentEditableUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - Script::tag()->contentEditable(ContentEditable::TRUE)->render(), - ), + Script::tag() + ->contentEditable(ContentEditable::TRUE) + ->render(), "Failed asserting that element renders correctly with 'contentEditable' attribute using enum.", ); } @@ -361,9 +357,9 @@ public function testRenderWithCrossorigin(): void HTML, - LineEndingNormalizer::normalize( - Script::tag()->crossorigin('anonymous')->render(), - ), + Script::tag() + ->crossorigin('anonymous') + ->render(), "Failed asserting that element renders correctly with 'crossorigin' attribute.", ); } @@ -375,9 +371,9 @@ public function testRenderWithCrossoriginUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - Script::tag()->crossorigin(Crossorigin::ANONYMOUS)->render(), - ), + Script::tag() + ->crossorigin(Crossorigin::ANONYMOUS) + ->render(), "Failed asserting that element renders correctly with 'crossorigin' attribute using enum.", ); } @@ -389,9 +385,9 @@ public function testRenderWithDataAttributes(): void HTML, - LineEndingNormalizer::normalize( - Script::tag()->dataAttributes(['value' => 'value'])->render(), - ), + Script::tag() + ->dataAttributes(['value' => 'value']) + ->render(), "Failed asserting that element renders correctly with 'dataAttributes()' method.", ); } @@ -403,9 +399,7 @@ public function testRenderWithDefaultConfigurationValues(): void HTML, - LineEndingNormalizer::normalize( - Script::tag(['class' => 'default-class'])->render(), - ), + Script::tag(['class' => 'default-class'])->render(), 'Failed asserting that default configuration values are applied correctly.', ); } @@ -417,9 +411,9 @@ public function testRenderWithDefaultProvider(): void HTML, - LineEndingNormalizer::normalize( - Script::tag()->addDefaultProvider(DefaultProvider::class)->render(), - ), + Script::tag() + ->addDefaultProvider(DefaultProvider::class) + ->render(), 'Failed asserting that default provider is applied correctly.', ); } @@ -431,9 +425,7 @@ public function testRenderWithDefaultValues(): void HTML, - LineEndingNormalizer::normalize( - Script::tag()->render(), - ), + Script::tag()->render(), 'Failed asserting that element renders correctly with default values.', ); } @@ -445,9 +437,9 @@ public function testRenderWithDefer(): void HTML, - LineEndingNormalizer::normalize( - Script::tag()->defer(true)->render(), - ), + Script::tag() + ->defer(true) + ->render(), "Failed asserting that element renders correctly with 'defer' attribute.", ); } @@ -459,9 +451,9 @@ public function testRenderWithDir(): void HTML, - LineEndingNormalizer::normalize( - Script::tag()->dir('ltr')->render(), - ), + Script::tag() + ->dir('ltr') + ->render(), "Failed asserting that element renders correctly with 'dir' attribute.", ); } @@ -473,9 +465,9 @@ public function testRenderWithDirUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - Script::tag()->dir(Direction::LTR)->render(), - ), + Script::tag() + ->dir(Direction::LTR) + ->render(), "Failed asserting that element renders correctly with 'dir' attribute using enum.", ); } @@ -487,9 +479,9 @@ public function testRenderWithDraggable(): void HTML, - LineEndingNormalizer::normalize( - Script::tag()->draggable(true)->render(), - ), + Script::tag() + ->draggable(true) + ->render(), "Failed asserting that element renders correctly with 'draggable' attribute.", ); } @@ -501,9 +493,9 @@ public function testRenderWithDraggableUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - Script::tag()->draggable(Draggable::TRUE)->render(), - ), + Script::tag() + ->draggable(Draggable::TRUE) + ->render(), "Failed asserting that element renders correctly with 'draggable' attribute using enum.", ); } @@ -515,9 +507,9 @@ public function testRenderWithFetchpriority(): void HTML, - LineEndingNormalizer::normalize( - Script::tag()->fetchpriority('high')->render(), - ), + Script::tag() + ->fetchpriority('high') + ->render(), "Failed asserting that element renders correctly with 'fetchpriority' attribute.", ); } @@ -529,9 +521,9 @@ public function testRenderWithFetchpriorityUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - Script::tag()->fetchpriority(Fetchpriority::HIGH)->render(), - ), + Script::tag() + ->fetchpriority(Fetchpriority::HIGH) + ->render(), "Failed asserting that element renders correctly with 'fetchpriority' attribute using enum.", ); } @@ -545,9 +537,7 @@ public function testRenderWithGlobalDefaultsAreApplied(): void HTML, - LineEndingNormalizer::normalize( - Script::tag()->render(), - ), + Script::tag()->render(), 'Failed asserting that global defaults are applied correctly.', ); @@ -561,9 +551,9 @@ public function testRenderWithHidden(): void HTML, - LineEndingNormalizer::normalize( - Script::tag()->hidden(true)->render(), - ), + Script::tag() + ->hidden(true) + ->render(), "Failed asserting that element renders correctly with 'hidden' attribute.", ); } @@ -575,9 +565,9 @@ public function testRenderWithId(): void HTML, - LineEndingNormalizer::normalize( - Script::tag()->id('test-id')->render(), - ), + Script::tag() + ->id('test-id') + ->render(), "Failed asserting that element renders correctly with 'id' attribute.", ); } @@ -589,9 +579,9 @@ public function testRenderWithIntegrity(): void HTML, - LineEndingNormalizer::normalize( - Script::tag()->integrity('sha384-abc123')->render(), - ), + Script::tag() + ->integrity('sha384-abc123') + ->render(), "Failed asserting that element renders correctly with 'integrity' attribute.", ); } @@ -603,9 +593,9 @@ public function testRenderWithLang(): void HTML, - LineEndingNormalizer::normalize( - Script::tag()->lang('es')->render(), - ), + Script::tag() + ->lang('es') + ->render(), "Failed asserting that element renders correctly with 'lang' attribute.", ); } @@ -617,9 +607,9 @@ public function testRenderWithLangUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - Script::tag()->lang(Language::SPANISH)->render(), - ), + Script::tag() + ->lang(Language::SPANISH) + ->render(), "Failed asserting that element renders correctly with 'lang' attribute using enum.", ); } @@ -631,15 +621,13 @@ public function testRenderWithMicroData(): void HTML, - LineEndingNormalizer::normalize( - Script::tag() - ->itemId('https://example.com/item') - ->itemProp('name') - ->itemRef('info') - ->itemScope(true) - ->itemType('https://schema.org/Thing') - ->render(), - ), + Script::tag() + ->itemId('https://example.com/item') + ->itemProp('name') + ->itemRef('info') + ->itemScope(true) + ->itemType('https://schema.org/Thing') + ->render(), 'Failed asserting that element renders correctly with microdata attributes.', ); } @@ -651,9 +639,9 @@ public function testRenderWithNomodule(): void HTML, - LineEndingNormalizer::normalize( - Script::tag()->nomodule(true)->render(), - ), + Script::tag() + ->nomodule(true) + ->render(), "Failed asserting that element renders correctly with 'nomodule' attribute.", ); } @@ -665,9 +653,9 @@ public function testRenderWithReferrerpolicy(): void HTML, - LineEndingNormalizer::normalize( - Script::tag()->referrerpolicy('no-referrer')->render(), - ), + Script::tag() + ->referrerpolicy('no-referrer') + ->render(), "Failed asserting that element renders correctly with 'referrerpolicy' attribute.", ); } @@ -679,9 +667,9 @@ public function testRenderWithReferrerpolicyUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - Script::tag()->referrerpolicy(Referrerpolicy::NO_REFERRER)->render(), - ), + Script::tag() + ->referrerpolicy(Referrerpolicy::NO_REFERRER) + ->render(), "Failed asserting that element renders correctly with 'referrerpolicy' attribute using enum.", ); } @@ -693,12 +681,10 @@ public function testRenderWithRemoveAriaAttribute(): void HTML, - LineEndingNormalizer::normalize( - Script::tag() - ->addAriaAttribute('label', 'Close') - ->removeAriaAttribute('label') - ->render(), - ), + Script::tag() + ->addAriaAttribute('label', 'Close') + ->removeAriaAttribute('label') + ->render(), "Failed asserting that element renders correctly with 'removeAriaAttribute()' method.", ); } @@ -710,12 +696,10 @@ public function testRenderWithRemoveAttribute(): void HTML, - LineEndingNormalizer::normalize( - Script::tag() - ->addAttribute('data-test', 'value') - ->removeAttribute('data-test') - ->render(), - ), + Script::tag() + ->addAttribute('data-test', 'value') + ->removeAttribute('data-test') + ->render(), "Failed asserting that element renders correctly with 'removeAttribute()' method.", ); } @@ -727,12 +711,10 @@ public function testRenderWithRemoveDataAttribute(): void HTML, - LineEndingNormalizer::normalize( - Script::tag() - ->addDataAttribute('value', 'test') - ->removeDataAttribute('value') - ->render(), - ), + Script::tag() + ->addDataAttribute('value', 'test') + ->removeDataAttribute('value') + ->render(), "Failed asserting that element renders correctly with 'removeDataAttribute()' method.", ); } @@ -744,9 +726,9 @@ public function testRenderWithRole(): void HTML, - LineEndingNormalizer::normalize( - Script::tag()->role('banner')->render(), - ), + Script::tag() + ->role('banner') + ->render(), "Failed asserting that element renders correctly with 'role' attribute.", ); } @@ -758,9 +740,9 @@ public function testRenderWithRoleUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - Script::tag()->role(Role::BANNER)->render(), - ), + Script::tag() + ->role(Role::BANNER) + ->render(), "Failed asserting that element renders correctly with 'role' attribute using enum.", ); } @@ -772,9 +754,9 @@ public function testRenderWithSpellcheck(): void HTML, - LineEndingNormalizer::normalize( - Script::tag()->spellcheck(true)->render(), - ), + Script::tag() + ->spellcheck(true) + ->render(), "Failed asserting that element renders correctly with 'spellcheck' attribute.", ); } @@ -786,9 +768,9 @@ public function testRenderWithSrc(): void HTML, - LineEndingNormalizer::normalize( - Script::tag()->src('https://example.com/script.js')->render(), - ), + Script::tag() + ->src('https://example.com/script.js') + ->render(), "Failed asserting that element renders correctly with 'src' attribute.", ); } @@ -800,9 +782,9 @@ public function testRenderWithStyle(): void HTML, - LineEndingNormalizer::normalize( - Script::tag()->style('value')->render(), - ), + Script::tag() + ->style('value') + ->render(), "Failed asserting that element renders correctly with 'style' attribute.", ); } @@ -814,9 +796,9 @@ public function testRenderWithTabindex(): void HTML, - LineEndingNormalizer::normalize( - Script::tag()->tabIndex(3)->render(), - ), + Script::tag() + ->tabIndex(3) + ->render(), "Failed asserting that element renders correctly with 'tabindex' attribute.", ); } @@ -828,9 +810,9 @@ public function testRenderWithThemeProvider(): void HTML, - LineEndingNormalizer::normalize( - Script::tag()->addThemeProvider('muted', DefaultThemeProvider::class)->render(), - ), + Script::tag() + ->addThemeProvider('muted', DefaultThemeProvider::class) + ->render(), "Failed asserting that element renders correctly with 'addThemeProvider()' method.", ); } @@ -842,9 +824,9 @@ public function testRenderWithTitle(): void HTML, - LineEndingNormalizer::normalize( - Script::tag()->title('value')->render(), - ), + Script::tag() + ->title('value') + ->render(), "Failed asserting that element renders correctly with 'title' attribute.", ); } @@ -856,9 +838,7 @@ public function testRenderWithToString(): void HTML, - LineEndingNormalizer::normalize( - (string) Script::tag(), - ), + (string) Script::tag(), "Failed asserting that '__toString()' method renders correctly.", ); } @@ -870,9 +850,9 @@ public function testRenderWithTranslate(): void HTML, - LineEndingNormalizer::normalize( - Script::tag()->translate(false)->render(), - ), + Script::tag() + ->translate(false) + ->render(), "Failed asserting that element renders correctly with 'translate' attribute.", ); } @@ -884,9 +864,9 @@ public function testRenderWithTranslateUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - Script::tag()->translate(Translate::NO)->render(), - ), + Script::tag() + ->translate(Translate::NO) + ->render(), "Failed asserting that element renders correctly with 'translate' attribute using enum.", ); } @@ -898,9 +878,9 @@ public function testRenderWithType(): void HTML, - LineEndingNormalizer::normalize( - Script::tag()->type('module')->render(), - ), + Script::tag() + ->type('module') + ->render(), "Failed asserting that element renders correctly with 'type' attribute.", ); } @@ -914,9 +894,7 @@ public function testRenderWithUserOverridesGlobalDefaults(): void HTML, - LineEndingNormalizer::normalize( - Script::tag(['id' => 'id-user'])->render(), - ), + Script::tag(['id' => 'id-user'])->render(), 'Failed asserting that user-defined attributes override global defaults correctly.', ); diff --git a/tests/Metadata/StyleTest.php b/tests/Metadata/StyleTest.php index f31646d..491aebb 100644 --- a/tests/Metadata/StyleTest.php +++ b/tests/Metadata/StyleTest.php @@ -5,7 +5,6 @@ namespace UIAwesome\Html\Tests\Metadata; use InvalidArgumentException; -use PHPForge\Support\LineEndingNormalizer; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use UIAwesome\Html\Attribute\Values\{ @@ -40,17 +39,16 @@ * @copyright Copyright (C) 2026 Terabytesoftw. * @license https://opensource.org/license/bsd-3-clause BSD 3-Clause License. */ -#[Group('html')] #[Group('metadata')] final class StyleTest extends TestCase { public function testContentEncodesValues(): void { - $style = Style::tag()->content(''); - self::assertSame( '<value>', - $style->getContent(), + Style::tag() + ->content('') + ->getContent(), "Failed asserting that 'content()' method encodes values correctly.", ); } @@ -68,7 +66,9 @@ public function testGetAttributesReturnsAssignedAttributes(): void { self::assertSame( ['data-test' => 'value'], - Style::tag()->addAttribute('data-test', 'value')->getAttributes(), + Style::tag() + ->addAttribute('data-test', 'value') + ->getAttributes(), "Failed asserting that 'getAttributes()' returns the assigned attributes.", ); } @@ -81,9 +81,9 @@ public function testHtmlDoesNotEncodeValues(): void HTML, - LineEndingNormalizer::normalize( - Style::tag()->html('')->render(), - ), + Style::tag() + ->html('') + ->render(), "Failed asserting that element renders correctly with 'html()' method.", ); } @@ -95,9 +95,9 @@ public function testRenderWithAccesskey(): void HTML, - LineEndingNormalizer::normalize( - Style::tag()->accesskey('k')->render(), - ), + Style::tag() + ->accesskey('k') + ->render(), "Failed asserting that element renders correctly with 'accesskey' attribute.", ); } @@ -109,9 +109,9 @@ public function testRenderWithAddAriaAttribute(): void HTML, - LineEndingNormalizer::normalize( - Style::tag()->addAriaAttribute('pressed', true)->render(), - ), + Style::tag() + ->addAriaAttribute('pressed', true) + ->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method.", ); } @@ -123,9 +123,9 @@ public function testRenderWithAddAriaAttributeUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - Style::tag()->addAriaAttribute(Aria::PRESSED, true)->render(), - ), + Style::tag() + ->addAriaAttribute(Aria::PRESSED, true) + ->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method.", ); } @@ -137,9 +137,9 @@ public function testRenderWithAddAttribute(): void HTML, - LineEndingNormalizer::normalize( - Style::tag()->addAttribute('data-test', 'value')->render(), - ), + Style::tag() + ->addAttribute('data-test', 'value') + ->render(), "Failed asserting that element renders correctly with 'addAttribute()' method.", ); } @@ -151,9 +151,9 @@ public function testRenderWithAddAttributeUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - Style::tag()->addAttribute(GlobalAttribute::TITLE, 'value')->render(), - ), + Style::tag() + ->addAttribute(GlobalAttribute::TITLE, 'value') + ->render(), "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", ); } @@ -165,9 +165,9 @@ public function testRenderWithAddDataAttribute(): void HTML, - LineEndingNormalizer::normalize( - Style::tag()->addDataAttribute('value', 'value')->render(), - ), + Style::tag() + ->addDataAttribute('value', 'value') + ->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method.", ); } @@ -179,9 +179,9 @@ public function testRenderWithAddDataAttributeUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - Style::tag()->addDataAttribute(Data::VALUE, 'value')->render(), - ), + Style::tag() + ->addDataAttribute(Data::VALUE, 'value') + ->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method.", ); } @@ -193,17 +193,15 @@ public function testRenderWithAriaAttributes(): void HTML, - LineEndingNormalizer::normalize( - Style::tag() - ->ariaAttributes( - [ - 'controls' => static fn(): string => 'modal-1', - 'hidden' => false, - 'label' => 'Close', - ], - ) - ->render(), - ), + Style::tag() + ->ariaAttributes( + [ + 'controls' => static fn(): string => 'modal-1', + 'hidden' => false, + 'label' => 'Close', + ], + ) + ->render(), "Failed asserting that element renders correctly with 'ariaAttributes()' method.", ); } @@ -215,9 +213,9 @@ public function testRenderWithAttributes(): void HTML, - LineEndingNormalizer::normalize( - Style::tag()->attributes(['class' => 'value'])->render(), - ), + Style::tag() + ->attributes(['class' => 'value']) + ->render(), "Failed asserting that element renders correctly with 'attributes()' method.", ); } @@ -229,9 +227,9 @@ public function testRenderWithAutofocus(): void HTML, - LineEndingNormalizer::normalize( - Style::tag()->autofocus(true)->render(), - ), + Style::tag() + ->autofocus(true) + ->render(), "Failed asserting that element renders correctly with 'autofocus' attribute.", ); } @@ -244,9 +242,7 @@ public function testRenderWithBeginEnd(): void Content HTML, - LineEndingNormalizer::normalize( - Style::tag()->begin() . 'Content' . Style::end(), - ), + Style::tag()->begin() . 'Content' . Style::end(), "Failed asserting that element renders correctly with 'begin()' and 'end()' methods.", ); } @@ -258,9 +254,9 @@ public function testRenderWithBlocking(): void HTML, - LineEndingNormalizer::normalize( - Style::tag()->blocking('render')->render(), - ), + Style::tag() + ->blocking('render') + ->render(), "Failed asserting that element renders correctly with 'blocking' attribute.", ); } @@ -272,9 +268,9 @@ public function testRenderWithBlockingUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - Style::tag()->blocking(Blocking::RENDER)->render(), - ), + Style::tag() + ->blocking(Blocking::RENDER) + ->render(), "Failed asserting that element renders correctly with 'blocking' attribute using enum.", ); } @@ -286,9 +282,9 @@ public function testRenderWithClass(): void HTML, - LineEndingNormalizer::normalize( - Style::tag()->class('value')->render(), - ), + Style::tag() + ->class('value') + ->render(), "Failed asserting that element renders correctly with 'class' attribute.", ); } @@ -301,9 +297,9 @@ public function testRenderWithContent(): void value HTML, - LineEndingNormalizer::normalize( - Style::tag()->content('value')->render(), - ), + Style::tag() + ->content('value') + ->render(), 'Failed asserting that element renders correctly with default values.', ); } @@ -315,9 +311,9 @@ public function testRenderWithContentEditable(): void HTML, - LineEndingNormalizer::normalize( - Style::tag()->contentEditable(true)->render(), - ), + Style::tag() + ->contentEditable(true) + ->render(), "Failed asserting that element renders correctly with 'contentEditable' attribute.", ); } @@ -329,9 +325,9 @@ public function testRenderWithContentEditableUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - Style::tag()->contentEditable(ContentEditable::TRUE)->render(), - ), + Style::tag() + ->contentEditable(ContentEditable::TRUE) + ->render(), "Failed asserting that element renders correctly with 'contentEditable' attribute using enum.", ); } @@ -343,9 +339,9 @@ public function testRenderWithDataAttributes(): void HTML, - LineEndingNormalizer::normalize( - Style::tag()->dataAttributes(['value' => 'value'])->render(), - ), + Style::tag() + ->dataAttributes(['value' => 'value']) + ->render(), "Failed asserting that element renders correctly with 'dataAttributes()' method.", ); } @@ -357,9 +353,7 @@ public function testRenderWithDefaultConfigurationValues(): void HTML, - LineEndingNormalizer::normalize( - Style::tag(['class' => 'default-class'])->render(), - ), + Style::tag(['class' => 'default-class'])->render(), 'Failed asserting that default configuration values are applied correctly.', ); } @@ -371,9 +365,9 @@ public function testRenderWithDefaultProvider(): void HTML, - LineEndingNormalizer::normalize( - Style::tag()->addDefaultProvider(DefaultProvider::class)->render(), - ), + Style::tag() + ->addDefaultProvider(DefaultProvider::class) + ->render(), 'Failed asserting that default provider is applied correctly.', ); } @@ -385,9 +379,7 @@ public function testRenderWithDefaultValues(): void HTML, - LineEndingNormalizer::normalize( - Style::tag()->render(), - ), + Style::tag()->render(), 'Failed asserting that element renders correctly with default values.', ); } @@ -399,9 +391,9 @@ public function testRenderWithDir(): void HTML, - LineEndingNormalizer::normalize( - Style::tag()->dir('ltr')->render(), - ), + Style::tag() + ->dir('ltr') + ->render(), "Failed asserting that element renders correctly with 'dir' attribute.", ); } @@ -413,9 +405,9 @@ public function testRenderWithDirUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - Style::tag()->dir(Direction::LTR)->render(), - ), + Style::tag() + ->dir(Direction::LTR) + ->render(), "Failed asserting that element renders correctly with 'dir' attribute using enum.", ); } @@ -427,9 +419,9 @@ public function testRenderWithDraggable(): void HTML, - LineEndingNormalizer::normalize( - Style::tag()->draggable(true)->render(), - ), + Style::tag() + ->draggable(true) + ->render(), "Failed asserting that element renders correctly with 'draggable' attribute.", ); } @@ -441,9 +433,9 @@ public function testRenderWithDraggableUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - Style::tag()->draggable(Draggable::TRUE)->render(), - ), + Style::tag() + ->draggable(Draggable::TRUE) + ->render(), "Failed asserting that element renders correctly with 'draggable' attribute using enum.", ); } @@ -457,9 +449,7 @@ public function testRenderWithGlobalDefaultsAreApplied(): void HTML, - LineEndingNormalizer::normalize( - Style::tag()->render(), - ), + Style::tag()->render(), 'Failed asserting that global defaults are applied correctly.', ); @@ -473,9 +463,9 @@ public function testRenderWithHidden(): void HTML, - LineEndingNormalizer::normalize( - Style::tag()->hidden(true)->render(), - ), + Style::tag() + ->hidden(true) + ->render(), "Failed asserting that element renders correctly with 'hidden' attribute.", ); } @@ -487,9 +477,9 @@ public function testRenderWithId(): void HTML, - LineEndingNormalizer::normalize( - Style::tag()->id('test-id')->render(), - ), + Style::tag() + ->id('test-id') + ->render(), "Failed asserting that element renders correctly with 'id' attribute.", ); } @@ -501,9 +491,9 @@ public function testRenderWithLang(): void HTML, - LineEndingNormalizer::normalize( - Style::tag()->lang('es')->render(), - ), + Style::tag() + ->lang('es') + ->render(), "Failed asserting that element renders correctly with 'lang' attribute.", ); } @@ -515,9 +505,9 @@ public function testRenderWithLangUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - Style::tag()->lang(Language::SPANISH)->render(), - ), + Style::tag() + ->lang(Language::SPANISH) + ->render(), "Failed asserting that element renders correctly with 'lang' attribute using enum.", ); } @@ -529,9 +519,9 @@ public function testRenderWithMedia(): void HTML, - LineEndingNormalizer::normalize( - Style::tag()->media('screen')->render(), - ), + Style::tag() + ->media('screen') + ->render(), "Failed asserting that element renders correctly with 'media' attribute.", ); } @@ -543,15 +533,13 @@ public function testRenderWithMicroData(): void HTML, - LineEndingNormalizer::normalize( - Style::tag() - ->itemId('https://example.com/item') - ->itemProp('name') - ->itemRef('info') - ->itemScope(true) - ->itemType('https://schema.org/Thing') - ->render(), - ), + Style::tag() + ->itemId('https://example.com/item') + ->itemProp('name') + ->itemRef('info') + ->itemScope(true) + ->itemType('https://schema.org/Thing') + ->render(), 'Failed asserting that element renders correctly with microdata attributes.', ); } @@ -563,9 +551,9 @@ public function testRenderWithNonce(): void HTML, - LineEndingNormalizer::normalize( - Style::tag()->nonce('nonce-value')->render(), - ), + Style::tag() + ->nonce('nonce-value') + ->render(), "Failed asserting that element renders correctly with 'nonce' attribute.", ); } @@ -577,12 +565,10 @@ public function testRenderWithRemoveAriaAttribute(): void HTML, - LineEndingNormalizer::normalize( - Style::tag() - ->addAriaAttribute('label', 'Close') - ->removeAriaAttribute('label') - ->render(), - ), + Style::tag() + ->addAriaAttribute('label', 'Close') + ->removeAriaAttribute('label') + ->render(), "Failed asserting that element renders correctly with 'removeAriaAttribute()' method.", ); } @@ -594,12 +580,10 @@ public function testRenderWithRemoveAttribute(): void HTML, - LineEndingNormalizer::normalize( - Style::tag() - ->addAttribute('data-test', 'value') - ->removeAttribute('data-test') - ->render(), - ), + Style::tag() + ->addAttribute('data-test', 'value') + ->removeAttribute('data-test') + ->render(), "Failed asserting that element renders correctly with 'removeAttribute()' method.", ); } @@ -611,12 +595,10 @@ public function testRenderWithRemoveDataAttribute(): void HTML, - LineEndingNormalizer::normalize( - Style::tag() - ->addDataAttribute('value', 'test') - ->removeDataAttribute('value') - ->render(), - ), + Style::tag() + ->addDataAttribute('value', 'test') + ->removeDataAttribute('value') + ->render(), "Failed asserting that element renders correctly with 'removeDataAttribute()' method.", ); } @@ -628,9 +610,9 @@ public function testRenderWithRole(): void HTML, - LineEndingNormalizer::normalize( - Style::tag()->role('banner')->render(), - ), + Style::tag() + ->role('banner') + ->render(), "Failed asserting that element renders correctly with 'role' attribute.", ); } @@ -642,9 +624,9 @@ public function testRenderWithRoleUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - Style::tag()->role(Role::BANNER)->render(), - ), + Style::tag() + ->role(Role::BANNER) + ->render(), "Failed asserting that element renders correctly with 'role' attribute using enum.", ); } @@ -656,9 +638,9 @@ public function testRenderWithSpellcheck(): void HTML, - LineEndingNormalizer::normalize( - Style::tag()->spellcheck(true)->render(), - ), + Style::tag() + ->spellcheck(true) + ->render(), "Failed asserting that element renders correctly with 'spellcheck' attribute.", ); } @@ -670,9 +652,9 @@ public function testRenderWithStyle(): void HTML, - LineEndingNormalizer::normalize( - Style::tag()->style('value')->render(), - ), + Style::tag() + ->style('value') + ->render(), "Failed asserting that element renders correctly with 'style' attribute.", ); } @@ -684,9 +666,9 @@ public function testRenderWithTabindex(): void HTML, - LineEndingNormalizer::normalize( - Style::tag()->tabIndex(3)->render(), - ), + Style::tag() + ->tabIndex(3) + ->render(), "Failed asserting that element renders correctly with 'tabindex' attribute.", ); } @@ -698,9 +680,9 @@ public function testRenderWithThemeProvider(): void HTML, - LineEndingNormalizer::normalize( - Style::tag()->addThemeProvider('muted', DefaultThemeProvider::class)->render(), - ), + Style::tag() + ->addThemeProvider('muted', DefaultThemeProvider::class) + ->render(), "Failed asserting that element renders correctly with 'addThemeProvider()' method.", ); } @@ -712,9 +694,9 @@ public function testRenderWithTitle(): void HTML, - LineEndingNormalizer::normalize( - Style::tag()->title('value')->render(), - ), + Style::tag() + ->title('value') + ->render(), "Failed asserting that element renders correctly with 'title' attribute.", ); } @@ -726,9 +708,7 @@ public function testRenderWithToString(): void HTML, - LineEndingNormalizer::normalize( - (string) Style::tag(), - ), + (string) Style::tag(), "Failed asserting that '__toString()' method renders correctly.", ); } @@ -740,9 +720,9 @@ public function testRenderWithTranslate(): void HTML, - LineEndingNormalizer::normalize( - Style::tag()->translate(false)->render(), - ), + Style::tag() + ->translate(false) + ->render(), "Failed asserting that element renders correctly with 'translate' attribute.", ); } @@ -754,9 +734,9 @@ public function testRenderWithTranslateUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - Style::tag()->translate(Translate::NO)->render(), - ), + Style::tag() + ->translate(Translate::NO) + ->render(), "Failed asserting that element renders correctly with 'translate' attribute using enum.", ); } @@ -768,9 +748,9 @@ public function testRenderWithType(): void HTML, - LineEndingNormalizer::normalize( - Style::tag()->type('text/css')->render(), - ), + Style::tag() + ->type('text/css') + ->render(), "Failed asserting that element renders correctly with 'type' attribute.", ); } @@ -784,9 +764,7 @@ public function testRenderWithUserOverridesGlobalDefaults(): void HTML, - LineEndingNormalizer::normalize( - Style::tag(['id' => 'id-user'])->render(), - ), + Style::tag(['id' => 'id-user'])->render(), 'Failed asserting that user-defined attributes override global defaults correctly.', ); diff --git a/tests/Metadata/TemplateTest.php b/tests/Metadata/TemplateTest.php index 87f97d3..407df0c 100644 --- a/tests/Metadata/TemplateTest.php +++ b/tests/Metadata/TemplateTest.php @@ -5,7 +5,6 @@ namespace UIAwesome\Html\Tests\Metadata; use InvalidArgumentException; -use PHPForge\Support\LineEndingNormalizer; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use UIAwesome\Html\Attribute\Values\{ @@ -41,17 +40,16 @@ * @copyright Copyright (C) 2026 Terabytesoftw. * @license https://opensource.org/license/bsd-3-clause BSD 3-Clause License. */ -#[Group('html')] #[Group('metadata')] final class TemplateTest extends TestCase { public function testContentEncodesValues(): void { - $template = Template::tag()->content(''); - self::assertSame( '<value>', - $template->getContent(), + Template::tag() + ->content('') + ->getContent(), "Failed asserting that 'content()' method encodes values correctly.", ); } @@ -69,7 +67,9 @@ public function testGetAttributesReturnsAssignedAttributes(): void { self::assertSame( ['data-test' => 'value'], - Template::tag()->addAttribute('data-test', 'value')->getAttributes(), + Template::tag() + ->addAttribute('data-test', 'value') + ->getAttributes(), "Failed asserting that 'getAttributes()' returns the assigned attributes.", ); } @@ -82,9 +82,9 @@ public function testHtmlDoesNotEncodeValues(): void HTML, - LineEndingNormalizer::normalize( - Template::tag()->html('')->render(), - ), + Template::tag() + ->html('') + ->render(), "Failed asserting that element renders correctly with 'html()' method.", ); } @@ -96,9 +96,9 @@ public function testRenderWithAccesskey(): void HTML, - LineEndingNormalizer::normalize( - Template::tag()->accesskey('k')->render(), - ), + Template::tag() + ->accesskey('k') + ->render(), "Failed asserting that element renders correctly with 'accesskey' attribute.", ); } @@ -110,9 +110,9 @@ public function testRenderWithAddAriaAttribute(): void HTML, - LineEndingNormalizer::normalize( - Template::tag()->addAriaAttribute('pressed', true)->render(), - ), + Template::tag() + ->addAriaAttribute('pressed', true) + ->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method.", ); } @@ -124,9 +124,9 @@ public function testRenderWithAddAriaAttributeUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - Template::tag()->addAriaAttribute(Aria::PRESSED, true)->render(), - ), + Template::tag() + ->addAriaAttribute(Aria::PRESSED, true) + ->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method.", ); } @@ -138,9 +138,9 @@ public function testRenderWithAddAttribute(): void HTML, - LineEndingNormalizer::normalize( - Template::tag()->addAttribute('data-test', 'value')->render(), - ), + Template::tag() + ->addAttribute('data-test', 'value') + ->render(), "Failed asserting that element renders correctly with 'addAttribute()' method.", ); } @@ -152,9 +152,9 @@ public function testRenderWithAddAttributeUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - Template::tag()->addAttribute(GlobalAttribute::TITLE, 'value')->render(), - ), + Template::tag() + ->addAttribute(GlobalAttribute::TITLE, 'value') + ->render(), "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", ); } @@ -166,9 +166,9 @@ public function testRenderWithAddDataAttribute(): void HTML, - LineEndingNormalizer::normalize( - Template::tag()->addDataAttribute('value', 'value')->render(), - ), + Template::tag() + ->addDataAttribute('value', 'value') + ->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method.", ); } @@ -180,9 +180,9 @@ public function testRenderWithAddDataAttributeUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - Template::tag()->addDataAttribute(Data::VALUE, 'value')->render(), - ), + Template::tag() + ->addDataAttribute(Data::VALUE, 'value') + ->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method.", ); } @@ -194,17 +194,15 @@ public function testRenderWithAriaAttributes(): void HTML, - LineEndingNormalizer::normalize( - Template::tag() - ->ariaAttributes( - [ - 'controls' => static fn(): string => 'modal-1', - 'hidden' => false, - 'label' => 'Close', - ], - ) + Template::tag() + ->ariaAttributes( + [ + 'controls' => static fn(): string => 'modal-1', + 'hidden' => false, + 'label' => 'Close', + ], + ) ->render(), - ), "Failed asserting that element renders correctly with 'ariaAttributes()' method.", ); } @@ -216,9 +214,9 @@ public function testRenderWithAttributes(): void HTML, - LineEndingNormalizer::normalize( - Template::tag()->attributes(['class' => 'value'])->render(), - ), + Template::tag() + ->attributes(['class' => 'value']) + ->render(), "Failed asserting that element renders correctly with 'attributes()' method.", ); } @@ -230,9 +228,9 @@ public function testRenderWithAutofocus(): void HTML, - LineEndingNormalizer::normalize( - Template::tag()->autofocus(true)->render(), - ), + Template::tag() + ->autofocus(true) + ->render(), "Failed asserting that element renders correctly with 'autofocus' attribute.", ); } @@ -245,9 +243,7 @@ public function testRenderWithBeginEnd(): void Content HTML, - LineEndingNormalizer::normalize( - Template::tag()->begin() . 'Content' . Template::end(), - ), + Template::tag()->begin() . 'Content' . Template::end(), "Failed asserting that element renders correctly with 'begin()' and 'end()' methods.", ); } @@ -259,9 +255,9 @@ public function testRenderWithClass(): void HTML, - LineEndingNormalizer::normalize( - Template::tag()->class('value')->render(), - ), + Template::tag() + ->class('value') + ->render(), "Failed asserting that element renders correctly with 'class' attribute.", ); } @@ -274,9 +270,9 @@ public function testRenderWithContent(): void value HTML, - LineEndingNormalizer::normalize( - Template::tag()->content('value')->render(), - ), + Template::tag() + ->content('value') + ->render(), 'Failed asserting that element renders correctly with default values.', ); } @@ -288,9 +284,9 @@ public function testRenderWithContentEditable(): void HTML, - LineEndingNormalizer::normalize( - Template::tag()->contentEditable(true)->render(), - ), + Template::tag() + ->contentEditable(true) + ->render(), "Failed asserting that element renders correctly with 'contentEditable' attribute.", ); } @@ -302,9 +298,9 @@ public function testRenderWithContentEditableUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - Template::tag()->contentEditable(ContentEditable::TRUE)->render(), - ), + Template::tag() + ->contentEditable(ContentEditable::TRUE) + ->render(), "Failed asserting that element renders correctly with 'contentEditable' attribute using enum.", ); } @@ -316,9 +312,9 @@ public function testRenderWithDataAttributes(): void HTML, - LineEndingNormalizer::normalize( - Template::tag()->dataAttributes(['value' => 'value'])->render(), - ), + Template::tag() + ->dataAttributes(['value' => 'value']) + ->render(), "Failed asserting that element renders correctly with 'dataAttributes()' method.", ); } @@ -330,9 +326,7 @@ public function testRenderWithDefaultConfigurationValues(): void HTML, - LineEndingNormalizer::normalize( - Template::tag(['class' => 'default-class'])->render(), - ), + Template::tag(['class' => 'default-class'])->render(), 'Failed asserting that default configuration values are applied correctly.', ); } @@ -344,9 +338,9 @@ public function testRenderWithDefaultProvider(): void HTML, - LineEndingNormalizer::normalize( - Template::tag()->addDefaultProvider(DefaultProvider::class)->render(), - ), + Template::tag() + ->addDefaultProvider(DefaultProvider::class) + ->render(), 'Failed asserting that default provider is applied correctly.', ); } @@ -358,9 +352,7 @@ public function testRenderWithDefaultValues(): void HTML, - LineEndingNormalizer::normalize( - Template::tag()->render(), - ), + Template::tag()->render(), 'Failed asserting that element renders correctly with default values.', ); } @@ -372,9 +364,9 @@ public function testRenderWithDir(): void HTML, - LineEndingNormalizer::normalize( - Template::tag()->dir('ltr')->render(), - ), + Template::tag() + ->dir('ltr') + ->render(), "Failed asserting that element renders correctly with 'dir' attribute.", ); } @@ -386,9 +378,9 @@ public function testRenderWithDirUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - Template::tag()->dir(Direction::LTR)->render(), - ), + Template::tag() + ->dir(Direction::LTR) + ->render(), "Failed asserting that element renders correctly with 'dir' attribute using enum.", ); } @@ -400,9 +392,9 @@ public function testRenderWithDraggable(): void HTML, - LineEndingNormalizer::normalize( - Template::tag()->draggable(true)->render(), - ), + Template::tag() + ->draggable(true) + ->render(), "Failed asserting that element renders correctly with 'draggable' attribute.", ); } @@ -414,9 +406,9 @@ public function testRenderWithDraggableUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - Template::tag()->draggable(Draggable::TRUE)->render(), - ), + Template::tag() + ->draggable(Draggable::TRUE) + ->render(), "Failed asserting that element renders correctly with 'draggable' attribute using enum.", ); } @@ -430,9 +422,7 @@ public function testRenderWithGlobalDefaultsAreApplied(): void HTML, - LineEndingNormalizer::normalize( - Template::tag()->render(), - ), + Template::tag()->render(), 'Failed asserting that global defaults are applied correctly.', ); @@ -446,9 +436,9 @@ public function testRenderWithHidden(): void HTML, - LineEndingNormalizer::normalize( - Template::tag()->hidden(true)->render(), - ), + Template::tag() + ->hidden(true) + ->render(), "Failed asserting that element renders correctly with 'hidden' attribute.", ); } @@ -460,9 +450,9 @@ public function testRenderWithId(): void HTML, - LineEndingNormalizer::normalize( - Template::tag()->id('test-id')->render(), - ), + Template::tag() + ->id('test-id') + ->render(), "Failed asserting that element renders correctly with 'id' attribute.", ); } @@ -474,9 +464,9 @@ public function testRenderWithLang(): void HTML, - LineEndingNormalizer::normalize( - Template::tag()->lang('es')->render(), - ), + Template::tag() + ->lang('es') + ->render(), "Failed asserting that element renders correctly with 'lang' attribute.", ); } @@ -488,9 +478,9 @@ public function testRenderWithLangUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - Template::tag()->lang(Language::SPANISH)->render(), - ), + Template::tag() + ->lang(Language::SPANISH) + ->render(), "Failed asserting that element renders correctly with 'lang' attribute using enum.", ); } @@ -502,15 +492,13 @@ public function testRenderWithMicroData(): void HTML, - LineEndingNormalizer::normalize( - Template::tag() - ->itemId('https://example.com/item') - ->itemProp('name') - ->itemRef('info') - ->itemScope(true) - ->itemType('https://schema.org/Thing') - ->render(), - ), + Template::tag() + ->itemId('https://example.com/item') + ->itemProp('name') + ->itemRef('info') + ->itemScope(true) + ->itemType('https://schema.org/Thing') + ->render(), 'Failed asserting that element renders correctly with microdata attributes.', ); } @@ -522,12 +510,10 @@ public function testRenderWithRemoveAriaAttribute(): void HTML, - LineEndingNormalizer::normalize( - Template::tag() - ->addAriaAttribute('label', 'Close') - ->removeAriaAttribute('label') - ->render(), - ), + Template::tag() + ->addAriaAttribute('label', 'Close') + ->removeAriaAttribute('label') + ->render(), "Failed asserting that element renders correctly with 'removeAriaAttribute()' method.", ); } @@ -539,12 +525,10 @@ public function testRenderWithRemoveAttribute(): void HTML, - LineEndingNormalizer::normalize( - Template::tag() - ->addAttribute('data-test', 'value') - ->removeAttribute('data-test') - ->render(), - ), + Template::tag() + ->addAttribute('data-test', 'value') + ->removeAttribute('data-test') + ->render(), "Failed asserting that element renders correctly with 'removeAttribute()' method.", ); } @@ -556,12 +540,10 @@ public function testRenderWithRemoveDataAttribute(): void HTML, - LineEndingNormalizer::normalize( - Template::tag() - ->addDataAttribute('value', 'test') - ->removeDataAttribute('value') - ->render(), - ), + Template::tag() + ->addDataAttribute('value', 'test') + ->removeDataAttribute('value') + ->render(), "Failed asserting that element renders correctly with 'removeDataAttribute()' method.", ); } @@ -573,9 +555,9 @@ public function testRenderWithRole(): void HTML, - LineEndingNormalizer::normalize( - Template::tag()->role('banner')->render(), - ), + Template::tag() + ->role('banner') + ->render(), "Failed asserting that element renders correctly with 'role' attribute.", ); } @@ -587,9 +569,9 @@ public function testRenderWithRoleUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - Template::tag()->role(Role::BANNER)->render(), - ), + Template::tag() + ->role(Role::BANNER) + ->render(), "Failed asserting that element renders correctly with 'role' attribute using enum.", ); } @@ -601,9 +583,9 @@ public function testRenderWithShadowRootClonable(): void HTML, - LineEndingNormalizer::normalize( - Template::tag()->shadowRootClonable(true)->render(), - ), + Template::tag() + ->shadowRootClonable(true) + ->render(), "Failed asserting that element renders correctly with 'shadowrootclonable' attribute.", ); } @@ -615,9 +597,9 @@ public function testRenderWithShadowRootDelegatesFocus(): void HTML, - LineEndingNormalizer::normalize( - Template::tag()->shadowRootDelegatesFocus(true)->render(), - ), + Template::tag() + ->shadowRootDelegatesFocus(true) + ->render(), "Failed asserting that element renders correctly with 'shadowrootdelegatesfocus' attribute.", ); } @@ -629,9 +611,9 @@ public function testRenderWithShadowRootMode(): void HTML, - LineEndingNormalizer::normalize( - Template::tag()->shadowRootMode('open')->render(), - ), + Template::tag() + ->shadowRootMode('open') + ->render(), "Failed asserting that element renders correctly with 'shadowrootmode' attribute.", ); } @@ -643,9 +625,9 @@ public function testRenderWithShadowRootModeUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - Template::tag()->shadowRootMode(ShadowRootMode::OPEN)->render(), - ), + Template::tag() + ->shadowRootMode(ShadowRootMode::OPEN) + ->render(), "Failed asserting that element renders correctly with 'shadowrootmode' attribute using enum.", ); } @@ -657,9 +639,9 @@ public function testRenderWithShadowRootReferenceTarget(): void HTML, - LineEndingNormalizer::normalize( - Template::tag()->shadowRootReferenceTarget('target')->render(), - ), + Template::tag() + ->shadowRootReferenceTarget('target') + ->render(), "Failed asserting that element renders correctly with 'shadowrootreferencetarget' attribute.", ); } @@ -671,9 +653,9 @@ public function testRenderWithShadowRootSerializable(): void HTML, - LineEndingNormalizer::normalize( - Template::tag()->shadowRootSerializable(true)->render(), - ), + Template::tag() + ->shadowRootSerializable(true) + ->render(), "Failed asserting that element renders correctly with 'shadowrootserializable' attribute.", ); } @@ -685,9 +667,9 @@ public function testRenderWithSpellcheck(): void HTML, - LineEndingNormalizer::normalize( - Template::tag()->spellcheck(true)->render(), - ), + Template::tag() + ->spellcheck(true) + ->render(), "Failed asserting that element renders correctly with 'spellcheck' attribute.", ); } @@ -699,9 +681,9 @@ public function testRenderWithStyle(): void HTML, - LineEndingNormalizer::normalize( - Template::tag()->style('value')->render(), - ), + Template::tag() + ->style('value') + ->render(), "Failed asserting that element renders correctly with 'style' attribute.", ); } @@ -713,9 +695,9 @@ public function testRenderWithTabindex(): void HTML, - LineEndingNormalizer::normalize( - Template::tag()->tabIndex(3)->render(), - ), + Template::tag() + ->tabIndex(3) + ->render(), "Failed asserting that element renders correctly with 'tabindex' attribute.", ); } @@ -727,9 +709,9 @@ public function testRenderWithThemeProvider(): void HTML, - LineEndingNormalizer::normalize( - Template::tag()->addThemeProvider('muted', DefaultThemeProvider::class)->render(), - ), + Template::tag() + ->addThemeProvider('muted', DefaultThemeProvider::class) + ->render(), "Failed asserting that element renders correctly with 'addThemeProvider()' method.", ); } @@ -741,9 +723,9 @@ public function testRenderWithTitle(): void HTML, - LineEndingNormalizer::normalize( - Template::tag()->title('value')->render(), - ), + Template::tag() + ->title('value') + ->render(), "Failed asserting that element renders correctly with 'title' attribute.", ); } @@ -755,9 +737,7 @@ public function testRenderWithToString(): void HTML, - LineEndingNormalizer::normalize( - (string) Template::tag(), - ), + (string) Template::tag(), "Failed asserting that '__toString()' method renders correctly.", ); } @@ -769,9 +749,9 @@ public function testRenderWithTranslate(): void HTML, - LineEndingNormalizer::normalize( - Template::tag()->translate(false)->render(), - ), + Template::tag() + ->translate(false) + ->render(), "Failed asserting that element renders correctly with 'translate' attribute.", ); } @@ -783,9 +763,9 @@ public function testRenderWithTranslateUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - Template::tag()->translate(Translate::NO)->render(), - ), + Template::tag() + ->translate(Translate::NO) + ->render(), "Failed asserting that element renders correctly with 'translate' attribute using enum.", ); } @@ -799,9 +779,7 @@ public function testRenderWithUserOverridesGlobalDefaults(): void HTML, - LineEndingNormalizer::normalize( - Template::tag(['id' => 'id-user'])->render(), - ), + Template::tag(['id' => 'id-user'])->render(), 'Failed asserting that user-defined attributes override global defaults correctly.', ); diff --git a/tests/Metadata/TitleTest.php b/tests/Metadata/TitleTest.php index 30c2937..8cd6670 100644 --- a/tests/Metadata/TitleTest.php +++ b/tests/Metadata/TitleTest.php @@ -4,7 +4,6 @@ namespace UIAwesome\Html\Tests\Metadata; -use PHPForge\Support\LineEndingNormalizer; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use UIAwesome\Html\Attribute\Values\{ @@ -34,17 +33,16 @@ * @copyright Copyright (C) 2026 Terabytesoftw. * @license https://opensource.org/license/bsd-3-clause BSD 3-Clause License. */ -#[Group('html')] #[Group('metadata')] final class TitleTest extends TestCase { public function testContentEncodesValues(): void { - $title = Title::tag()->content(''); - self::assertSame( '<value>', - $title->getContent(), + Title::tag() + ->content('') + ->getContent(), "Failed asserting that 'content()' method encodes values correctly.", ); } @@ -62,7 +60,9 @@ public function testGetAttributesReturnsAssignedAttributes(): void { self::assertSame( ['data-test' => 'value'], - Title::tag()->addAttribute('data-test', 'value')->getAttributes(), + Title::tag() + ->addAttribute('data-test', 'value') + ->getAttributes(), "Failed asserting that 'getAttributes()' returns the assigned attributes.", ); } @@ -75,9 +75,9 @@ public function testHtmlDoesNotEncodeValues(): void HTML, - LineEndingNormalizer::normalize( - Title::tag()->html('')->render(), - ), + Title::tag() + ->html('') + ->render(), "Failed asserting that element renders correctly with 'html()' method.", ); } @@ -89,9 +89,9 @@ public function testRenderWithAccesskey(): void HTML, - LineEndingNormalizer::normalize( - Title::tag()->accesskey('k')->render(), - ), + Title::tag() + ->accesskey('k') + ->render(), "Failed asserting that element renders correctly with 'accesskey' attribute.", ); } @@ -103,9 +103,9 @@ public function testRenderWithAddAriaAttribute(): void HTML, - LineEndingNormalizer::normalize( - Title::tag()->addAriaAttribute('pressed', true)->render(), - ), + Title::tag() + ->addAriaAttribute('pressed', true) + ->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method.", ); } @@ -117,9 +117,9 @@ public function testRenderWithAddAriaAttributeUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - Title::tag()->addAriaAttribute(Aria::PRESSED, true)->render(), - ), + Title::tag() + ->addAriaAttribute(Aria::PRESSED, true) + ->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method.", ); } @@ -131,9 +131,9 @@ public function testRenderWithAddAttribute(): void HTML, - LineEndingNormalizer::normalize( - Title::tag()->addAttribute('data-test', 'value')->render(), - ), + Title::tag() + ->addAttribute('data-test', 'value') + ->render(), "Failed asserting that element renders correctly with 'addAttribute()' method.", ); } @@ -145,9 +145,9 @@ public function testRenderWithAddAttributeUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - Title::tag()->addAttribute(GlobalAttribute::TITLE, 'value')->render(), - ), + Title::tag() + ->addAttribute(GlobalAttribute::TITLE, 'value') + ->render(), "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", ); } @@ -159,9 +159,9 @@ public function testRenderWithAddDataAttribute(): void HTML, - LineEndingNormalizer::normalize( - Title::tag()->addDataAttribute('value', 'value')->render(), - ), + Title::tag() + ->addDataAttribute('value', 'value') + ->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method.", ); } @@ -173,9 +173,9 @@ public function testRenderWithAddDataAttributeUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - Title::tag()->addDataAttribute(Data::VALUE, 'value')->render(), - ), + Title::tag() + ->addDataAttribute(Data::VALUE, 'value') + ->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method.", ); } @@ -187,17 +187,15 @@ public function testRenderWithAriaAttributes(): void HTML, - LineEndingNormalizer::normalize( - Title::tag() - ->ariaAttributes( - [ - 'controls' => static fn(): string => 'modal-1', - 'hidden' => false, - 'label' => 'Close', - ], - ) - ->render(), - ), + Title::tag() + ->ariaAttributes( + [ + 'controls' => static fn(): string => 'modal-1', + 'hidden' => false, + 'label' => 'Close', + ], + ) + ->render(), "Failed asserting that element renders correctly with 'ariaAttributes()' method.", ); } @@ -209,9 +207,9 @@ public function testRenderWithAttributes(): void HTML, - LineEndingNormalizer::normalize( - Title::tag()->attributes(['class' => 'value'])->render(), - ), + Title::tag() + ->attributes(['class' => 'value']) + ->render(), "Failed asserting that element renders correctly with 'attributes()' method.", ); } @@ -223,9 +221,9 @@ public function testRenderWithAutofocus(): void HTML, - LineEndingNormalizer::normalize( - Title::tag()->autofocus(true)->render(), - ), + Title::tag() + ->autofocus(true) + ->render(), "Failed asserting that element renders correctly with 'autofocus' attribute.", ); } @@ -238,9 +236,7 @@ public function testRenderWithBeginEnd(): void Content HTML, - LineEndingNormalizer::normalize( - Title::tag()->begin() . 'Content' . Title::end(), - ), + Title::tag()->begin() . 'Content' . Title::end(), "Failed asserting that element renders correctly with 'begin()' and 'end()' methods.", ); } @@ -252,9 +248,9 @@ public function testRenderWithClass(): void HTML, - LineEndingNormalizer::normalize( - Title::tag()->class('value')->render(), - ), + Title::tag() + ->class('value') + ->render(), "Failed asserting that element renders correctly with 'class' attribute.", ); } @@ -267,9 +263,9 @@ public function testRenderWithContent(): void value HTML, - LineEndingNormalizer::normalize( - Title::tag()->content('value')->render(), - ), + Title::tag() + ->content('value') + ->render(), 'Failed asserting that element renders correctly with default values.', ); } @@ -281,9 +277,9 @@ public function testRenderWithContentEditable(): void HTML, - LineEndingNormalizer::normalize( - Title::tag()->contentEditable(true)->render(), - ), + Title::tag() + ->contentEditable(true) + ->render(), "Failed asserting that element renders correctly with 'contentEditable' attribute.", ); } @@ -295,9 +291,9 @@ public function testRenderWithContentEditableUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - Title::tag()->contentEditable(ContentEditable::TRUE)->render(), - ), + Title::tag() + ->contentEditable(ContentEditable::TRUE) + ->render(), "Failed asserting that element renders correctly with 'contentEditable' attribute using enum.", ); } @@ -309,9 +305,9 @@ public function testRenderWithDataAttributes(): void HTML, - LineEndingNormalizer::normalize( - Title::tag()->dataAttributes(['value' => 'value'])->render(), - ), + Title::tag() + ->dataAttributes(['value' => 'value']) + ->render(), "Failed asserting that element renders correctly with 'dataAttributes()' method.", ); } @@ -323,9 +319,7 @@ public function testRenderWithDefaultConfigurationValues(): void HTML, - LineEndingNormalizer::normalize( - Title::tag(['class' => 'default-class'])->render(), - ), + Title::tag(['class' => 'default-class'])->render(), 'Failed asserting that default configuration values are applied correctly.', ); } @@ -337,9 +331,9 @@ public function testRenderWithDefaultProvider(): void HTML, - LineEndingNormalizer::normalize( - Title::tag()->addDefaultProvider(DefaultProvider::class)->render(), - ), + Title::tag() + ->addDefaultProvider(DefaultProvider::class) + ->render(), 'Failed asserting that default provider is applied correctly.', ); } @@ -351,9 +345,7 @@ public function testRenderWithDefaultValues(): void HTML, - LineEndingNormalizer::normalize( - Title::tag()->render(), - ), + Title::tag()->render(), 'Failed asserting that element renders correctly with default values.', ); } @@ -365,9 +357,9 @@ public function testRenderWithDir(): void HTML, - LineEndingNormalizer::normalize( - Title::tag()->dir('ltr')->render(), - ), + Title::tag() + ->dir('ltr') + ->render(), "Failed asserting that element renders correctly with 'dir' attribute.", ); } @@ -379,9 +371,9 @@ public function testRenderWithDirUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - Title::tag()->dir(Direction::LTR)->render(), - ), + Title::tag() + ->dir(Direction::LTR) + ->render(), "Failed asserting that element renders correctly with 'dir' attribute using enum.", ); } @@ -393,9 +385,9 @@ public function testRenderWithDraggable(): void HTML, - LineEndingNormalizer::normalize( - Title::tag()->draggable(true)->render(), - ), + Title::tag() + ->draggable(true) + ->render(), "Failed asserting that element renders correctly with 'draggable' attribute.", ); } @@ -407,9 +399,9 @@ public function testRenderWithDraggableUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - Title::tag()->draggable(Draggable::TRUE)->render(), - ), + Title::tag() + ->draggable(Draggable::TRUE) + ->render(), "Failed asserting that element renders correctly with 'draggable' attribute using enum.", ); } @@ -423,9 +415,7 @@ public function testRenderWithGlobalDefaultsAreApplied(): void HTML, - LineEndingNormalizer::normalize( - Title::tag()->render(), - ), + Title::tag()->render(), 'Failed asserting that global defaults are applied correctly.', ); @@ -439,9 +429,9 @@ public function testRenderWithHidden(): void HTML, - LineEndingNormalizer::normalize( - Title::tag()->hidden(true)->render(), - ), + Title::tag() + ->hidden(true) + ->render(), "Failed asserting that element renders correctly with 'hidden' attribute.", ); } @@ -453,9 +443,9 @@ public function testRenderWithId(): void HTML, - LineEndingNormalizer::normalize( - Title::tag()->id('test-id')->render(), - ), + Title::tag() + ->id('test-id') + ->render(), "Failed asserting that element renders correctly with 'id' attribute.", ); } @@ -467,9 +457,9 @@ public function testRenderWithLang(): void HTML, - LineEndingNormalizer::normalize( - Title::tag()->lang('es')->render(), - ), + Title::tag() + ->lang('es') + ->render(), "Failed asserting that element renders correctly with 'lang' attribute.", ); } @@ -481,9 +471,9 @@ public function testRenderWithLangUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - Title::tag()->lang(Language::SPANISH)->render(), - ), + Title::tag() + ->lang(Language::SPANISH) + ->render(), "Failed asserting that element renders correctly with 'lang' attribute using enum.", ); } @@ -495,15 +485,13 @@ public function testRenderWithMicroData(): void HTML, - LineEndingNormalizer::normalize( - Title::tag() - ->itemId('https://example.com/item') - ->itemProp('name') - ->itemRef('info') - ->itemScope(true) - ->itemType('https://schema.org/Thing') - ->render(), - ), + Title::tag() + ->itemId('https://example.com/item') + ->itemProp('name') + ->itemRef('info') + ->itemScope(true) + ->itemType('https://schema.org/Thing') + ->render(), 'Failed asserting that element renders correctly with microdata attributes.', ); } @@ -515,12 +503,10 @@ public function testRenderWithRemoveAriaAttribute(): void HTML, - LineEndingNormalizer::normalize( - Title::tag() - ->addAriaAttribute('label', 'Close') - ->removeAriaAttribute('label') - ->render(), - ), + Title::tag() + ->addAriaAttribute('label', 'Close') + ->removeAriaAttribute('label') + ->render(), "Failed asserting that element renders correctly with 'removeAriaAttribute()' method.", ); } @@ -532,12 +518,10 @@ public function testRenderWithRemoveAttribute(): void HTML, - LineEndingNormalizer::normalize( - Title::tag() - ->addAttribute('data-test', 'value') - ->removeAttribute('data-test') - ->render(), - ), + Title::tag() + ->addAttribute('data-test', 'value') + ->removeAttribute('data-test') + ->render(), "Failed asserting that element renders correctly with 'removeAttribute()' method.", ); } @@ -549,12 +533,10 @@ public function testRenderWithRemoveDataAttribute(): void HTML, - LineEndingNormalizer::normalize( - Title::tag() - ->addDataAttribute('value', 'test') - ->removeDataAttribute('value') - ->render(), - ), + Title::tag() + ->addDataAttribute('value', 'test') + ->removeDataAttribute('value') + ->render(), "Failed asserting that element renders correctly with 'removeDataAttribute()' method.", ); } @@ -566,9 +548,9 @@ public function testRenderWithRole(): void HTML, - LineEndingNormalizer::normalize( - Title::tag()->role('banner')->render(), - ), + Title::tag() + ->role('banner') + ->render(), "Failed asserting that element renders correctly with 'role' attribute.", ); } @@ -580,9 +562,9 @@ public function testRenderWithRoleUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - Title::tag()->role(Role::BANNER)->render(), - ), + Title::tag() + ->role(Role::BANNER) + ->render(), "Failed asserting that element renders correctly with 'role' attribute using enum.", ); } @@ -594,9 +576,9 @@ public function testRenderWithSpellcheck(): void HTML, - LineEndingNormalizer::normalize( - Title::tag()->spellcheck(true)->render(), - ), + Title::tag() + ->spellcheck(true) + ->render(), "Failed asserting that element renders correctly with 'spellcheck' attribute.", ); } @@ -608,9 +590,9 @@ public function testRenderWithStyle(): void HTML, - LineEndingNormalizer::normalize( - Title::tag()->style('value')->render(), - ), + Title::tag() + ->style('value') + ->render(), "Failed asserting that element renders correctly with 'style' attribute.", ); } @@ -622,9 +604,9 @@ public function testRenderWithTabindex(): void HTML, - LineEndingNormalizer::normalize( - Title::tag()->tabIndex(3)->render(), - ), + Title::tag() + ->tabIndex(3) + ->render(), "Failed asserting that element renders correctly with 'tabindex' attribute.", ); } @@ -636,9 +618,9 @@ public function testRenderWithThemeProvider(): void HTML, - LineEndingNormalizer::normalize( - Title::tag()->addThemeProvider('muted', DefaultThemeProvider::class)->render(), - ), + Title::tag() + ->addThemeProvider('muted', DefaultThemeProvider::class) + ->render(), "Failed asserting that element renders correctly with 'addThemeProvider()' method.", ); } @@ -650,9 +632,9 @@ public function testRenderWithTitle(): void HTML, - LineEndingNormalizer::normalize( - Title::tag()->title('value')->render(), - ), + Title::tag() + ->title('value') + ->render(), "Failed asserting that element renders correctly with 'title' attribute.", ); } @@ -664,9 +646,7 @@ public function testRenderWithToString(): void HTML, - LineEndingNormalizer::normalize( - (string) Title::tag(), - ), + (string) Title::tag(), "Failed asserting that '__toString()' method renders correctly.", ); } @@ -678,9 +658,9 @@ public function testRenderWithTranslate(): void HTML, - LineEndingNormalizer::normalize( - Title::tag()->translate(false)->render(), - ), + Title::tag() + ->translate(false) + ->render(), "Failed asserting that element renders correctly with 'translate' attribute.", ); } @@ -692,9 +672,9 @@ public function testRenderWithTranslateUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - Title::tag()->translate(Translate::NO)->render(), - ), + Title::tag() + ->translate(Translate::NO) + ->render(), "Failed asserting that element renders correctly with 'translate' attribute using enum.", ); } @@ -708,9 +688,7 @@ public function testRenderWithUserOverridesGlobalDefaults(): void HTML, - LineEndingNormalizer::normalize( - Title::tag(['id' => 'id-user'])->render(), - ), + Title::tag(['id' => 'id-user'])->render(), 'Failed asserting that user-defined attributes override global defaults correctly.', ); diff --git a/tests/Palpable/ATest.php b/tests/Palpable/ATest.php index 944f413..855253c 100644 --- a/tests/Palpable/ATest.php +++ b/tests/Palpable/ATest.php @@ -4,7 +4,6 @@ namespace UIAwesome\Html\Tests\Palpable; -use PHPForge\Support\LineEndingNormalizer; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use UIAwesome\Html\Attribute\Values\{ @@ -40,17 +39,16 @@ * @copyright Copyright (C) 2026 Terabytesoftw. * @license https://opensource.org/license/bsd-3-clause BSD 3-Clause License. */ -#[Group('html')] #[Group('palpable')] final class ATest extends TestCase { public function testContentEncodesValues(): void { - $a = A::tag()->content(''); - self::assertSame( '<value>', - $a->getContent(), + A::tag() + ->content('') + ->getContent(), "Failed asserting that 'content()' method encodes values correctly.", ); } @@ -68,7 +66,9 @@ public function testGetAttributesReturnsAssignedAttributes(): void { self::assertSame( ['data-test' => 'value'], - A::tag()->addAttribute('data-test', 'value')->getAttributes(), + A::tag() + ->addAttribute('data-test', 'value') + ->getAttributes(), "Failed asserting that 'getAttributes()' returns the assigned attributes.", ); } @@ -79,9 +79,9 @@ public function testHtmlDoesNotEncodeValues(): void << HTML, - LineEndingNormalizer::normalize( - A::tag()->html('')->render(), - ), + A::tag() + ->html('') + ->render(), "Failed asserting that element renders correctly with 'html()' method.", ); } @@ -92,9 +92,9 @@ public function testRenderWithAccesskey(): void << HTML, - LineEndingNormalizer::normalize( - A::tag()->accesskey('k')->render(), - ), + A::tag() + ->accesskey('k') + ->render(), "Failed asserting that element renders correctly with 'accesskey' attribute.", ); } @@ -105,9 +105,9 @@ public function testRenderWithAddAriaAttribute(): void << HTML, - LineEndingNormalizer::normalize( - A::tag()->addAriaAttribute('label', 'Link content')->render(), - ), + A::tag() + ->addAriaAttribute('label', 'Link content') + ->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method.", ); } @@ -118,9 +118,9 @@ public function testRenderWithAddAriaAttributeUsingEnum(): void << HTML, - LineEndingNormalizer::normalize( - A::tag()->addAriaAttribute(Aria::HIDDEN, true)->render(), - ), + A::tag() + ->addAriaAttribute(Aria::HIDDEN, true) + ->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method using enum.", ); } @@ -131,9 +131,9 @@ public function testRenderWithAddAttribute(): void << HTML, - LineEndingNormalizer::normalize( - A::tag()->addAttribute('data-test', 'value')->render(), - ), + A::tag() + ->addAttribute('data-test', 'value') + ->render(), "Failed asserting that element renders correctly with 'addAttribute()' method.", ); } @@ -144,9 +144,9 @@ public function testRenderWithAddAttributeUsingEnum(): void << HTML, - LineEndingNormalizer::normalize( - A::tag()->addAttribute(GlobalAttribute::TITLE, 'Link content')->render(), - ), + A::tag() + ->addAttribute(GlobalAttribute::TITLE, 'Link content') + ->render(), "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", ); } @@ -157,9 +157,9 @@ public function testRenderWithAddDataAttribute(): void << HTML, - LineEndingNormalizer::normalize( - A::tag()->addDataAttribute('value', 'value')->render(), - ), + A::tag() + ->addDataAttribute('value', 'value') + ->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method.", ); } @@ -170,9 +170,9 @@ public function testRenderWithAddDataAttributeUsingEnum(): void << HTML, - LineEndingNormalizer::normalize( - A::tag()->addDataAttribute(Data::VALUE, 'value')->render(), - ), + A::tag() + ->addDataAttribute(Data::VALUE, 'value') + ->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method using enum.", ); } @@ -183,17 +183,15 @@ public function testRenderWithAriaAttributes(): void << HTML, - LineEndingNormalizer::normalize( - A::tag() - ->ariaAttributes( - [ - 'controls' => static fn(): string => 'modal-1', - 'hidden' => false, - 'label' => 'Close', - ], - ) - ->render(), - ), + A::tag() + ->ariaAttributes( + [ + 'controls' => static fn(): string => 'modal-1', + 'hidden' => false, + 'label' => 'Close', + ], + ) + ->render(), "Failed asserting that element renders correctly with 'ariaAttributes()' method.", ); } @@ -204,9 +202,9 @@ public function testRenderWithAttributes(): void << HTML, - LineEndingNormalizer::normalize( - A::tag()->attributes(['class' => 'value'])->render(), - ), + A::tag() + ->attributes(['class' => 'value']) + ->render(), "Failed asserting that element renders correctly with 'attributes()' method.", ); } @@ -217,9 +215,9 @@ public function testRenderWithClass(): void << HTML, - LineEndingNormalizer::normalize( - A::tag()->class('value')->render(), - ), + A::tag() + ->class('value') + ->render(), "Failed asserting that element renders correctly with 'class' attribute.", ); } @@ -230,9 +228,9 @@ public function testRenderWithContent(): void <<value HTML, - LineEndingNormalizer::normalize( - A::tag()->content('value')->render(), - ), + A::tag() + ->content('value') + ->render(), 'Failed asserting that element renders correctly with default values.', ); } @@ -243,9 +241,9 @@ public function testRenderWithDataAttributes(): void << HTML, - LineEndingNormalizer::normalize( - A::tag()->dataAttributes(['value' => 'value'])->render(), - ), + A::tag() + ->dataAttributes(['value' => 'value']) + ->render(), "Failed asserting that element renders correctly with 'dataAttributes()' method.", ); } @@ -256,9 +254,7 @@ public function testRenderWithDefaultConfigurationValues(): void << HTML, - LineEndingNormalizer::normalize( - A::tag(['class' => 'default-class'])->render(), - ), + A::tag(['class' => 'default-class'])->render(), 'Failed asserting that default configuration values are applied correctly.', ); } @@ -269,9 +265,9 @@ public function testRenderWithDefaultProvider(): void << HTML, - LineEndingNormalizer::normalize( - A::tag()->addDefaultProvider(DefaultProvider::class)->render(), - ), + A::tag() + ->addDefaultProvider(DefaultProvider::class) + ->render(), 'Failed asserting that default provider is applied correctly.', ); } @@ -282,9 +278,7 @@ public function testRenderWithDefaultValues(): void << HTML, - LineEndingNormalizer::normalize( - A::tag()->render(), - ), + A::tag()->render(), 'Failed asserting that element renders correctly with default values.', ); } @@ -295,9 +289,9 @@ public function testRenderWithDir(): void << HTML, - LineEndingNormalizer::normalize( - A::tag()->dir('ltr')->render(), - ), + A::tag() + ->dir('ltr') + ->render(), "Failed asserting that element renders correctly with 'dir' attribute.", ); } @@ -308,24 +302,22 @@ public function testRenderWithDirUsingEnum(): void << HTML, - LineEndingNormalizer::normalize( - A::tag()->dir(Direction::LTR)->render(), - ), + A::tag() + ->dir(Direction::LTR) + ->render(), "Failed asserting that element renders correctly with 'dir' attribute using enum.", ); } - // Anchor-specific attribute tests - public function testRenderWithDownload(): void { self::assertSame( << HTML, - LineEndingNormalizer::normalize( - A::tag()->download(true)->render(), - ), + A::tag() + ->download(true) + ->render(), "Failed asserting that element renders correctly with 'download' attribute.", ); } @@ -336,9 +328,9 @@ public function testRenderWithDownloadFilename(): void << HTML, - LineEndingNormalizer::normalize( - A::tag()->download('file.pdf')->render(), - ), + A::tag() + ->download('file.pdf') + ->render(), "Failed asserting that element renders correctly with 'download' attribute and filename.", ); } @@ -351,9 +343,7 @@ public function testRenderWithGlobalDefaultsAreApplied(): void << HTML, - LineEndingNormalizer::normalize( - A::tag()->render(), - ), + A::tag()->render(), 'Failed asserting that global defaults are applied correctly.', ); @@ -366,9 +356,9 @@ public function testRenderWithHidden(): void << HTML, - LineEndingNormalizer::normalize( - A::tag()->hidden(true)->render(), - ), + A::tag() + ->hidden(true) + ->render(), "Failed asserting that element renders correctly with 'hidden' attribute.", ); } @@ -379,9 +369,9 @@ public function testRenderWithHref(): void << HTML, - LineEndingNormalizer::normalize( - A::tag()->href('https://example.com')->render(), - ), + A::tag() + ->href('https://example.com') + ->render(), "Failed asserting that element renders correctly with 'href' attribute.", ); } @@ -392,9 +382,9 @@ public function testRenderWithHreflang(): void << HTML, - LineEndingNormalizer::normalize( - A::tag()->hreflang('en')->render(), - ), + A::tag() + ->hreflang('en') + ->render(), "Failed asserting that element renders correctly with 'hreflang' attribute.", ); } @@ -405,9 +395,9 @@ public function testRenderWithHreflangUsingEnum(): void << HTML, - LineEndingNormalizer::normalize( - A::tag()->hreflang(Language::SPANISH)->render(), - ), + A::tag() + ->hreflang(Language::SPANISH) + ->render(), "Failed asserting that element renders correctly with 'hreflang' attribute using enum.", ); } @@ -418,9 +408,9 @@ public function testRenderWithId(): void << HTML, - LineEndingNormalizer::normalize( - A::tag()->id('test-id')->render(), - ), + A::tag() + ->id('test-id') + ->render(), "Failed asserting that element renders correctly with 'id' attribute.", ); } @@ -431,9 +421,9 @@ public function testRenderWithLang(): void << HTML, - LineEndingNormalizer::normalize( - A::tag()->lang('es')->render(), - ), + A::tag() + ->lang('es') + ->render(), "Failed asserting that element renders correctly with 'lang' attribute.", ); } @@ -444,9 +434,9 @@ public function testRenderWithLangUsingEnum(): void << HTML, - LineEndingNormalizer::normalize( - A::tag()->lang(Language::SPANISH)->render(), - ), + A::tag() + ->lang(Language::SPANISH) + ->render(), "Failed asserting that element renders correctly with 'lang' attribute using enum.", ); } @@ -457,9 +447,9 @@ public function testRenderWithPing(): void << HTML, - LineEndingNormalizer::normalize( - A::tag()->ping('https://example.com/track')->render(), - ), + A::tag() + ->ping('https://example.com/track') + ->render(), "Failed asserting that element renders correctly with 'ping' attribute.", ); } @@ -470,9 +460,9 @@ public function testRenderWithReferrerpolicy(): void << HTML, - LineEndingNormalizer::normalize( - A::tag()->referrerpolicy('no-referrer')->render(), - ), + A::tag() + ->referrerpolicy('no-referrer') + ->render(), "Failed asserting that element renders correctly with 'referrerpolicy' attribute.", ); } @@ -483,9 +473,9 @@ public function testRenderWithReferrerpolicyUsingEnum(): void << HTML, - LineEndingNormalizer::normalize( - A::tag()->referrerpolicy(Referrerpolicy::NO_REFERRER)->render(), - ), + A::tag() + ->referrerpolicy(Referrerpolicy::NO_REFERRER) + ->render(), "Failed asserting that element renders correctly with 'referrerpolicy' attribute using enum.", ); } @@ -496,9 +486,9 @@ public function testRenderWithRel(): void << HTML, - LineEndingNormalizer::normalize( - A::tag()->rel('noopener')->render(), - ), + A::tag() + ->rel('noopener') + ->render(), "Failed asserting that element renders correctly with 'rel' attribute.", ); } @@ -509,9 +499,9 @@ public function testRenderWithRelUsingEnum(): void << HTML, - LineEndingNormalizer::normalize( - A::tag()->rel(Rel::NOOPENER)->render(), - ), + A::tag() + ->rel(Rel::NOOPENER) + ->render(), "Failed asserting that element renders correctly with 'rel' attribute using enum.", ); } @@ -522,12 +512,10 @@ public function testRenderWithRemoveAriaAttribute(): void << HTML, - LineEndingNormalizer::normalize( - A::tag() - ->addAriaAttribute('label', 'Close') - ->removeAriaAttribute('label') - ->render(), - ), + A::tag() + ->addAriaAttribute('label', 'Close') + ->removeAriaAttribute('label') + ->render(), "Failed asserting that element renders correctly with 'removeAriaAttribute()' method.", ); } @@ -538,12 +526,10 @@ public function testRenderWithRemoveAttribute(): void << HTML, - LineEndingNormalizer::normalize( - A::tag() - ->addAttribute('data-test', 'value') - ->removeAttribute('data-test') - ->render(), - ), + A::tag() + ->addAttribute('data-test', 'value') + ->removeAttribute('data-test') + ->render(), "Failed asserting that element renders correctly with 'removeAttribute()' method.", ); } @@ -554,12 +540,10 @@ public function testRenderWithRemoveDataAttribute(): void << HTML, - LineEndingNormalizer::normalize( - A::tag() - ->addDataAttribute('value', 'test') - ->removeDataAttribute('value') - ->render(), - ), + A::tag() + ->addDataAttribute('value', 'test') + ->removeDataAttribute('value') + ->render(), "Failed asserting that element renders correctly with 'removeDataAttribute()' method.", ); } @@ -570,9 +554,9 @@ public function testRenderWithRole(): void << HTML, - LineEndingNormalizer::normalize( - A::tag()->role('button')->render(), - ), + A::tag() + ->role('button') + ->render(), "Failed asserting that element renders correctly with 'role' attribute.", ); } @@ -583,9 +567,9 @@ public function testRenderWithRoleUsingEnum(): void << HTML, - LineEndingNormalizer::normalize( - A::tag()->role(Role::BUTTON)->render(), - ), + A::tag() + ->role(Role::BUTTON) + ->render(), "Failed asserting that element renders correctly with 'role' attribute using enum.", ); } @@ -596,9 +580,9 @@ public function testRenderWithStyle(): void << HTML, - LineEndingNormalizer::normalize( - A::tag()->style('color: red;')->render(), - ), + A::tag() + ->style('color: red;') + ->render(), "Failed asserting that element renders correctly with 'style' attribute.", ); } @@ -609,9 +593,9 @@ public function testRenderWithTarget(): void << HTML, - LineEndingNormalizer::normalize( - A::tag()->target('_blank')->render(), - ), + A::tag() + ->target('_blank') + ->render(), "Failed asserting that element renders correctly with 'target' attribute.", ); } @@ -622,9 +606,9 @@ public function testRenderWithTargetUsingEnum(): void << HTML, - LineEndingNormalizer::normalize( - A::tag()->target(Target::BLANK)->render(), - ), + A::tag() + ->target(Target::BLANK) + ->render(), "Failed asserting that element renders correctly with 'target' attribute using enum.", ); } @@ -635,9 +619,9 @@ public function testRenderWithThemeProvider(): void << HTML, - LineEndingNormalizer::normalize( - A::tag()->addThemeProvider('muted', DefaultThemeProvider::class)->render(), - ), + A::tag() + ->addThemeProvider('muted', DefaultThemeProvider::class) + ->render(), "Failed asserting that element renders correctly with 'addThemeProvider()' method.", ); } @@ -648,9 +632,9 @@ public function testRenderWithTitle(): void << HTML, - LineEndingNormalizer::normalize( - A::tag()->title('value')->render(), - ), + A::tag() + ->title('value') + ->render(), "Failed asserting that element renders correctly with 'title' attribute.", ); } @@ -661,9 +645,7 @@ public function testRenderWithToString(): void << HTML, - LineEndingNormalizer::normalize( - (string) A::tag(), - ), + (string) A::tag(), "Failed asserting that '__toString()' method renders correctly.", ); } @@ -674,9 +656,9 @@ public function testRenderWithTranslate(): void << HTML, - LineEndingNormalizer::normalize( - A::tag()->translate(false)->render(), - ), + A::tag() + ->translate(false) + ->render(), "Failed asserting that element renders correctly with 'translate' attribute.", ); } @@ -687,9 +669,9 @@ public function testRenderWithTranslateUsingEnum(): void << HTML, - LineEndingNormalizer::normalize( - A::tag()->translate(Translate::NO)->render(), - ), + A::tag() + ->translate(Translate::NO) + ->render(), "Failed asserting that element renders correctly with 'translate' attribute using enum.", ); } @@ -700,9 +682,9 @@ public function testRenderWithType(): void << HTML, - LineEndingNormalizer::normalize( - A::tag()->type('text/html')->render(), - ), + A::tag() + ->type('text/html') + ->render(), "Failed asserting that element renders correctly with 'type' attribute.", ); } @@ -715,9 +697,7 @@ public function testRenderWithUserOverridesGlobalDefaults(): void << HTML, - LineEndingNormalizer::normalize( - A::tag(['id' => 'id-user'])->render(), - ), + A::tag(['id' => 'id-user'])->render(), 'Failed asserting that user-defined attributes override global defaults correctly.', ); diff --git a/tests/Phrasing/ITest.php b/tests/Phrasing/ITest.php index d66b7c4..49b6d65 100644 --- a/tests/Phrasing/ITest.php +++ b/tests/Phrasing/ITest.php @@ -4,7 +4,6 @@ namespace UIAwesome\Html\Tests\Phrasing; -use PHPForge\Support\LineEndingNormalizer; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use UIAwesome\Html\Attribute\Values\{ @@ -32,17 +31,16 @@ * @copyright Copyright (C) 2026 Terabytesoftw. * @license https://opensource.org/license/bsd-3-clause BSD 3-Clause License. */ -#[Group('html')] #[Group('phrasing')] final class ITest extends TestCase { public function testContentEncodesValues(): void { - $i = I::tag()->content(''); - self::assertSame( '<value>', - $i->getContent(), + I::tag() + ->content('') + ->getContent(), "Failed asserting that 'content()' method encodes values correctly.", ); } @@ -60,7 +58,9 @@ public function testGetAttributesReturnsAssignedAttributes(): void { self::assertSame( ['data-test' => 'value'], - I::tag()->addAttribute('data-test', 'value')->getAttributes(), + I::tag() + ->addAttribute('data-test', 'value') + ->getAttributes(), "Failed asserting that 'getAttributes()' returns the assigned attributes.", ); } @@ -71,9 +71,9 @@ public function testHtmlDoesNotEncodeValues(): void << HTML, - LineEndingNormalizer::normalize( - I::tag()->html('')->render(), - ), + I::tag() + ->html('') + ->render(), "Failed asserting that element renders correctly with 'html()' method.", ); } @@ -84,9 +84,9 @@ public function testRenderWithAccesskey(): void << HTML, - LineEndingNormalizer::normalize( - I::tag()->accesskey('k')->render(), - ), + I::tag() + ->accesskey('k') + ->render(), "Failed asserting that element renders correctly with 'accesskey' attribute.", ); } @@ -97,9 +97,9 @@ public function testRenderWithAddAriaAttribute(): void << HTML, - LineEndingNormalizer::normalize( - I::tag()->addAriaAttribute('label', 'Idiomatic text')->render(), - ), + I::tag() + ->addAriaAttribute('label', 'Idiomatic text') + ->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method.", ); } @@ -110,9 +110,9 @@ public function testRenderWithAddAriaAttributeUsingEnum(): void << HTML, - LineEndingNormalizer::normalize( - I::tag()->addAriaAttribute(Aria::HIDDEN, true)->render(), - ), + I::tag() + ->addAriaAttribute(Aria::HIDDEN, true) + ->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method using enum.", ); } @@ -123,9 +123,9 @@ public function testRenderWithAddAttribute(): void << HTML, - LineEndingNormalizer::normalize( - I::tag()->addAttribute('data-test', 'value')->render(), - ), + I::tag() + ->addAttribute('data-test', 'value') + ->render(), "Failed asserting that element renders correctly with 'addAttribute()' method.", ); } @@ -136,9 +136,9 @@ public function testRenderWithAddAttributeUsingEnum(): void << HTML, - LineEndingNormalizer::normalize( - I::tag()->addAttribute(GlobalAttribute::TITLE, 'Idiomatic text')->render(), - ), + I::tag() + ->addAttribute(GlobalAttribute::TITLE, 'Idiomatic text') + ->render(), "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", ); } @@ -149,9 +149,9 @@ public function testRenderWithAddDataAttribute(): void << HTML, - LineEndingNormalizer::normalize( - I::tag()->addDataAttribute('value', 'value')->render(), - ), + I::tag() + ->addDataAttribute('value', 'value') + ->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method.", ); } @@ -162,9 +162,9 @@ public function testRenderWithAddDataAttributeUsingEnum(): void << HTML, - LineEndingNormalizer::normalize( - I::tag()->addDataAttribute(Data::VALUE, 'value')->render(), - ), + I::tag() + ->addDataAttribute(Data::VALUE, 'value') + ->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method using enum.", ); } @@ -175,17 +175,15 @@ public function testRenderWithAriaAttributes(): void << HTML, - LineEndingNormalizer::normalize( - I::tag() - ->ariaAttributes( - [ - 'controls' => static fn(): string => 'modal-1', - 'hidden' => false, - 'label' => 'Close', - ], - ) - ->render(), - ), + I::tag() + ->ariaAttributes( + [ + 'controls' => static fn(): string => 'modal-1', + 'hidden' => false, + 'label' => 'Close', + ], + ) + ->render(), "Failed asserting that element renders correctly with 'ariaAttributes()' method.", ); } @@ -196,9 +194,9 @@ public function testRenderWithAttributes(): void << HTML, - LineEndingNormalizer::normalize( - I::tag()->attributes(['class' => 'value'])->render(), - ), + I::tag() + ->attributes(['class' => 'value']) + ->render(), "Failed asserting that element renders correctly with 'attributes()' method.", ); } @@ -209,9 +207,9 @@ public function testRenderWithClass(): void << HTML, - LineEndingNormalizer::normalize( - I::tag()->class('value')->render(), - ), + I::tag() + ->class('value') + ->render(), "Failed asserting that element renders correctly with 'class' attribute.", ); } @@ -222,9 +220,9 @@ public function testRenderWithContent(): void <<value HTML, - LineEndingNormalizer::normalize( - I::tag()->content('value')->render(), - ), + I::tag() + ->content('value') + ->render(), 'Failed asserting that element renders correctly with default values.', ); } @@ -235,9 +233,9 @@ public function testRenderWithDataAttributes(): void << HTML, - LineEndingNormalizer::normalize( - I::tag()->dataAttributes(['value' => 'value'])->render(), - ), + I::tag() + ->dataAttributes(['value' => 'value']) + ->render(), "Failed asserting that element renders correctly with 'dataAttributes()' method.", ); } @@ -248,9 +246,7 @@ public function testRenderWithDefaultConfigurationValues(): void << HTML, - LineEndingNormalizer::normalize( - I::tag(['class' => 'default-class'])->render(), - ), + I::tag(['class' => 'default-class'])->render(), 'Failed asserting that default configuration values are applied correctly.', ); } @@ -261,9 +257,9 @@ public function testRenderWithDefaultProvider(): void << HTML, - LineEndingNormalizer::normalize( - I::tag()->addDefaultProvider(DefaultProvider::class)->render(), - ), + I::tag() + ->addDefaultProvider(DefaultProvider::class) + ->render(), 'Failed asserting that default provider is applied correctly.', ); } @@ -274,9 +270,7 @@ public function testRenderWithDefaultValues(): void << HTML, - LineEndingNormalizer::normalize( - I::tag()->render(), - ), + I::tag()->render(), 'Failed asserting that element renders correctly with default values.', ); } @@ -287,9 +281,9 @@ public function testRenderWithDir(): void << HTML, - LineEndingNormalizer::normalize( - I::tag()->dir('ltr')->render(), - ), + I::tag() + ->dir('ltr') + ->render(), "Failed asserting that element renders correctly with 'dir' attribute.", ); } @@ -300,9 +294,9 @@ public function testRenderWithDirUsingEnum(): void << HTML, - LineEndingNormalizer::normalize( - I::tag()->dir(Direction::LTR)->render(), - ), + I::tag() + ->dir(Direction::LTR) + ->render(), "Failed asserting that element renders correctly with 'dir' attribute using enum.", ); } @@ -315,9 +309,7 @@ public function testRenderWithGlobalDefaultsAreApplied(): void << HTML, - LineEndingNormalizer::normalize( - I::tag()->render(), - ), + I::tag()->render(), 'Failed asserting that global defaults are applied correctly.', ); @@ -330,9 +322,9 @@ public function testRenderWithHidden(): void << HTML, - LineEndingNormalizer::normalize( - I::tag()->hidden(true)->render(), - ), + I::tag() + ->hidden(true) + ->render(), "Failed asserting that element renders correctly with 'hidden' attribute.", ); } @@ -343,9 +335,9 @@ public function testRenderWithId(): void << HTML, - LineEndingNormalizer::normalize( - I::tag()->id('test-id')->render(), - ), + I::tag() + ->id('test-id') + ->render(), "Failed asserting that element renders correctly with 'id' attribute.", ); } @@ -356,9 +348,9 @@ public function testRenderWithLang(): void << HTML, - LineEndingNormalizer::normalize( - I::tag()->lang('es')->render(), - ), + I::tag() + ->lang('es') + ->render(), "Failed asserting that element renders correctly with 'lang' attribute.", ); } @@ -369,9 +361,9 @@ public function testRenderWithLangUsingEnum(): void << HTML, - LineEndingNormalizer::normalize( - I::tag()->lang(Language::SPANISH)->render(), - ), + I::tag() + ->lang(Language::SPANISH) + ->render(), "Failed asserting that element renders correctly with 'lang' attribute using enum.", ); } @@ -382,12 +374,10 @@ public function testRenderWithRemoveAriaAttribute(): void << HTML, - LineEndingNormalizer::normalize( - I::tag() - ->addAriaAttribute('label', 'Close') - ->removeAriaAttribute('label') - ->render(), - ), + I::tag() + ->addAriaAttribute('label', 'Close') + ->removeAriaAttribute('label') + ->render(), "Failed asserting that element renders correctly with 'removeAriaAttribute()' method.", ); } @@ -398,12 +388,10 @@ public function testRenderWithRemoveAttribute(): void << HTML, - LineEndingNormalizer::normalize( - I::tag() - ->addAttribute('data-test', 'value') - ->removeAttribute('data-test') - ->render(), - ), + I::tag() + ->addAttribute('data-test', 'value') + ->removeAttribute('data-test') + ->render(), "Failed asserting that element renders correctly with 'removeAttribute()' method.", ); } @@ -414,12 +402,10 @@ public function testRenderWithRemoveDataAttribute(): void << HTML, - LineEndingNormalizer::normalize( - I::tag() - ->addDataAttribute('value', 'test') - ->removeDataAttribute('value') - ->render(), - ), + I::tag() + ->addDataAttribute('value', 'test') + ->removeDataAttribute('value') + ->render(), "Failed asserting that element renders correctly with 'removeDataAttribute()' method.", ); } @@ -430,9 +416,9 @@ public function testRenderWithRole(): void << HTML, - LineEndingNormalizer::normalize( - I::tag()->role('button')->render(), - ), + I::tag() + ->role('button') + ->render(), "Failed asserting that element renders correctly with 'role' attribute.", ); } @@ -443,9 +429,9 @@ public function testRenderWithRoleUsingEnum(): void << HTML, - LineEndingNormalizer::normalize( - I::tag()->role(Role::BUTTON)->render(), - ), + I::tag() + ->role(Role::BUTTON) + ->render(), "Failed asserting that element renders correctly with 'role' attribute using enum.", ); } @@ -456,9 +442,9 @@ public function testRenderWithStyle(): void << HTML, - LineEndingNormalizer::normalize( - I::tag()->style('color: red;')->render(), - ), + I::tag() + ->style('color: red;') + ->render(), "Failed asserting that element renders correctly with 'style' attribute.", ); } @@ -469,9 +455,9 @@ public function testRenderWithThemeProvider(): void << HTML, - LineEndingNormalizer::normalize( - I::tag()->addThemeProvider('muted', DefaultThemeProvider::class)->render(), - ), + I::tag() + ->addThemeProvider('muted', DefaultThemeProvider::class) + ->render(), "Failed asserting that element renders correctly with 'addThemeProvider()' method.", ); } @@ -482,9 +468,9 @@ public function testRenderWithTitle(): void << HTML, - LineEndingNormalizer::normalize( - I::tag()->title('value')->render(), - ), + I::tag() + ->title('value') + ->render(), "Failed asserting that element renders correctly with 'title' attribute.", ); } @@ -495,9 +481,7 @@ public function testRenderWithToString(): void << HTML, - LineEndingNormalizer::normalize( - (string) I::tag(), - ), + (string) I::tag(), "Failed asserting that '__toString()' method renders correctly.", ); } @@ -508,9 +492,9 @@ public function testRenderWithTranslate(): void << HTML, - LineEndingNormalizer::normalize( - I::tag()->translate(false)->render(), - ), + I::tag() + ->translate(false) + ->render(), "Failed asserting that element renders correctly with 'translate' attribute.", ); } @@ -521,9 +505,9 @@ public function testRenderWithTranslateUsingEnum(): void << HTML, - LineEndingNormalizer::normalize( - I::tag()->translate(Translate::NO)->render(), - ), + I::tag() + ->translate(Translate::NO) + ->render(), "Failed asserting that element renders correctly with 'translate' attribute using enum.", ); } @@ -536,9 +520,7 @@ public function testRenderWithUserOverridesGlobalDefaults(): void << HTML, - LineEndingNormalizer::normalize( - I::tag(['id' => 'id-user'])->render(), - ), + I::tag(['id' => 'id-user'])->render(), 'Failed asserting that user-defined attributes override global defaults correctly.', ); diff --git a/tests/Phrasing/LabelTest.php b/tests/Phrasing/LabelTest.php index a2f1374..efb4b3e 100644 --- a/tests/Phrasing/LabelTest.php +++ b/tests/Phrasing/LabelTest.php @@ -4,7 +4,6 @@ namespace UIAwesome\Html\Tests\Phrasing; -use PHPForge\Support\LineEndingNormalizer; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use UIAwesome\Html\Attribute\Values\{ @@ -32,17 +31,16 @@ * @copyright Copyright (C) 2026 Terabytesoftw. * @license https://opensource.org/license/bsd-3-clause BSD 3-Clause License. */ -#[Group('html')] #[Group('phrasing')] final class LabelTest extends TestCase { public function testContentEncodesValues(): void { - $label = Label::tag()->content(''); - self::assertSame( '<value>', - $label->getContent(), + Label::tag() + ->content('') + ->getContent(), "Failed asserting that 'content()' method encodes values correctly.", ); } @@ -60,7 +58,9 @@ public function testGetAttributesReturnsAssignedAttributes(): void { self::assertSame( ['data-test' => 'value'], - Label::tag()->addAttribute('data-test', 'value')->getAttributes(), + Label::tag() + ->addAttribute('data-test', 'value') + ->getAttributes(), "Failed asserting that 'getAttributes()' returns the assigned attributes.", ); } @@ -71,9 +71,9 @@ public function testHtmlDoesNotEncodeValues(): void << HTML, - LineEndingNormalizer::normalize( - Label::tag()->html('')->render(), - ), + Label::tag() + ->html('') + ->render(), "Failed asserting that element renders correctly with 'html()' method.", ); } @@ -84,9 +84,9 @@ public function testRenderWithAccesskey(): void << HTML, - LineEndingNormalizer::normalize( - Label::tag()->accesskey('k')->render(), - ), + Label::tag() + ->accesskey('k') + ->render(), "Failed asserting that element renders correctly with 'accesskey' attribute.", ); } @@ -97,9 +97,9 @@ public function testRenderWithAddAriaAttribute(): void << HTML, - LineEndingNormalizer::normalize( - Label::tag()->addAriaAttribute('label', 'Label content')->render(), - ), + Label::tag() + ->addAriaAttribute('label', 'Label content') + ->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method.", ); } @@ -110,9 +110,9 @@ public function testRenderWithAddAriaAttributeUsingEnum(): void << HTML, - LineEndingNormalizer::normalize( - Label::tag()->addAriaAttribute(Aria::HIDDEN, true)->render(), - ), + Label::tag() + ->addAriaAttribute(Aria::HIDDEN, true) + ->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method using enum.", ); } @@ -123,9 +123,9 @@ public function testRenderWithAddAttribute(): void << HTML, - LineEndingNormalizer::normalize( - Label::tag()->addAttribute('data-test', 'value')->render(), - ), + Label::tag() + ->addAttribute('data-test', 'value') + ->render(), "Failed asserting that element renders correctly with 'addAttribute()' method.", ); } @@ -136,9 +136,9 @@ public function testRenderWithAddAttributeUsingEnum(): void << HTML, - LineEndingNormalizer::normalize( - Label::tag()->addAttribute(GlobalAttribute::TITLE, 'Label content')->render(), - ), + Label::tag() + ->addAttribute(GlobalAttribute::TITLE, 'Label content') + ->render(), "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", ); } @@ -149,9 +149,9 @@ public function testRenderWithAddDataAttribute(): void << HTML, - LineEndingNormalizer::normalize( - Label::tag()->addDataAttribute('value', 'value')->render(), - ), + Label::tag() + ->addDataAttribute('value', 'value') + ->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method.", ); } @@ -162,9 +162,9 @@ public function testRenderWithAddDataAttributeUsingEnum(): void << HTML, - LineEndingNormalizer::normalize( - Label::tag()->addDataAttribute(Data::VALUE, 'value')->render(), - ), + Label::tag() + ->addDataAttribute(Data::VALUE, 'value') + ->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method using enum.", ); } @@ -175,17 +175,15 @@ public function testRenderWithAriaAttributes(): void << HTML, - LineEndingNormalizer::normalize( - Label::tag() - ->ariaAttributes( - [ - 'controls' => static fn(): string => 'modal-1', - 'hidden' => false, - 'label' => 'Close', - ], - ) - ->render(), - ), + Label::tag() + ->ariaAttributes( + [ + 'controls' => static fn(): string => 'modal-1', + 'hidden' => false, + 'label' => 'Close', + ], + ) + ->render(), "Failed asserting that element renders correctly with 'ariaAttributes()' method.", ); } @@ -196,9 +194,9 @@ public function testRenderWithAttributes(): void << HTML, - LineEndingNormalizer::normalize( - Label::tag()->attributes(['class' => 'value'])->render(), - ), + Label::tag() + ->attributes(['class' => 'value']) + ->render(), "Failed asserting that element renders correctly with 'attributes()' method.", ); } @@ -209,9 +207,9 @@ public function testRenderWithClass(): void << HTML, - LineEndingNormalizer::normalize( - Label::tag()->class('value')->render(), - ), + Label::tag() + ->class('value') + ->render(), "Failed asserting that element renders correctly with 'class' attribute.", ); } @@ -222,9 +220,9 @@ public function testRenderWithContent(): void <<value HTML, - LineEndingNormalizer::normalize( - Label::tag()->content('value')->render(), - ), + Label::tag() + ->content('value') + ->render(), 'Failed asserting that element renders correctly with default values.', ); } @@ -235,9 +233,9 @@ public function testRenderWithDataAttributes(): void << HTML, - LineEndingNormalizer::normalize( - Label::tag()->dataAttributes(['value' => 'value'])->render(), - ), + Label::tag() + ->dataAttributes(['value' => 'value']) + ->render(), "Failed asserting that element renders correctly with 'dataAttributes()' method.", ); } @@ -248,9 +246,7 @@ public function testRenderWithDefaultConfigurationValues(): void << HTML, - LineEndingNormalizer::normalize( - Label::tag(['class' => 'default-class'])->render(), - ), + Label::tag(['class' => 'default-class'])->render(), 'Failed asserting that default configuration values are applied correctly.', ); } @@ -261,9 +257,9 @@ public function testRenderWithDefaultProvider(): void << HTML, - LineEndingNormalizer::normalize( - Label::tag()->addDefaultProvider(DefaultProvider::class)->render(), - ), + Label::tag() + ->addDefaultProvider(DefaultProvider::class) + ->render(), 'Failed asserting that default provider is applied correctly.', ); } @@ -274,9 +270,7 @@ public function testRenderWithDefaultValues(): void << HTML, - LineEndingNormalizer::normalize( - Label::tag()->render(), - ), + Label::tag()->render(), 'Failed asserting that element renders correctly with default values.', ); } @@ -287,9 +281,9 @@ public function testRenderWithDir(): void << HTML, - LineEndingNormalizer::normalize( - Label::tag()->dir('ltr')->render(), - ), + Label::tag() + ->dir('ltr') + ->render(), "Failed asserting that element renders correctly with 'dir' attribute.", ); } @@ -300,9 +294,9 @@ public function testRenderWithDirUsingEnum(): void << HTML, - LineEndingNormalizer::normalize( - Label::tag()->dir(Direction::LTR)->render(), - ), + Label::tag() + ->dir(Direction::LTR) + ->render(), "Failed asserting that element renders correctly with 'dir' attribute using enum.", ); } @@ -313,9 +307,9 @@ public function testRenderWithFor(): void << HTML, - LineEndingNormalizer::normalize( - Label::tag()->for('email')->render(), - ), + Label::tag() + ->for('email') + ->render(), "Failed asserting that element renders correctly with 'for' attribute.", ); } @@ -328,9 +322,7 @@ public function testRenderWithGlobalDefaultsAreApplied(): void << HTML, - LineEndingNormalizer::normalize( - Label::tag()->render(), - ), + Label::tag()->render(), 'Failed asserting that global defaults are applied correctly.', ); @@ -343,9 +335,9 @@ public function testRenderWithHidden(): void << HTML, - LineEndingNormalizer::normalize( - Label::tag()->hidden(true)->render(), - ), + Label::tag() + ->hidden(true) + ->render(), "Failed asserting that element renders correctly with 'hidden' attribute.", ); } @@ -356,9 +348,9 @@ public function testRenderWithId(): void << HTML, - LineEndingNormalizer::normalize( - Label::tag()->id('test-id')->render(), - ), + Label::tag() + ->id('test-id') + ->render(), "Failed asserting that element renders correctly with 'id' attribute.", ); } @@ -369,9 +361,9 @@ public function testRenderWithLang(): void << HTML, - LineEndingNormalizer::normalize( - Label::tag()->lang('es')->render(), - ), + Label::tag() + ->lang('es') + ->render(), "Failed asserting that element renders correctly with 'lang' attribute.", ); } @@ -382,9 +374,9 @@ public function testRenderWithLangUsingEnum(): void << HTML, - LineEndingNormalizer::normalize( - Label::tag()->lang(Language::SPANISH)->render(), - ), + Label::tag() + ->lang(Language::SPANISH) + ->render(), "Failed asserting that element renders correctly with 'lang' attribute using enum.", ); } @@ -395,12 +387,10 @@ public function testRenderWithRemoveAriaAttribute(): void << HTML, - LineEndingNormalizer::normalize( - Label::tag() - ->addAriaAttribute('label', 'Close') - ->removeAriaAttribute('label') - ->render(), - ), + Label::tag() + ->addAriaAttribute('label', 'Close') + ->removeAriaAttribute('label') + ->render(), "Failed asserting that element renders correctly with 'removeAriaAttribute()' method.", ); } @@ -411,12 +401,10 @@ public function testRenderWithRemoveAttribute(): void << HTML, - LineEndingNormalizer::normalize( - Label::tag() - ->addAttribute('data-test', 'value') - ->removeAttribute('data-test') - ->render(), - ), + Label::tag() + ->addAttribute('data-test', 'value') + ->removeAttribute('data-test') + ->render(), "Failed asserting that element renders correctly with 'removeAttribute()' method.", ); } @@ -427,12 +415,10 @@ public function testRenderWithRemoveDataAttribute(): void << HTML, - LineEndingNormalizer::normalize( - Label::tag() - ->addDataAttribute('value', 'test') - ->removeDataAttribute('value') - ->render(), - ), + Label::tag() + ->addDataAttribute('value', 'test') + ->removeDataAttribute('value') + ->render(), "Failed asserting that element renders correctly with 'removeDataAttribute()' method.", ); } @@ -443,9 +429,9 @@ public function testRenderWithRole(): void << HTML, - LineEndingNormalizer::normalize( - Label::tag()->role('button')->render(), - ), + Label::tag() + ->role('button') + ->render(), "Failed asserting that element renders correctly with 'role' attribute.", ); } @@ -456,9 +442,9 @@ public function testRenderWithRoleUsingEnum(): void << HTML, - LineEndingNormalizer::normalize( - Label::tag()->role(Role::BUTTON)->render(), - ), + Label::tag() + ->role(Role::BUTTON) + ->render(), "Failed asserting that element renders correctly with 'role' attribute using enum.", ); } @@ -469,9 +455,9 @@ public function testRenderWithStyle(): void << HTML, - LineEndingNormalizer::normalize( - Label::tag()->style('color: red;')->render(), - ), + Label::tag() + ->style('color: red;') + ->render(), "Failed asserting that element renders correctly with 'style' attribute.", ); } @@ -482,9 +468,9 @@ public function testRenderWithThemeProvider(): void << HTML, - LineEndingNormalizer::normalize( - Label::tag()->addThemeProvider('muted', DefaultThemeProvider::class)->render(), - ), + Label::tag() + ->addThemeProvider('muted', DefaultThemeProvider::class) + ->render(), "Failed asserting that element renders correctly with 'addThemeProvider()' method.", ); } @@ -495,9 +481,9 @@ public function testRenderWithTitle(): void << HTML, - LineEndingNormalizer::normalize( - Label::tag()->title('value')->render(), - ), + Label::tag() + ->title('value') + ->render(), "Failed asserting that element renders correctly with 'title' attribute.", ); } @@ -508,9 +494,7 @@ public function testRenderWithToString(): void << HTML, - LineEndingNormalizer::normalize( - (string) Label::tag(), - ), + (string) Label::tag(), "Failed asserting that '__toString()' method renders correctly.", ); } @@ -521,9 +505,9 @@ public function testRenderWithTranslate(): void << HTML, - LineEndingNormalizer::normalize( - Label::tag()->translate(false)->render(), - ), + Label::tag() + ->translate(false) + ->render(), "Failed asserting that element renders correctly with 'translate' attribute.", ); } @@ -534,9 +518,9 @@ public function testRenderWithTranslateUsingEnum(): void << HTML, - LineEndingNormalizer::normalize( - Label::tag()->translate(Translate::NO)->render(), - ), + Label::tag() + ->translate(Translate::NO) + ->render(), "Failed asserting that element renders correctly with 'translate' attribute using enum.", ); } @@ -549,9 +533,7 @@ public function testRenderWithUserOverridesGlobalDefaults(): void << HTML, - LineEndingNormalizer::normalize( - Label::tag(['id' => 'id-user'])->render(), - ), + Label::tag(['id' => 'id-user'])->render(), 'Failed asserting that user-defined attributes override global defaults correctly.', ); diff --git a/tests/Phrasing/SpanTest.php b/tests/Phrasing/SpanTest.php index 7ef9107..1fbcc93 100644 --- a/tests/Phrasing/SpanTest.php +++ b/tests/Phrasing/SpanTest.php @@ -4,7 +4,6 @@ namespace UIAwesome\Html\Tests\Phrasing; -use PHPForge\Support\LineEndingNormalizer; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use UIAwesome\Html\Attribute\Values\{ @@ -32,17 +31,16 @@ * @copyright Copyright (C) 2026 Terabytesoftw. * @license https://opensource.org/license/bsd-3-clause BSD 3-Clause License. */ -#[Group('html')] #[Group('phrasing')] final class SpanTest extends TestCase { public function testContentEncodesValues(): void { - $span = Span::tag()->content(''); - self::assertSame( '<value>', - $span->getContent(), + Span::tag() + ->content('') + ->getContent(), "Failed asserting that 'content()' method encodes values correctly.", ); } @@ -60,7 +58,9 @@ public function testGetAttributesReturnsAssignedAttributes(): void { self::assertSame( ['data-test' => 'value'], - Span::tag()->addAttribute('data-test', 'value')->getAttributes(), + Span::tag() + ->addAttribute('data-test', 'value') + ->getAttributes(), "Failed asserting that 'getAttributes()' returns the assigned attributes.", ); } @@ -71,9 +71,9 @@ public function testHtmlDoesNotEncodeValues(): void << HTML, - LineEndingNormalizer::normalize( - Span::tag()->html('')->render(), - ), + Span::tag() + ->html('') + ->render(), "Failed asserting that element renders correctly with 'html()' method.", ); } @@ -84,9 +84,7 @@ public function testRenderWithAccesskey(): void << HTML, - LineEndingNormalizer::normalize( - Span::tag()->accesskey('k')->render(), - ), + Span::tag()->accesskey('k')->render(), "Failed asserting that element renders correctly with 'accesskey' attribute.", ); } @@ -97,9 +95,9 @@ public function testRenderWithAddAriaAttribute(): void << HTML, - LineEndingNormalizer::normalize( - Span::tag()->addAriaAttribute('label', 'Span content')->render(), - ), + Span::tag() + ->addAriaAttribute('label', 'Span content') + ->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method.", ); } @@ -110,9 +108,9 @@ public function testRenderWithAddAriaAttributeUsingEnum(): void << HTML, - LineEndingNormalizer::normalize( - Span::tag()->addAriaAttribute(Aria::HIDDEN, true)->render(), - ), + Span::tag() + ->addAriaAttribute(Aria::HIDDEN, true) + ->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method using enum.", ); } @@ -123,9 +121,9 @@ public function testRenderWithAddAttribute(): void << HTML, - LineEndingNormalizer::normalize( - Span::tag()->addAttribute('data-test', 'value')->render(), - ), + Span::tag() + ->addAttribute('data-test', 'value') + ->render(), "Failed asserting that element renders correctly with 'addAttribute()' method.", ); } @@ -136,9 +134,9 @@ public function testRenderWithAddAttributeUsingEnum(): void << HTML, - LineEndingNormalizer::normalize( - Span::tag()->addAttribute(GlobalAttribute::TITLE, 'Span content')->render(), - ), + Span::tag() + ->addAttribute(GlobalAttribute::TITLE, 'Span content') + ->render(), "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", ); } @@ -149,9 +147,9 @@ public function testRenderWithAddDataAttribute(): void << HTML, - LineEndingNormalizer::normalize( - Span::tag()->addDataAttribute('value', 'value')->render(), - ), + Span::tag() + ->addDataAttribute('value', 'value') + ->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method.", ); } @@ -162,9 +160,9 @@ public function testRenderWithAddDataAttributeUsingEnum(): void << HTML, - LineEndingNormalizer::normalize( - Span::tag()->addDataAttribute(Data::VALUE, 'value')->render(), - ), + Span::tag() + ->addDataAttribute(Data::VALUE, 'value') + ->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method using enum.", ); } @@ -175,17 +173,15 @@ public function testRenderWithAriaAttributes(): void << HTML, - LineEndingNormalizer::normalize( - Span::tag() - ->ariaAttributes( - [ - 'controls' => static fn(): string => 'modal-1', - 'hidden' => false, - 'label' => 'Close', - ], - ) - ->render(), - ), + Span::tag() + ->ariaAttributes( + [ + 'controls' => static fn(): string => 'modal-1', + 'hidden' => false, + 'label' => 'Close', + ], + ) + ->render(), "Failed asserting that element renders correctly with 'ariaAttributes()' method.", ); } @@ -196,9 +192,9 @@ public function testRenderWithAttributes(): void << HTML, - LineEndingNormalizer::normalize( - Span::tag()->attributes(['class' => 'value'])->render(), - ), + Span::tag() + ->attributes(['class' => 'value']) + ->render(), "Failed asserting that element renders correctly with 'attributes()' method.", ); } @@ -209,9 +205,9 @@ public function testRenderWithClass(): void << HTML, - LineEndingNormalizer::normalize( - Span::tag()->class('value')->render(), - ), + Span::tag() + ->class('value') + ->render(), "Failed asserting that element renders correctly with 'class' attribute.", ); } @@ -222,9 +218,9 @@ public function testRenderWithContent(): void <<value HTML, - LineEndingNormalizer::normalize( - Span::tag()->content('value')->render(), - ), + Span::tag() + ->content('value') + ->render(), 'Failed asserting that element renders correctly with default values.', ); } @@ -235,9 +231,9 @@ public function testRenderWithDataAttributes(): void << HTML, - LineEndingNormalizer::normalize( - Span::tag()->dataAttributes(['value' => 'value'])->render(), - ), + Span::tag() + ->dataAttributes(['value' => 'value']) + ->render(), "Failed asserting that element renders correctly with 'dataAttributes()' method.", ); } @@ -248,9 +244,7 @@ public function testRenderWithDefaultConfigurationValues(): void << HTML, - LineEndingNormalizer::normalize( - Span::tag(['class' => 'default-class'])->render(), - ), + Span::tag(['class' => 'default-class'])->render(), 'Failed asserting that default configuration values are applied correctly.', ); } @@ -261,9 +255,9 @@ public function testRenderWithDefaultProvider(): void << HTML, - LineEndingNormalizer::normalize( - Span::tag()->addDefaultProvider(DefaultProvider::class)->render(), - ), + Span::tag() + ->addDefaultProvider(DefaultProvider::class) + ->render(), 'Failed asserting that default provider is applied correctly.', ); } @@ -274,9 +268,7 @@ public function testRenderWithDefaultValues(): void << HTML, - LineEndingNormalizer::normalize( - Span::tag()->render(), - ), + Span::tag()->render(), 'Failed asserting that element renders correctly with default values.', ); } @@ -287,9 +279,9 @@ public function testRenderWithDir(): void << HTML, - LineEndingNormalizer::normalize( - Span::tag()->dir('ltr')->render(), - ), + Span::tag() + ->dir('ltr') + ->render(), "Failed asserting that element renders correctly with 'dir' attribute.", ); } @@ -300,9 +292,9 @@ public function testRenderWithDirUsingEnum(): void << HTML, - LineEndingNormalizer::normalize( - Span::tag()->dir(Direction::LTR)->render(), - ), + Span::tag() + ->dir(Direction::LTR) + ->render(), "Failed asserting that element renders correctly with 'dir' attribute using enum.", ); } @@ -315,9 +307,7 @@ public function testRenderWithGlobalDefaultsAreApplied(): void << HTML, - LineEndingNormalizer::normalize( - Span::tag()->render(), - ), + Span::tag()->render(), 'Failed asserting that global defaults are applied correctly.', ); @@ -330,9 +320,9 @@ public function testRenderWithHidden(): void << HTML, - LineEndingNormalizer::normalize( - Span::tag()->hidden(true)->render(), - ), + Span::tag() + ->hidden(true) + ->render(), "Failed asserting that element renders correctly with 'hidden' attribute.", ); } @@ -343,9 +333,9 @@ public function testRenderWithId(): void << HTML, - LineEndingNormalizer::normalize( - Span::tag()->id('test-id')->render(), - ), + Span::tag() + ->id('test-id') + ->render(), "Failed asserting that element renders correctly with 'id' attribute.", ); } @@ -356,9 +346,9 @@ public function testRenderWithLang(): void << HTML, - LineEndingNormalizer::normalize( - Span::tag()->lang('es')->render(), - ), + Span::tag() + ->lang('es') + ->render(), "Failed asserting that element renders correctly with 'lang' attribute.", ); } @@ -369,9 +359,9 @@ public function testRenderWithLangUsingEnum(): void << HTML, - LineEndingNormalizer::normalize( - Span::tag()->lang(Language::SPANISH)->render(), - ), + Span::tag() + ->lang(Language::SPANISH) + ->render(), "Failed asserting that element renders correctly with 'lang' attribute using enum.", ); } @@ -382,12 +372,10 @@ public function testRenderWithRemoveAriaAttribute(): void << HTML, - LineEndingNormalizer::normalize( - Span::tag() - ->addAriaAttribute('label', 'Close') - ->removeAriaAttribute('label') - ->render(), - ), + Span::tag() + ->addAriaAttribute('label', 'Close') + ->removeAriaAttribute('label') + ->render(), "Failed asserting that element renders correctly with 'removeAriaAttribute()' method.", ); } @@ -398,12 +386,10 @@ public function testRenderWithRemoveAttribute(): void << HTML, - LineEndingNormalizer::normalize( - Span::tag() - ->addAttribute('data-test', 'value') - ->removeAttribute('data-test') - ->render(), - ), + Span::tag() + ->addAttribute('data-test', 'value') + ->removeAttribute('data-test') + ->render(), "Failed asserting that element renders correctly with 'removeAttribute()' method.", ); } @@ -414,12 +400,10 @@ public function testRenderWithRemoveDataAttribute(): void << HTML, - LineEndingNormalizer::normalize( - Span::tag() - ->addDataAttribute('value', 'test') - ->removeDataAttribute('value') - ->render(), - ), + Span::tag() + ->addDataAttribute('value', 'test') + ->removeDataAttribute('value') + ->render(), "Failed asserting that element renders correctly with 'removeDataAttribute()' method.", ); } @@ -430,9 +414,9 @@ public function testRenderWithRole(): void << HTML, - LineEndingNormalizer::normalize( - Span::tag()->role('button')->render(), - ), + Span::tag() + ->role('button') + ->render(), "Failed asserting that element renders correctly with 'role' attribute.", ); } @@ -443,9 +427,9 @@ public function testRenderWithRoleUsingEnum(): void << HTML, - LineEndingNormalizer::normalize( - Span::tag()->role(Role::BUTTON)->render(), - ), + Span::tag() + ->role(Role::BUTTON) + ->render(), "Failed asserting that element renders correctly with 'role' attribute using enum.", ); } @@ -456,9 +440,9 @@ public function testRenderWithStyle(): void << HTML, - LineEndingNormalizer::normalize( - Span::tag()->style('color: red;')->render(), - ), + Span::tag() + ->style('color: red;') + ->render(), "Failed asserting that element renders correctly with 'style' attribute.", ); } @@ -469,9 +453,9 @@ public function testRenderWithThemeProvider(): void << HTML, - LineEndingNormalizer::normalize( - Span::tag()->addThemeProvider('muted', DefaultThemeProvider::class)->render(), - ), + Span::tag() + ->addThemeProvider('muted', DefaultThemeProvider::class) + ->render(), "Failed asserting that element renders correctly with 'addThemeProvider()' method.", ); } @@ -482,9 +466,9 @@ public function testRenderWithTitle(): void << HTML, - LineEndingNormalizer::normalize( - Span::tag()->title('value')->render(), - ), + Span::tag() + ->title('value') + ->render(), "Failed asserting that element renders correctly with 'title' attribute.", ); } @@ -495,9 +479,7 @@ public function testRenderWithToString(): void << HTML, - LineEndingNormalizer::normalize( - (string) Span::tag(), - ), + (string) Span::tag(), "Failed asserting that '__toString()' method renders correctly.", ); } @@ -508,9 +490,9 @@ public function testRenderWithTranslate(): void << HTML, - LineEndingNormalizer::normalize( - Span::tag()->translate(false)->render(), - ), + Span::tag() + ->translate(false) + ->render(), "Failed asserting that element renders correctly with 'translate' attribute.", ); } @@ -521,9 +503,9 @@ public function testRenderWithTranslateUsingEnum(): void << HTML, - LineEndingNormalizer::normalize( - Span::tag()->translate(Translate::NO)->render(), - ), + Span::tag() + ->translate(Translate::NO) + ->render(), "Failed asserting that element renders correctly with 'translate' attribute using enum.", ); } @@ -536,9 +518,7 @@ public function testRenderWithUserOverridesGlobalDefaults(): void << HTML, - LineEndingNormalizer::normalize( - Span::tag(['id' => 'id-user'])->render(), - ), + Span::tag(['id' => 'id-user'])->render(), 'Failed asserting that user-defined attributes override global defaults correctly.', ); diff --git a/tests/Provider/Form/CheckedProvider.php b/tests/Provider/Form/CheckedProvider.php index 44fbf14..bee8dce 100644 --- a/tests/Provider/Form/CheckedProvider.php +++ b/tests/Provider/Form/CheckedProvider.php @@ -4,8 +4,7 @@ namespace UIAwesome\Html\Tests\Provider\Form; -use PHPForge\Support\Stub\BackedString; -use PHPForge\Support\Stub\Unit; +use PHPForge\Support\Stub\{BackedString, Unit}; use Stringable; use UnitEnum; @@ -37,7 +36,7 @@ public static function checked(): array [1, 2], 1, << + HTML, ], // array (unchecked) @@ -45,7 +44,7 @@ public static function checked(): array [1, 2], 3, << + HTML, ], // array type juggling (checked) @@ -53,14 +52,14 @@ public static function checked(): array ['1', '2'], 1, << + HTML, ], 'checked: [1, 2], value: "1"' => [ [1, 2], '1', << + HTML, ], // backed enum (checked) @@ -68,7 +67,7 @@ public static function checked(): array BackedString::VALUE, 'value', << + HTML, ], // backed enum (unchecked) @@ -76,7 +75,7 @@ public static function checked(): array BackedString::VALUE, 'other', << + HTML, ], // boolean `false` (never checked) @@ -84,35 +83,35 @@ public static function checked(): array false, 'active', << + HTML, ], 'checked: false, value: ""' => [ false, '', << + HTML, ], 'checked: false, value: 1' => [ false, 1, << + HTML, ], 'checked: false, value: false' => [ false, false, << + HTML, ], 'checked: false, value: null' => [ false, null, << + HTML, ], // boolean `true` (always checked) @@ -120,21 +119,21 @@ public static function checked(): array true, 'active', << + HTML, ], 'checked: true, value: 1' => [ true, 1, << + HTML, ], 'checked: true, value: null' => [ true, null, << + HTML, ], // float matching (checked) @@ -142,21 +141,21 @@ public static function checked(): array 1.1, 1.1, << + HTML, ], 'checked: 1.1, value: "1.1"' => [ 1.1, '1.1', << + HTML, ], 'checked: "1.1", value: 1.1' => [ '1.1', 1.1, << + HTML, ], // float mismatch (unchecked) @@ -164,7 +163,7 @@ public static function checked(): array 1.1, 1.2, << + HTML, ], // null (never checked) @@ -172,14 +171,14 @@ public static function checked(): array null, 1, << + HTML, ], 'checked: null, value: null' => [ null, null, << + HTML, ], // scalar matching (checked) @@ -187,35 +186,35 @@ public static function checked(): array 'active', 'active', << + HTML, ], 'checked: 0, value: 0' => [ 0, 0, << + HTML, ], 'checked: 1, value: 1' => [ 1, 1, << + HTML, ], 'checked: "1", value: true' => [ '1', true, << + HTML, ], 'checked: "1", value: "1"' => [ '1', '1', << + HTML, ], // scalar mismatch (unchecked) @@ -223,14 +222,14 @@ public static function checked(): array 'active', 'inactive', << + HTML, ], 'checked: 1, value: 0' => [ 1, 0, << + HTML, ], // type juggling (checked) @@ -238,14 +237,14 @@ public static function checked(): array 1, '1', << + HTML, ], 'checked: "1", value: 1' => [ '1', 1, << + HTML, ], // type juggling (unchecked) @@ -253,7 +252,7 @@ public static function checked(): array 1, '0', << + HTML, ], // stringable (checked) @@ -266,7 +265,7 @@ public function __toString(): string }, 'active', << + HTML, ], // stringable (unchecked) @@ -279,7 +278,7 @@ public function __toString(): string }, 'active', << + HTML, ], // unit enum (checked) @@ -287,7 +286,7 @@ public function __toString(): string Unit::value, 'value', << + HTML, ], // unit enum (unchecked) @@ -295,7 +294,7 @@ public function __toString(): string Unit::value, 'other', << + HTML, ], ]; diff --git a/tests/Root/BodyTest.php b/tests/Root/BodyTest.php index 7f37d60..9b15e5b 100644 --- a/tests/Root/BodyTest.php +++ b/tests/Root/BodyTest.php @@ -4,7 +4,6 @@ namespace UIAwesome\Html\Tests\Root; -use PHPForge\Support\LineEndingNormalizer; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use UIAwesome\Html\Attribute\Values\{ @@ -34,17 +33,16 @@ * @copyright Copyright (C) 2026 Terabytesoftw. * @license https://opensource.org/license/bsd-3-clause BSD 3-Clause License. */ -#[Group('html')] #[Group('root')] final class BodyTest extends TestCase { public function testContentEncodesValues(): void { - $body = Body::tag()->content(''); - self::assertSame( '<value>', - $body->getContent(), + Body::tag() + ->content('') + ->getContent(), "Failed asserting that 'content()' method encodes values correctly.", ); } @@ -62,7 +60,9 @@ public function testGetAttributesReturnsAssignedAttributes(): void { self::assertSame( ['data-test' => 'value'], - Body::tag()->addAttribute('data-test', 'value')->getAttributes(), + Body::tag() + ->addAttribute('data-test', 'value') + ->getAttributes(), "Failed asserting that 'getAttributes()' returns the assigned attributes.", ); } @@ -75,9 +75,9 @@ public function testHtmlDoesNotEncodeValues(): void HTML, - LineEndingNormalizer::normalize( - Body::tag()->html('')->render(), - ), + Body::tag() + ->html('') + ->render(), "Failed asserting that element renders correctly with 'html()' method.", ); } @@ -89,9 +89,9 @@ public function testRenderWithAccesskey(): void HTML, - LineEndingNormalizer::normalize( - Body::tag()->accesskey('k')->render(), - ), + Body::tag() + ->accesskey('k') + ->render(), "Failed asserting that element renders correctly with 'accesskey' attribute.", ); } @@ -103,9 +103,9 @@ public function testRenderWithAddAriaAttribute(): void HTML, - LineEndingNormalizer::normalize( - Body::tag()->addAriaAttribute('pressed', true)->render(), - ), + Body::tag() + ->addAriaAttribute('pressed', true) + ->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method.", ); } @@ -117,9 +117,9 @@ public function testRenderWithAddAriaAttributeUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - Body::tag()->addAriaAttribute(Aria::PRESSED, true)->render(), - ), + Body::tag() + ->addAriaAttribute(Aria::PRESSED, true) + ->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method.", ); } @@ -131,9 +131,9 @@ public function testRenderWithAddAttribute(): void HTML, - LineEndingNormalizer::normalize( - Body::tag()->addAttribute('data-test', 'value')->render(), - ), + Body::tag() + ->addAttribute('data-test', 'value') + ->render(), "Failed asserting that element renders correctly with 'addAttribute()' method.", ); } @@ -145,9 +145,9 @@ public function testRenderWithAddAttributeUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - Body::tag()->addAttribute(GlobalAttribute::TITLE, 'value')->render(), - ), + Body::tag() + ->addAttribute(GlobalAttribute::TITLE, 'value') + ->render(), "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", ); } @@ -159,9 +159,9 @@ public function testRenderWithAddDataAttribute(): void HTML, - LineEndingNormalizer::normalize( - Body::tag()->addDataAttribute('value', 'value')->render(), - ), + Body::tag() + ->addDataAttribute('value', 'value') + ->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method.", ); } @@ -173,9 +173,9 @@ public function testRenderWithAddDataAttributeUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - Body::tag()->addDataAttribute(Data::VALUE, 'value')->render(), - ), + Body::tag() + ->addDataAttribute(Data::VALUE, 'value') + ->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method.", ); } @@ -187,17 +187,15 @@ public function testRenderWithAriaAttributes(): void HTML, - LineEndingNormalizer::normalize( - Body::tag() - ->ariaAttributes( - [ - 'controls' => static fn(): string => 'modal-1', - 'hidden' => false, - 'label' => 'Close', - ], - ) - ->render(), - ), + Body::tag() + ->ariaAttributes( + [ + 'controls' => static fn(): string => 'modal-1', + 'hidden' => false, + 'label' => 'Close', + ], + ) + ->render(), "Failed asserting that element renders correctly with 'ariaAttributes()' method.", ); } @@ -209,9 +207,9 @@ public function testRenderWithAttributes(): void HTML, - LineEndingNormalizer::normalize( - Body::tag()->attributes(['class' => 'value'])->render(), - ), + Body::tag() + ->attributes(['class' => 'value']) + ->render(), "Failed asserting that element renders correctly with 'attributes()' method.", ); } @@ -223,9 +221,9 @@ public function testRenderWithAutofocus(): void HTML, - LineEndingNormalizer::normalize( - Body::tag()->autofocus(true)->render(), - ), + Body::tag() + ->autofocus(true) + ->render(), "Failed asserting that element renders correctly with 'autofocus' attribute.", ); } @@ -238,9 +236,7 @@ public function testRenderWithBeginEnd(): void Content HTML, - LineEndingNormalizer::normalize( - Body::tag()->begin() . 'Content' . Body::end(), - ), + Body::tag()->begin() . 'Content' . Body::end(), "Failed asserting that element renders correctly with 'begin()' and 'end()' methods.", ); } @@ -252,9 +248,9 @@ public function testRenderWithClass(): void HTML, - LineEndingNormalizer::normalize( - Body::tag()->class('value')->render(), - ), + Body::tag() + ->class('value') + ->render(), "Failed asserting that element renders correctly with 'class' attribute.", ); } @@ -267,9 +263,9 @@ public function testRenderWithContent(): void value HTML, - LineEndingNormalizer::normalize( - Body::tag()->content('value')->render(), - ), + Body::tag() + ->content('value') + ->render(), 'Failed asserting that element renders correctly with default values.', ); } @@ -281,9 +277,9 @@ public function testRenderWithContentEditable(): void HTML, - LineEndingNormalizer::normalize( - Body::tag()->contentEditable(true)->render(), - ), + Body::tag() + ->contentEditable(true) + ->render(), "Failed asserting that element renders correctly with 'contentEditable' attribute.", ); } @@ -295,9 +291,9 @@ public function testRenderWithContentEditableUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - Body::tag()->contentEditable(ContentEditable::TRUE)->render(), - ), + Body::tag() + ->contentEditable(ContentEditable::TRUE) + ->render(), "Failed asserting that element renders correctly with 'contentEditable' attribute using enum.", ); } @@ -309,9 +305,9 @@ public function testRenderWithDataAttributes(): void HTML, - LineEndingNormalizer::normalize( - Body::tag()->dataAttributes(['value' => 'value'])->render(), - ), + Body::tag() + ->dataAttributes(['value' => 'value']) + ->render(), "Failed asserting that element renders correctly with 'dataAttributes()' method.", ); } @@ -323,9 +319,7 @@ public function testRenderWithDefaultConfigurationValues(): void HTML, - LineEndingNormalizer::normalize( - Body::tag(['class' => 'default-class'])->render(), - ), + Body::tag(['class' => 'default-class'])->render(), 'Failed asserting that default configuration values are applied correctly.', ); } @@ -337,9 +331,9 @@ public function testRenderWithDefaultProvider(): void HTML, - LineEndingNormalizer::normalize( - Body::tag()->addDefaultProvider(DefaultProvider::class)->render(), - ), + Body::tag() + ->addDefaultProvider(DefaultProvider::class) + ->render(), 'Failed asserting that default provider is applied correctly.', ); } @@ -351,9 +345,9 @@ public function testRenderWithDir(): void HTML, - LineEndingNormalizer::normalize( - Body::tag()->dir('ltr')->render(), - ), + Body::tag() + ->dir('ltr') + ->render(), "Failed asserting that element renders correctly with 'dir' attribute.", ); } @@ -365,9 +359,9 @@ public function testRenderWithDirUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - Body::tag()->dir(Direction::LTR)->render(), - ), + Body::tag() + ->dir(Direction::LTR) + ->render(), "Failed asserting that element renders correctly with 'dir' attribute using enum.", ); } @@ -379,9 +373,9 @@ public function testRenderWithDraggable(): void HTML, - LineEndingNormalizer::normalize( - Body::tag()->draggable(true)->render(), - ), + Body::tag() + ->draggable(true) + ->render(), "Failed asserting that element renders correctly with 'draggable' attribute.", ); } @@ -393,9 +387,9 @@ public function testRenderWithDraggableUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - Body::tag()->draggable(Draggable::TRUE)->render(), - ), + Body::tag() + ->draggable(Draggable::TRUE) + ->render(), "Failed asserting that element renders correctly with 'draggable' attribute using enum.", ); } @@ -409,9 +403,7 @@ public function testRenderWithGlobalDefaultsAreApplied(): void HTML, - LineEndingNormalizer::normalize( - Body::tag()->render(), - ), + Body::tag()->render(), 'Failed asserting that global defaults are applied correctly.', ); @@ -425,9 +417,9 @@ public function testRenderWithHidden(): void HTML, - LineEndingNormalizer::normalize( - Body::tag()->hidden(true)->render(), - ), + Body::tag() + ->hidden(true) + ->render(), "Failed asserting that element renders correctly with 'hidden' attribute.", ); } @@ -439,9 +431,9 @@ public function testRenderWithId(): void HTML, - LineEndingNormalizer::normalize( - Body::tag()->id('test-id')->render(), - ), + Body::tag() + ->id('test-id') + ->render(), "Failed asserting that element renders correctly with 'id' attribute.", ); } @@ -453,9 +445,9 @@ public function testRenderWithLang(): void HTML, - LineEndingNormalizer::normalize( - Body::tag()->lang('es')->render(), - ), + Body::tag() + ->lang('es') + ->render(), "Failed asserting that element renders correctly with 'lang' attribute.", ); } @@ -467,9 +459,9 @@ public function testRenderWithLangUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - Body::tag()->lang(Language::SPANISH)->render(), - ), + Body::tag() + ->lang(Language::SPANISH) + ->render(), "Failed asserting that element renders correctly with 'lang' attribute using enum.", ); } @@ -481,15 +473,13 @@ public function testRenderWithMicroData(): void HTML, - LineEndingNormalizer::normalize( - Body::tag() - ->itemId('https://example.com/item') - ->itemProp('name') - ->itemRef('info') - ->itemScope(true) - ->itemType('https://schema.org/Thing') - ->render(), - ), + Body::tag() + ->itemId('https://example.com/item') + ->itemProp('name') + ->itemRef('info') + ->itemScope(true) + ->itemType('https://schema.org/Thing') + ->render(), 'Failed asserting that element renders correctly with microdata attributes.', ); } @@ -501,12 +491,10 @@ public function testRenderWithRemoveAriaAttribute(): void HTML, - LineEndingNormalizer::normalize( - Body::tag() - ->addAriaAttribute('label', 'Close') - ->removeAriaAttribute('label') - ->render(), - ), + Body::tag() + ->addAriaAttribute('label', 'Close') + ->removeAriaAttribute('label') + ->render(), "Failed asserting that element renders correctly with 'removeAriaAttribute()' method.", ); } @@ -518,12 +506,10 @@ public function testRenderWithRemoveAttribute(): void HTML, - LineEndingNormalizer::normalize( - Body::tag() - ->addAttribute('data-test', 'value') - ->removeAttribute('data-test') - ->render(), - ), + Body::tag() + ->addAttribute('data-test', 'value') + ->removeAttribute('data-test') + ->render(), "Failed asserting that element renders correctly with 'removeAttribute()' method.", ); } @@ -535,12 +521,10 @@ public function testRenderWithRemoveDataAttribute(): void HTML, - LineEndingNormalizer::normalize( - Body::tag() - ->addDataAttribute('value', 'test') - ->removeDataAttribute('value') - ->render(), - ), + Body::tag() + ->addDataAttribute('value', 'test') + ->removeDataAttribute('value') + ->render(), "Failed asserting that element renders correctly with 'removeDataAttribute()' method.", ); } @@ -552,9 +536,9 @@ public function testRenderWithRole(): void HTML, - LineEndingNormalizer::normalize( - Body::tag()->role('banner')->render(), - ), + Body::tag() + ->role('banner') + ->render(), "Failed asserting that element renders correctly with 'role' attribute.", ); } @@ -566,9 +550,9 @@ public function testRenderWithRoleUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - Body::tag()->role(Role::BANNER)->render(), - ), + Body::tag() + ->role(Role::BANNER) + ->render(), "Failed asserting that element renders correctly with 'role' attribute using enum.", ); } @@ -580,9 +564,9 @@ public function testRenderWithSpellcheck(): void HTML, - LineEndingNormalizer::normalize( - Body::tag()->spellcheck(true)->render(), - ), + Body::tag() + ->spellcheck(true) + ->render(), "Failed asserting that element renders correctly with 'spellcheck' attribute.", ); } @@ -594,9 +578,9 @@ public function testRenderWithStyle(): void HTML, - LineEndingNormalizer::normalize( - Body::tag()->style('value')->render(), - ), + Body::tag() + ->style('value') + ->render(), "Failed asserting that element renders correctly with 'style' attribute.", ); } @@ -608,9 +592,9 @@ public function testRenderWithTabindex(): void HTML, - LineEndingNormalizer::normalize( - Body::tag()->tabIndex(3)->render(), - ), + Body::tag() + ->tabIndex(3) + ->render(), "Failed asserting that element renders correctly with 'tabindex' attribute.", ); } @@ -622,9 +606,9 @@ public function testRenderWithThemeProvider(): void HTML, - LineEndingNormalizer::normalize( - Body::tag()->addThemeProvider('muted', DefaultThemeProvider::class)->render(), - ), + Body::tag() + ->addThemeProvider('muted', DefaultThemeProvider::class) + ->render(), "Failed asserting that element renders correctly with 'addThemeProvider()' method.", ); } @@ -636,9 +620,9 @@ public function testRenderWithTitle(): void HTML, - LineEndingNormalizer::normalize( - Body::tag()->title('value')->render(), - ), + Body::tag() + ->title('value') + ->render(), "Failed asserting that element renders correctly with 'title' attribute.", ); } @@ -650,9 +634,7 @@ public function testRenderWithToString(): void HTML, - LineEndingNormalizer::normalize( - (string) Body::tag(), - ), + (string) Body::tag(), "Failed asserting that '__toString()' method renders correctly.", ); } @@ -664,9 +646,9 @@ public function testRenderWithTranslate(): void HTML, - LineEndingNormalizer::normalize( - Body::tag()->translate(false)->render(), - ), + Body::tag() + ->translate(false) + ->render(), "Failed asserting that element renders correctly with 'translate' attribute.", ); } @@ -678,9 +660,9 @@ public function testRenderWithTranslateUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - Body::tag()->translate(Translate::NO)->render(), - ), + Body::tag() + ->translate(Translate::NO) + ->render(), "Failed asserting that element renders correctly with 'translate' attribute using enum.", ); } @@ -694,9 +676,7 @@ public function testRenderWithUserOverridesGlobalDefaults(): void HTML, - LineEndingNormalizer::normalize( - Body::tag(['id' => 'id-user'])->render(), - ), + Body::tag(['id' => 'id-user'])->render(), 'Failed asserting that user-defined attributes override global defaults correctly.', ); diff --git a/tests/Root/FooterTest.php b/tests/Root/FooterTest.php index 5d8abca..5e84ae9 100644 --- a/tests/Root/FooterTest.php +++ b/tests/Root/FooterTest.php @@ -4,7 +4,6 @@ namespace UIAwesome\Html\Tests\Root; -use PHPForge\Support\LineEndingNormalizer; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use UIAwesome\Html\Attribute\Values\{ @@ -34,17 +33,16 @@ * @copyright Copyright (C) 2026 Terabytesoftw. * @license https://opensource.org/license/bsd-3-clause BSD 3-Clause License. */ -#[Group('html')] #[Group('root')] final class FooterTest extends TestCase { public function testContentEncodesValues(): void { - $footer = Footer::tag()->content(''); - self::assertSame( '<value>', - $footer->getContent(), + Footer::tag() + ->content('') + ->getContent(), "Failed asserting that 'content()' method encodes values correctly.", ); } @@ -62,7 +60,9 @@ public function testGetAttributesReturnsAssignedAttributes(): void { self::assertSame( ['data-test' => 'value'], - Footer::tag()->addAttribute('data-test', 'value')->getAttributes(), + Footer::tag() + ->addAttribute('data-test', 'value') + ->getAttributes(), "Failed asserting that 'getAttributes()' returns the assigned attributes.", ); } @@ -75,9 +75,9 @@ public function testHtmlDoesNotEncodeValues(): void HTML, - LineEndingNormalizer::normalize( - Footer::tag()->html('')->render(), - ), + Footer::tag() + ->html('') + ->render(), "Failed asserting that element renders correctly with 'html()' method.", ); } @@ -89,9 +89,9 @@ public function testRenderWithAccesskey(): void
    HTML, - LineEndingNormalizer::normalize( - Footer::tag()->accesskey('k')->render(), - ), + Footer::tag() + ->accesskey('k') + ->render(), "Failed asserting that element renders correctly with 'accesskey' attribute.", ); } @@ -103,9 +103,9 @@ public function testRenderWithAddAriaAttribute(): void
    HTML, - LineEndingNormalizer::normalize( - Footer::tag()->addAriaAttribute('pressed', true)->render(), - ), + Footer::tag() + ->addAriaAttribute('pressed', true) + ->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method.", ); } @@ -117,9 +117,9 @@ public function testRenderWithAddAriaAttributeUsingEnum(): void
    HTML, - LineEndingNormalizer::normalize( - Footer::tag()->addAriaAttribute(Aria::PRESSED, true)->render(), - ), + Footer::tag() + ->addAriaAttribute(Aria::PRESSED, true) + ->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method.", ); } @@ -131,9 +131,9 @@ public function testRenderWithAddAttribute(): void
    HTML, - LineEndingNormalizer::normalize( - Footer::tag()->addAttribute('data-test', 'value')->render(), - ), + Footer::tag() + ->addAttribute('data-test', 'value') + ->render(), "Failed asserting that element renders correctly with 'addAttribute()' method.", ); } @@ -145,9 +145,9 @@ public function testRenderWithAddAttributeUsingEnum(): void
    HTML, - LineEndingNormalizer::normalize( - Footer::tag()->addAttribute(GlobalAttribute::TITLE, 'value')->render(), - ), + Footer::tag() + ->addAttribute(GlobalAttribute::TITLE, 'value') + ->render(), "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", ); } @@ -159,9 +159,9 @@ public function testRenderWithAddDataAttribute(): void
    HTML, - LineEndingNormalizer::normalize( - Footer::tag()->addDataAttribute('value', 'value')->render(), - ), + Footer::tag() + ->addDataAttribute('value', 'value') + ->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method.", ); } @@ -173,9 +173,9 @@ public function testRenderWithAddDataAttributeUsingEnum(): void
    HTML, - LineEndingNormalizer::normalize( - Footer::tag()->addDataAttribute(Data::VALUE, 'value')->render(), - ), + Footer::tag() + ->addDataAttribute(Data::VALUE, 'value') + ->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method.", ); } @@ -187,17 +187,15 @@ public function testRenderWithAriaAttributes(): void
    HTML, - LineEndingNormalizer::normalize( - Footer::tag() - ->ariaAttributes( - [ - 'controls' => static fn(): string => 'modal-1', - 'hidden' => false, - 'label' => 'Close', - ], - ) - ->render(), - ), + Footer::tag() + ->ariaAttributes( + [ + 'controls' => static fn(): string => 'modal-1', + 'hidden' => false, + 'label' => 'Close', + ], + ) + ->render(), "Failed asserting that element renders correctly with 'ariaAttributes()' method.", ); } @@ -209,9 +207,9 @@ public function testRenderWithAttributes(): void
    HTML, - LineEndingNormalizer::normalize( - Footer::tag()->attributes(['class' => 'value'])->render(), - ), + Footer::tag() + ->attributes(['class' => 'value']) + ->render(), "Failed asserting that element renders correctly with 'attributes()' method.", ); } @@ -223,9 +221,9 @@ public function testRenderWithAutofocus(): void
    HTML, - LineEndingNormalizer::normalize( - Footer::tag()->autofocus(true)->render(), - ), + Footer::tag() + ->autofocus(true) + ->render(), "Failed asserting that element renders correctly with 'autofocus' attribute.", ); } @@ -238,9 +236,7 @@ public function testRenderWithBeginEnd(): void Content HTML, - LineEndingNormalizer::normalize( - Footer::tag()->begin() . 'Content' . Footer::end(), - ), + Footer::tag()->begin() . 'Content' . Footer::end(), "Failed asserting that element renders correctly with 'begin()' and 'end()' methods.", ); } @@ -252,9 +248,9 @@ public function testRenderWithClass(): void
    HTML, - LineEndingNormalizer::normalize( - Footer::tag()->class('value')->render(), - ), + Footer::tag() + ->class('value') + ->render(), "Failed asserting that element renders correctly with 'class' attribute.", ); } @@ -267,9 +263,9 @@ public function testRenderWithContent(): void value HTML, - LineEndingNormalizer::normalize( - Footer::tag()->content('value')->render(), - ), + Footer::tag() + ->content('value') + ->render(), 'Failed asserting that element renders correctly with default values.', ); } @@ -281,9 +277,9 @@ public function testRenderWithContentEditable(): void
    HTML, - LineEndingNormalizer::normalize( - Footer::tag()->contentEditable(true)->render(), - ), + Footer::tag() + ->contentEditable(true) + ->render(), "Failed asserting that element renders correctly with 'contentEditable' attribute.", ); } @@ -295,9 +291,9 @@ public function testRenderWithContentEditableUsingEnum(): void
    HTML, - LineEndingNormalizer::normalize( - Footer::tag()->contentEditable(ContentEditable::TRUE)->render(), - ), + Footer::tag() + ->contentEditable(ContentEditable::TRUE) + ->render(), "Failed asserting that element renders correctly with 'contentEditable' attribute using enum.", ); } @@ -309,9 +305,9 @@ public function testRenderWithDataAttributes(): void
    HTML, - LineEndingNormalizer::normalize( - Footer::tag()->dataAttributes(['value' => 'value'])->render(), - ), + Footer::tag() + ->dataAttributes(['value' => 'value']) + ->render(), "Failed asserting that element renders correctly with 'dataAttributes()' method.", ); } @@ -323,9 +319,7 @@ public function testRenderWithDefaultConfigurationValues(): void
    HTML, - LineEndingNormalizer::normalize( - Footer::tag(['class' => 'default-class'])->render(), - ), + Footer::tag(['class' => 'default-class'])->render(), 'Failed asserting that default configuration values are applied correctly.', ); } @@ -337,9 +331,9 @@ public function testRenderWithDefaultProvider(): void
    HTML, - LineEndingNormalizer::normalize( - Footer::tag()->addDefaultProvider(DefaultProvider::class)->render(), - ), + Footer::tag() + ->addDefaultProvider(DefaultProvider::class) + ->render(), 'Failed asserting that default provider is applied correctly.', ); } @@ -351,9 +345,9 @@ public function testRenderWithDir(): void
    HTML, - LineEndingNormalizer::normalize( - Footer::tag()->dir('ltr')->render(), - ), + Footer::tag() + ->dir('ltr') + ->render(), "Failed asserting that element renders correctly with 'dir' attribute.", ); } @@ -365,9 +359,9 @@ public function testRenderWithDirUsingEnum(): void
    HTML, - LineEndingNormalizer::normalize( - Footer::tag()->dir(Direction::LTR)->render(), - ), + Footer::tag() + ->dir(Direction::LTR) + ->render(), "Failed asserting that element renders correctly with 'dir' attribute using enum.", ); } @@ -379,9 +373,9 @@ public function testRenderWithDraggable(): void
    HTML, - LineEndingNormalizer::normalize( - Footer::tag()->draggable(true)->render(), - ), + Footer::tag() + ->draggable(true) + ->render(), "Failed asserting that element renders correctly with 'draggable' attribute.", ); } @@ -393,9 +387,9 @@ public function testRenderWithDraggableUsingEnum(): void
    HTML, - LineEndingNormalizer::normalize( - Footer::tag()->draggable(Draggable::TRUE)->render(), - ), + Footer::tag() + ->draggable(Draggable::TRUE) + ->render(), "Failed asserting that element renders correctly with 'draggable' attribute using enum.", ); } @@ -409,9 +403,7 @@ public function testRenderWithGlobalDefaultsAreApplied(): void
    HTML, - LineEndingNormalizer::normalize( - Footer::tag()->render(), - ), + Footer::tag()->render(), 'Failed asserting that global defaults are applied correctly.', ); @@ -425,9 +417,9 @@ public function testRenderWithHidden(): void
    HTML, - LineEndingNormalizer::normalize( - Footer::tag()->hidden(true)->render(), - ), + Footer::tag() + ->hidden(true) + ->render(), "Failed asserting that element renders correctly with 'hidden' attribute.", ); } @@ -439,9 +431,9 @@ public function testRenderWithId(): void
    HTML, - LineEndingNormalizer::normalize( - Footer::tag()->id('test-id')->render(), - ), + Footer::tag() + ->id('test-id') + ->render(), "Failed asserting that element renders correctly with 'id' attribute.", ); } @@ -453,9 +445,9 @@ public function testRenderWithLang(): void
    HTML, - LineEndingNormalizer::normalize( - Footer::tag()->lang('es')->render(), - ), + Footer::tag() + ->lang('es') + ->render(), "Failed asserting that element renders correctly with 'lang' attribute.", ); } @@ -467,9 +459,9 @@ public function testRenderWithLangUsingEnum(): void
    HTML, - LineEndingNormalizer::normalize( - Footer::tag()->lang(Language::SPANISH)->render(), - ), + Footer::tag() + ->lang(Language::SPANISH) + ->render(), "Failed asserting that element renders correctly with 'lang' attribute using enum.", ); } @@ -481,15 +473,13 @@ public function testRenderWithMicroData(): void
    HTML, - LineEndingNormalizer::normalize( - Footer::tag() - ->itemId('https://example.com/item') - ->itemProp('name') - ->itemRef('info') - ->itemScope(true) - ->itemType('https://schema.org/Thing') - ->render(), - ), + Footer::tag() + ->itemId('https://example.com/item') + ->itemProp('name') + ->itemRef('info') + ->itemScope(true) + ->itemType('https://schema.org/Thing') + ->render(), 'Failed asserting that element renders correctly with microdata attributes.', ); } @@ -501,12 +491,10 @@ public function testRenderWithRemoveAriaAttribute(): void
    HTML, - LineEndingNormalizer::normalize( - Footer::tag() - ->addAriaAttribute('label', 'Close') - ->removeAriaAttribute('label') - ->render(), - ), + Footer::tag() + ->addAriaAttribute('label', 'Close') + ->removeAriaAttribute('label') + ->render(), "Failed asserting that element renders correctly with 'removeAriaAttribute()' method.", ); } @@ -518,12 +506,10 @@ public function testRenderWithRemoveAttribute(): void
    HTML, - LineEndingNormalizer::normalize( - Footer::tag() - ->addAttribute('data-test', 'value') - ->removeAttribute('data-test') - ->render(), - ), + Footer::tag() + ->addAttribute('data-test', 'value') + ->removeAttribute('data-test') + ->render(), "Failed asserting that element renders correctly with 'removeAttribute()' method.", ); } @@ -535,12 +521,10 @@ public function testRenderWithRemoveDataAttribute(): void
    HTML, - LineEndingNormalizer::normalize( - Footer::tag() - ->addDataAttribute('value', 'test') - ->removeDataAttribute('value') - ->render(), - ), + Footer::tag() + ->addDataAttribute('value', 'test') + ->removeDataAttribute('value') + ->render(), "Failed asserting that element renders correctly with 'removeDataAttribute()' method.", ); } @@ -552,9 +536,9 @@ public function testRenderWithRole(): void
    HTML, - LineEndingNormalizer::normalize( - Footer::tag()->role('contentinfo')->render(), - ), + Footer::tag() + ->role('contentinfo') + ->render(), "Failed asserting that element renders correctly with 'role' attribute.", ); } @@ -566,9 +550,9 @@ public function testRenderWithRoleUsingEnum(): void
    HTML, - LineEndingNormalizer::normalize( - Footer::tag()->role(Role::CONTENTINFO)->render(), - ), + Footer::tag() + ->role(Role::CONTENTINFO) + ->render(), "Failed asserting that element renders correctly with 'role' attribute using enum.", ); } @@ -580,9 +564,9 @@ public function testRenderWithSpellcheck(): void
    HTML, - LineEndingNormalizer::normalize( - Footer::tag()->spellcheck(true)->render(), - ), + Footer::tag() + ->spellcheck(true) + ->render(), "Failed asserting that element renders correctly with 'spellcheck' attribute.", ); } @@ -594,9 +578,9 @@ public function testRenderWithStyle(): void
    HTML, - LineEndingNormalizer::normalize( - Footer::tag()->style('value')->render(), - ), + Footer::tag() + ->style('value') + ->render(), "Failed asserting that element renders correctly with 'style' attribute.", ); } @@ -608,9 +592,9 @@ public function testRenderWithTabindex(): void
    HTML, - LineEndingNormalizer::normalize( - Footer::tag()->tabIndex(3)->render(), - ), + Footer::tag() + ->tabIndex(3) + ->render(), "Failed asserting that element renders correctly with 'tabindex' attribute.", ); } @@ -622,9 +606,9 @@ public function testRenderWithThemeProvider(): void
    HTML, - LineEndingNormalizer::normalize( - Footer::tag()->addThemeProvider('muted', DefaultThemeProvider::class)->render(), - ), + Footer::tag() + ->addThemeProvider('muted', DefaultThemeProvider::class) + ->render(), "Failed asserting that element renders correctly with 'addThemeProvider()' method.", ); } @@ -636,7 +620,9 @@ public function testRenderWithTitle(): void
    HTML, - Footer::tag()->title('value')->render(), + Footer::tag() + ->title('value') + ->render(), "Failed asserting that element renders correctly with 'title' attribute.", ); } @@ -648,9 +634,7 @@ public function testRenderWithToString(): void
    HTML, - LineEndingNormalizer::normalize( - (string) Footer::tag(), - ), + (string) Footer::tag(), "Failed asserting that '__toString()' method renders correctly.", ); } @@ -662,9 +646,9 @@ public function testRenderWithTranslate(): void
    HTML, - LineEndingNormalizer::normalize( - Footer::tag()->translate(false)->render(), - ), + Footer::tag() + ->translate(false) + ->render(), "Failed asserting that element renders correctly with 'translate' attribute.", ); } @@ -676,9 +660,9 @@ public function testRenderWithTranslateUsingEnum(): void
    HTML, - LineEndingNormalizer::normalize( - Footer::tag()->translate(Translate::NO)->render(), - ), + Footer::tag() + ->translate(Translate::NO) + ->render(), "Failed asserting that element renders correctly with 'translate' attribute using enum.", ); } @@ -692,9 +676,7 @@ public function testRenderWithUserOverridesGlobalDefaults(): void
    HTML, - LineEndingNormalizer::normalize( - Footer::tag(['id' => 'id-user'])->render(), - ), + Footer::tag(['id' => 'id-user'])->render(), 'Failed asserting that user-defined attributes override global defaults correctly.', ); diff --git a/tests/Root/HeadTest.php b/tests/Root/HeadTest.php index 8eb8b06..b5f5b5b 100644 --- a/tests/Root/HeadTest.php +++ b/tests/Root/HeadTest.php @@ -4,7 +4,6 @@ namespace UIAwesome\Html\Tests\Root; -use PHPForge\Support\LineEndingNormalizer; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use UIAwesome\Html\Attribute\Values\{ @@ -34,17 +33,16 @@ * @copyright Copyright (C) 2026 Terabytesoftw. * @license https://opensource.org/license/bsd-3-clause BSD 3-Clause License. */ -#[Group('html')] #[Group('root')] final class HeadTest extends TestCase { public function testContentEncodesValues(): void { - $head = Head::tag()->content(''); - self::assertSame( '<value>', - $head->getContent(), + Head::tag() + ->content('') + ->getContent(), "Failed asserting that 'content()' method encodes values correctly.", ); } @@ -62,7 +60,9 @@ public function testGetAttributesReturnsAssignedAttributes(): void { self::assertSame( ['data-test' => 'value'], - Head::tag()->addAttribute('data-test', 'value')->getAttributes(), + Head::tag() + ->addAttribute('data-test', 'value') + ->getAttributes(), "Failed asserting that 'getAttributes()' returns the assigned attributes.", ); } @@ -75,9 +75,9 @@ public function testHtmlDoesNotEncodeValues(): void HTML, - LineEndingNormalizer::normalize( - Head::tag()->html('')->render(), - ), + Head::tag() + ->html('') + ->render(), "Failed asserting that element renders correctly with 'html()' method.", ); } @@ -89,9 +89,9 @@ public function testRenderWithAccesskey(): void HTML, - LineEndingNormalizer::normalize( - Head::tag()->accesskey('k')->render(), - ), + Head::tag() + ->accesskey('k') + ->render(), "Failed asserting that element renders correctly with 'accesskey' attribute.", ); } @@ -103,9 +103,9 @@ public function testRenderWithAddAriaAttribute(): void HTML, - LineEndingNormalizer::normalize( - Head::tag()->addAriaAttribute('pressed', true)->render(), - ), + Head::tag() + ->addAriaAttribute('pressed', true) + ->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method.", ); } @@ -117,9 +117,9 @@ public function testRenderWithAddAriaAttributeUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - Head::tag()->addAriaAttribute(Aria::PRESSED, true)->render(), - ), + Head::tag() + ->addAriaAttribute(Aria::PRESSED, true) + ->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method.", ); } @@ -131,9 +131,9 @@ public function testRenderWithAddAttribute(): void HTML, - LineEndingNormalizer::normalize( - Head::tag()->addAttribute('data-test', 'value')->render(), - ), + Head::tag() + ->addAttribute('data-test', 'value') + ->render(), "Failed asserting that element renders correctly with 'addAttribute()' method.", ); } @@ -145,9 +145,9 @@ public function testRenderWithAddAttributeUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - Head::tag()->addAttribute(GlobalAttribute::TITLE, 'value')->render(), - ), + Head::tag() + ->addAttribute(GlobalAttribute::TITLE, 'value') + ->render(), "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", ); } @@ -159,9 +159,9 @@ public function testRenderWithAddDataAttribute(): void HTML, - LineEndingNormalizer::normalize( - Head::tag()->addDataAttribute('value', 'value')->render(), - ), + Head::tag() + ->addDataAttribute('value', 'value') + ->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method.", ); } @@ -173,9 +173,9 @@ public function testRenderWithAddDataAttributeUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - Head::tag()->addDataAttribute(Data::VALUE, 'value')->render(), - ), + Head::tag() + ->addDataAttribute(Data::VALUE, 'value') + ->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method.", ); } @@ -187,17 +187,15 @@ public function testRenderWithAriaAttributes(): void HTML, - LineEndingNormalizer::normalize( - Head::tag() - ->ariaAttributes( - [ - 'controls' => static fn(): string => 'modal-1', - 'hidden' => false, - 'label' => 'Close', - ], - ) - ->render(), - ), + Head::tag() + ->ariaAttributes( + [ + 'controls' => static fn(): string => 'modal-1', + 'hidden' => false, + 'label' => 'Close', + ], + ) + ->render(), "Failed asserting that element renders correctly with 'ariaAttributes()' method.", ); } @@ -209,9 +207,9 @@ public function testRenderWithAttributes(): void HTML, - LineEndingNormalizer::normalize( - Head::tag()->attributes(['class' => 'value'])->render(), - ), + Head::tag() + ->attributes(['class' => 'value']) + ->render(), "Failed asserting that element renders correctly with 'attributes()' method.", ); } @@ -223,9 +221,9 @@ public function testRenderWithAutofocus(): void HTML, - LineEndingNormalizer::normalize( - Head::tag()->autofocus(true)->render(), - ), + Head::tag() + ->autofocus(true) + ->render(), "Failed asserting that element renders correctly with 'autofocus' attribute.", ); } @@ -238,9 +236,7 @@ public function testRenderWithBeginEnd(): void Content HTML, - LineEndingNormalizer::normalize( - Head::tag()->begin() . 'Content' . Head::end(), - ), + Head::tag()->begin() . 'Content' . Head::end(), "Failed asserting that element renders correctly with 'begin()' and 'end()' methods.", ); } @@ -252,9 +248,9 @@ public function testRenderWithClass(): void HTML, - LineEndingNormalizer::normalize( - Head::tag()->class('value')->render(), - ), + Head::tag() + ->class('value') + ->render(), "Failed asserting that element renders correctly with 'class' attribute.", ); } @@ -267,9 +263,9 @@ public function testRenderWithContent(): void value HTML, - LineEndingNormalizer::normalize( - Head::tag()->content('value')->render(), - ), + Head::tag() + ->content('value') + ->render(), 'Failed asserting that element renders correctly with default values.', ); } @@ -281,9 +277,9 @@ public function testRenderWithContentEditable(): void HTML, - LineEndingNormalizer::normalize( - Head::tag()->contentEditable(true)->render(), - ), + Head::tag() + ->contentEditable(true) + ->render(), "Failed asserting that element renders correctly with 'contentEditable' attribute.", ); } @@ -295,9 +291,9 @@ public function testRenderWithContentEditableUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - Head::tag()->contentEditable(ContentEditable::TRUE)->render(), - ), + Head::tag() + ->contentEditable(ContentEditable::TRUE) + ->render(), "Failed asserting that element renders correctly with 'contentEditable' attribute using enum.", ); } @@ -309,9 +305,9 @@ public function testRenderWithDataAttributes(): void HTML, - LineEndingNormalizer::normalize( - Head::tag()->dataAttributes(['value' => 'value'])->render(), - ), + Head::tag() + ->dataAttributes(['value' => 'value']) + ->render(), "Failed asserting that element renders correctly with 'dataAttributes()' method.", ); } @@ -323,9 +319,7 @@ public function testRenderWithDefaultConfigurationValues(): void HTML, - LineEndingNormalizer::normalize( - Head::tag(['class' => 'default-class'])->render(), - ), + Head::tag(['class' => 'default-class'])->render(), 'Failed asserting that default configuration values are applied correctly.', ); } @@ -337,9 +331,9 @@ public function testRenderWithDefaultProvider(): void HTML, - LineEndingNormalizer::normalize( - Head::tag()->addDefaultProvider(DefaultProvider::class)->render(), - ), + Head::tag() + ->addDefaultProvider(DefaultProvider::class) + ->render(), 'Failed asserting that default provider is applied correctly.', ); } @@ -351,9 +345,9 @@ public function testRenderWithDir(): void HTML, - LineEndingNormalizer::normalize( - Head::tag()->dir('ltr')->render(), - ), + Head::tag() + ->dir('ltr') + ->render(), "Failed asserting that element renders correctly with 'dir' attribute.", ); } @@ -365,9 +359,9 @@ public function testRenderWithDirUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - Head::tag()->dir(Direction::LTR)->render(), - ), + Head::tag() + ->dir(Direction::LTR) + ->render(), "Failed asserting that element renders correctly with 'dir' attribute using enum.", ); } @@ -379,9 +373,9 @@ public function testRenderWithDraggable(): void HTML, - LineEndingNormalizer::normalize( - Head::tag()->draggable(true)->render(), - ), + Head::tag() + ->draggable(true) + ->render(), "Failed asserting that element renders correctly with 'draggable' attribute.", ); } @@ -393,9 +387,9 @@ public function testRenderWithDraggableUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - Head::tag()->draggable(Draggable::TRUE)->render(), - ), + Head::tag() + ->draggable(Draggable::TRUE) + ->render(), "Failed asserting that element renders correctly with 'draggable' attribute using enum.", ); } @@ -409,9 +403,7 @@ public function testRenderWithGlobalDefaultsAreApplied(): void HTML, - LineEndingNormalizer::normalize( - Head::tag()->render(), - ), + Head::tag()->render(), 'Failed asserting that global defaults are applied correctly.', ); @@ -425,9 +417,9 @@ public function testRenderWithHidden(): void HTML, - LineEndingNormalizer::normalize( - Head::tag()->hidden(true)->render(), - ), + Head::tag() + ->hidden(true) + ->render(), "Failed asserting that element renders correctly with 'hidden' attribute.", ); } @@ -439,9 +431,9 @@ public function testRenderWithId(): void HTML, - LineEndingNormalizer::normalize( - Head::tag()->id('test-id')->render(), - ), + Head::tag() + ->id('test-id') + ->render(), "Failed asserting that element renders correctly with 'id' attribute.", ); } @@ -453,9 +445,9 @@ public function testRenderWithLang(): void HTML, - LineEndingNormalizer::normalize( - Head::tag()->lang('es')->render(), - ), + Head::tag() + ->lang('es') + ->render(), "Failed asserting that element renders correctly with 'lang' attribute.", ); } @@ -467,9 +459,9 @@ public function testRenderWithLangUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - Head::tag()->lang(Language::SPANISH)->render(), - ), + Head::tag() + ->lang(Language::SPANISH) + ->render(), "Failed asserting that element renders correctly with 'lang' attribute using enum.", ); } @@ -481,15 +473,13 @@ public function testRenderWithMicroData(): void HTML, - LineEndingNormalizer::normalize( - Head::tag() - ->itemId('https://example.com/item') - ->itemProp('name') - ->itemRef('info') - ->itemScope(true) - ->itemType('https://schema.org/Thing') - ->render(), - ), + Head::tag() + ->itemId('https://example.com/item') + ->itemProp('name') + ->itemRef('info') + ->itemScope(true) + ->itemType('https://schema.org/Thing') + ->render(), 'Failed asserting that element renders correctly with microdata attributes.', ); } @@ -501,12 +491,10 @@ public function testRenderWithRemoveAriaAttribute(): void HTML, - LineEndingNormalizer::normalize( - Head::tag() - ->addAriaAttribute('label', 'Close') - ->removeAriaAttribute('label') - ->render(), - ), + Head::tag() + ->addAriaAttribute('label', 'Close') + ->removeAriaAttribute('label') + ->render(), "Failed asserting that element renders correctly with 'removeAriaAttribute()' method.", ); } @@ -518,12 +506,10 @@ public function testRenderWithRemoveAttribute(): void HTML, - LineEndingNormalizer::normalize( - Head::tag() - ->addAttribute('data-test', 'value') - ->removeAttribute('data-test') - ->render(), - ), + Head::tag() + ->addAttribute('data-test', 'value') + ->removeAttribute('data-test') + ->render(), "Failed asserting that element renders correctly with 'removeAttribute()' method.", ); } @@ -535,12 +521,10 @@ public function testRenderWithRemoveDataAttribute(): void HTML, - LineEndingNormalizer::normalize( - Head::tag() - ->addDataAttribute('value', 'test') - ->removeDataAttribute('value') - ->render(), - ), + Head::tag() + ->addDataAttribute('value', 'test') + ->removeDataAttribute('value') + ->render(), "Failed asserting that element renders correctly with 'removeDataAttribute()' method.", ); } @@ -552,9 +536,9 @@ public function testRenderWithRole(): void HTML, - LineEndingNormalizer::normalize( - Head::tag()->role('banner')->render(), - ), + Head::tag() + ->role('banner') + ->render(), "Failed asserting that element renders correctly with 'role' attribute.", ); } @@ -566,9 +550,9 @@ public function testRenderWithRoleUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - Head::tag()->role(Role::BANNER)->render(), - ), + Head::tag() + ->role(Role::BANNER) + ->render(), "Failed asserting that element renders correctly with 'role' attribute using enum.", ); } @@ -580,9 +564,9 @@ public function testRenderWithSpellcheck(): void HTML, - LineEndingNormalizer::normalize( - Head::tag()->spellcheck(true)->render(), - ), + Head::tag() + ->spellcheck(true) + ->render(), "Failed asserting that element renders correctly with 'spellcheck' attribute.", ); } @@ -594,9 +578,9 @@ public function testRenderWithStyle(): void HTML, - LineEndingNormalizer::normalize( - Head::tag()->style('value')->render(), - ), + Head::tag() + ->style('value') + ->render(), "Failed asserting that element renders correctly with 'style' attribute.", ); } @@ -608,9 +592,9 @@ public function testRenderWithTabindex(): void HTML, - LineEndingNormalizer::normalize( - Head::tag()->tabIndex(3)->render(), - ), + Head::tag() + ->tabIndex(3) + ->render(), "Failed asserting that element renders correctly with 'tabindex' attribute.", ); } @@ -622,9 +606,9 @@ public function testRenderWithThemeProvider(): void HTML, - LineEndingNormalizer::normalize( - Head::tag()->addThemeProvider('muted', DefaultThemeProvider::class)->render(), - ), + Head::tag() + ->addThemeProvider('muted', DefaultThemeProvider::class) + ->render(), "Failed asserting that element renders correctly with 'addThemeProvider()' method.", ); } @@ -636,9 +620,9 @@ public function testRenderWithTitle(): void HTML, - LineEndingNormalizer::normalize( - Head::tag()->title('value')->render(), - ), + Head::tag() + ->title('value') + ->render(), "Failed asserting that element renders correctly with 'title' attribute.", ); } @@ -650,9 +634,7 @@ public function testRenderWithToString(): void HTML, - LineEndingNormalizer::normalize( - (string) Head::tag(), - ), + (string) Head::tag(), "Failed asserting that '__toString()' method renders correctly.", ); } @@ -664,9 +646,9 @@ public function testRenderWithTranslate(): void HTML, - LineEndingNormalizer::normalize( - Head::tag()->translate(false)->render(), - ), + Head::tag() + ->translate(false) + ->render(), "Failed asserting that element renders correctly with 'translate' attribute.", ); } @@ -678,9 +660,9 @@ public function testRenderWithTranslateUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - Head::tag()->translate(Translate::NO)->render(), - ), + Head::tag() + ->translate(Translate::NO) + ->render(), "Failed asserting that element renders correctly with 'translate' attribute using enum.", ); } @@ -694,9 +676,7 @@ public function testRenderWithUserOverridesGlobalDefaults(): void HTML, - LineEndingNormalizer::normalize( - Head::tag(['id' => 'id-user'])->render(), - ), + Head::tag(['id' => 'id-user'])->render(), 'Failed asserting that user-defined attributes override global defaults correctly.', ); diff --git a/tests/Root/HeaderTest.php b/tests/Root/HeaderTest.php index 0f880c4..d0470cf 100644 --- a/tests/Root/HeaderTest.php +++ b/tests/Root/HeaderTest.php @@ -4,7 +4,6 @@ namespace UIAwesome\Html\Tests\Root; -use PHPForge\Support\LineEndingNormalizer; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use UIAwesome\Html\Attribute\Values\{ @@ -34,17 +33,16 @@ * @copyright Copyright (C) 2026 Terabytesoftw. * @license https://opensource.org/license/bsd-3-clause BSD 3-Clause License. */ -#[Group('html')] #[Group('root')] final class HeaderTest extends TestCase { public function testContentEncodesValues(): void { - $header = Header::tag()->content(''); - self::assertSame( '<value>', - $header->getContent(), + Header::tag() + ->content('') + ->getContent(), "Failed asserting that 'content()' method encodes values correctly.", ); } @@ -62,7 +60,9 @@ public function testGetAttributesReturnsAssignedAttributes(): void { self::assertSame( ['data-test' => 'value'], - Header::tag()->addAttribute('data-test', 'value')->getAttributes(), + Header::tag() + ->addAttribute('data-test', 'value') + ->getAttributes(), "Failed asserting that 'getAttributes()' returns the assigned attributes.", ); } @@ -75,9 +75,9 @@ public function testHtmlDoesNotEncodeValues(): void HTML, - LineEndingNormalizer::normalize( - Header::tag()->html('')->render(), - ), + Header::tag() + ->html('') + ->render(), "Failed asserting that element renders correctly with 'html()' method.", ); } @@ -89,9 +89,9 @@ public function testRenderWithAccesskey(): void
    HTML, - LineEndingNormalizer::normalize( - Header::tag()->accesskey('k')->render(), - ), + Header::tag() + ->accesskey('k') + ->render(), "Failed asserting that element renders correctly with 'accesskey' attribute.", ); } @@ -103,9 +103,9 @@ public function testRenderWithAddAriaAttribute(): void
    HTML, - LineEndingNormalizer::normalize( - Header::tag()->addAriaAttribute('pressed', true)->render(), - ), + Header::tag() + ->addAriaAttribute('pressed', true) + ->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method.", ); } @@ -117,9 +117,9 @@ public function testRenderWithAddAriaAttributeUsingEnum(): void
    HTML, - LineEndingNormalizer::normalize( - Header::tag()->addAriaAttribute(Aria::PRESSED, true)->render(), - ), + Header::tag() + ->addAriaAttribute(Aria::PRESSED, true) + ->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method using enum.", ); } @@ -131,9 +131,9 @@ public function testRenderWithAddAttribute(): void
    HTML, - LineEndingNormalizer::normalize( - Header::tag()->addAttribute('data-test', 'value')->render(), - ), + Header::tag() + ->addAttribute('data-test', 'value') + ->render(), "Failed asserting that element renders correctly with 'addAttribute()' method.", ); } @@ -145,9 +145,9 @@ public function testRenderWithAddAttributeUsingEnum(): void
    HTML, - LineEndingNormalizer::normalize( - Header::tag()->addAttribute(GlobalAttribute::TITLE, 'value')->render(), - ), + Header::tag() + ->addAttribute(GlobalAttribute::TITLE, 'value') + ->render(), "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", ); } @@ -159,9 +159,9 @@ public function testRenderWithAddDataAttribute(): void
    HTML, - LineEndingNormalizer::normalize( - Header::tag()->addDataAttribute('value', 'value')->render(), - ), + Header::tag() + ->addDataAttribute('value', 'value') + ->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method.", ); } @@ -173,9 +173,9 @@ public function testRenderWithAddDataAttributeUsingEnum(): void
    HTML, - LineEndingNormalizer::normalize( - Header::tag()->addDataAttribute(Data::VALUE, 'value')->render(), - ), + Header::tag() + ->addDataAttribute(Data::VALUE, 'value') + ->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method using enum.", ); } @@ -187,17 +187,15 @@ public function testRenderWithAriaAttributes(): void
    HTML, - LineEndingNormalizer::normalize( - Header::tag() - ->ariaAttributes( - [ - 'controls' => static fn(): string => 'modal-1', - 'hidden' => false, - 'label' => 'Close', - ], - ) - ->render(), - ), + Header::tag() + ->ariaAttributes( + [ + 'controls' => static fn(): string => 'modal-1', + 'hidden' => false, + 'label' => 'Close', + ], + ) + ->render(), "Failed asserting that element renders correctly with 'ariaAttributes()' method.", ); } @@ -209,9 +207,9 @@ public function testRenderWithAttributes(): void
    HTML, - LineEndingNormalizer::normalize( - Header::tag()->attributes(['class' => 'value'])->render(), - ), + Header::tag() + ->attributes(['class' => 'value']) + ->render(), "Failed asserting that element renders correctly with 'attributes()' method.", ); } @@ -223,9 +221,9 @@ public function testRenderWithAutofocus(): void
    HTML, - LineEndingNormalizer::normalize( - Header::tag()->autofocus(true)->render(), - ), + Header::tag() + ->autofocus(true) + ->render(), "Failed asserting that element renders correctly with 'autofocus' attribute.", ); } @@ -238,9 +236,7 @@ public function testRenderWithBeginEnd(): void Content HTML, - LineEndingNormalizer::normalize( - Header::tag()->begin() . 'Content' . Header::end(), - ), + Header::tag()->begin() . 'Content' . Header::end(), "Failed asserting that element renders correctly with 'begin()' and 'end()' methods.", ); } @@ -252,9 +248,9 @@ public function testRenderWithClass(): void
    HTML, - LineEndingNormalizer::normalize( - Header::tag()->class('value')->render(), - ), + Header::tag() + ->class('value') + ->render(), "Failed asserting that element renders correctly with 'class' attribute.", ); } @@ -267,9 +263,9 @@ public function testRenderWithContent(): void value HTML, - LineEndingNormalizer::normalize( - Header::tag()->content('value')->render(), - ), + Header::tag() + ->content('value') + ->render(), 'Failed asserting that element renders correctly with default values.', ); } @@ -281,9 +277,9 @@ public function testRenderWithContentEditable(): void
    HTML, - LineEndingNormalizer::normalize( - Header::tag()->contentEditable(true)->render(), - ), + Header::tag() + ->contentEditable(true) + ->render(), "Failed asserting that element renders correctly with 'contentEditable' attribute.", ); } @@ -295,9 +291,9 @@ public function testRenderWithContentEditableUsingEnum(): void
    HTML, - LineEndingNormalizer::normalize( - Header::tag()->contentEditable(ContentEditable::TRUE)->render(), - ), + Header::tag() + ->contentEditable(ContentEditable::TRUE) + ->render(), "Failed asserting that element renders correctly with 'contentEditable' attribute using enum.", ); } @@ -309,9 +305,9 @@ public function testRenderWithDataAttributes(): void
    HTML, - LineEndingNormalizer::normalize( - Header::tag()->dataAttributes(['value' => 'value'])->render(), - ), + Header::tag() + ->dataAttributes(['value' => 'value']) + ->render(), "Failed asserting that element renders correctly with 'dataAttributes()' method.", ); } @@ -323,9 +319,7 @@ public function testRenderWithDefaultConfigurationValues(): void
    HTML, - LineEndingNormalizer::normalize( - Header::tag(['class' => 'default-class'])->render(), - ), + Header::tag(['class' => 'default-class'])->render(), 'Failed asserting that default configuration values are applied correctly.', ); } @@ -337,9 +331,9 @@ public function testRenderWithDefaultProvider(): void
    HTML, - LineEndingNormalizer::normalize( - Header::tag()->addDefaultProvider(DefaultProvider::class)->render(), - ), + Header::tag() + ->addDefaultProvider(DefaultProvider::class) + ->render(), 'Failed asserting that default provider is applied correctly.', ); } @@ -351,9 +345,9 @@ public function testRenderWithDir(): void
    HTML, - LineEndingNormalizer::normalize( - Header::tag()->dir('ltr')->render(), - ), + Header::tag() + ->dir('ltr') + ->render(), "Failed asserting that element renders correctly with 'dir' attribute.", ); } @@ -365,9 +359,9 @@ public function testRenderWithDirUsingEnum(): void
    HTML, - LineEndingNormalizer::normalize( - Header::tag()->dir(Direction::LTR)->render(), - ), + Header::tag() + ->dir(Direction::LTR) + ->render(), "Failed asserting that element renders correctly with 'dir' attribute using enum.", ); } @@ -379,9 +373,9 @@ public function testRenderWithDraggable(): void
    HTML, - LineEndingNormalizer::normalize( - Header::tag()->draggable(true)->render(), - ), + Header::tag() + ->draggable(true) + ->render(), "Failed asserting that element renders correctly with 'draggable' attribute.", ); } @@ -393,9 +387,9 @@ public function testRenderWithDraggableUsingEnum(): void
    HTML, - LineEndingNormalizer::normalize( - Header::tag()->draggable(Draggable::TRUE)->render(), - ), + Header::tag() + ->draggable(Draggable::TRUE) + ->render(), "Failed asserting that element renders correctly with 'draggable' attribute using enum.", ); } @@ -409,9 +403,7 @@ public function testRenderWithGlobalDefaultsAreApplied(): void
    HTML, - LineEndingNormalizer::normalize( - Header::tag()->render(), - ), + Header::tag()->render(), 'Failed asserting that global defaults are applied correctly.', ); @@ -425,9 +417,9 @@ public function testRenderWithHidden(): void HTML, - LineEndingNormalizer::normalize( - Header::tag()->hidden(true)->render(), - ), + Header::tag() + ->hidden(true) + ->render(), "Failed asserting that element renders correctly with 'hidden' attribute.", ); } @@ -439,9 +431,9 @@ public function testRenderWithId(): void
    HTML, - LineEndingNormalizer::normalize( - Header::tag()->id('test-id')->render(), - ), + Header::tag() + ->id('test-id') + ->render(), "Failed asserting that element renders correctly with 'id' attribute.", ); } @@ -453,9 +445,9 @@ public function testRenderWithLang(): void
    HTML, - LineEndingNormalizer::normalize( - Header::tag()->lang('es')->render(), - ), + Header::tag() + ->lang('es') + ->render(), "Failed asserting that element renders correctly with 'lang' attribute.", ); } @@ -467,9 +459,9 @@ public function testRenderWithLangUsingEnum(): void
    HTML, - LineEndingNormalizer::normalize( - Header::tag()->lang(Language::SPANISH)->render(), - ), + Header::tag() + ->lang(Language::SPANISH) + ->render(), "Failed asserting that element renders correctly with 'lang' attribute using enum.", ); } @@ -481,15 +473,13 @@ public function testRenderWithMicroData(): void
    HTML, - LineEndingNormalizer::normalize( - Header::tag() - ->itemId('https://example.com/item') - ->itemProp('name') - ->itemRef('info') - ->itemScope(true) - ->itemType('https://schema.org/Thing') - ->render(), - ), + Header::tag() + ->itemId('https://example.com/item') + ->itemProp('name') + ->itemRef('info') + ->itemScope(true) + ->itemType('https://schema.org/Thing') + ->render(), 'Failed asserting that element renders correctly with microdata attributes.', ); } @@ -501,12 +491,10 @@ public function testRenderWithRemoveAriaAttribute(): void
    HTML, - LineEndingNormalizer::normalize( - Header::tag() - ->addAriaAttribute('label', 'Close') - ->removeAriaAttribute('label') - ->render(), - ), + Header::tag() + ->addAriaAttribute('label', 'Close') + ->removeAriaAttribute('label') + ->render(), "Failed asserting that element renders correctly with 'removeAriaAttribute()' method.", ); } @@ -518,12 +506,10 @@ public function testRenderWithRemoveAttribute(): void
    HTML, - LineEndingNormalizer::normalize( - Header::tag() - ->addAttribute('data-test', 'value') - ->removeAttribute('data-test') - ->render(), - ), + Header::tag() + ->addAttribute('data-test', 'value') + ->removeAttribute('data-test') + ->render(), "Failed asserting that element renders correctly with 'removeAttribute()' method.", ); } @@ -535,12 +521,10 @@ public function testRenderWithRemoveDataAttribute(): void
    HTML, - LineEndingNormalizer::normalize( - Header::tag() - ->addDataAttribute('value', 'test') - ->removeDataAttribute('value') - ->render(), - ), + Header::tag() + ->addDataAttribute('value', 'test') + ->removeDataAttribute('value') + ->render(), "Failed asserting that element renders correctly with 'removeDataAttribute()' method.", ); } @@ -552,9 +536,9 @@ public function testRenderWithRole(): void
    HTML, - LineEndingNormalizer::normalize( - Header::tag()->role('banner')->render(), - ), + Header::tag() + ->role('banner') + ->render(), "Failed asserting that element renders correctly with 'role' attribute.", ); } @@ -566,9 +550,9 @@ public function testRenderWithRoleUsingEnum(): void
    HTML, - LineEndingNormalizer::normalize( - Header::tag()->role(Role::BANNER)->render(), - ), + Header::tag() + ->role(Role::BANNER) + ->render(), "Failed asserting that element renders correctly with 'role' attribute using enum.", ); } @@ -580,9 +564,9 @@ public function testRenderWithSpellcheck(): void
    HTML, - LineEndingNormalizer::normalize( - Header::tag()->spellcheck(true)->render(), - ), + Header::tag() + ->spellcheck(true) + ->render(), "Failed asserting that element renders correctly with 'spellcheck' attribute.", ); } @@ -594,9 +578,9 @@ public function testRenderWithStyle(): void
    HTML, - LineEndingNormalizer::normalize( - Header::tag()->style('value')->render(), - ), + Header::tag() + ->style('value') + ->render(), "Failed asserting that element renders correctly with 'style' attribute.", ); } @@ -608,9 +592,9 @@ public function testRenderWithTabindex(): void
    HTML, - LineEndingNormalizer::normalize( - Header::tag()->tabIndex(3)->render(), - ), + Header::tag() + ->tabIndex(3) + ->render(), "Failed asserting that element renders correctly with 'tabindex' attribute.", ); } @@ -622,9 +606,9 @@ public function testRenderWithThemeProvider(): void
    HTML, - LineEndingNormalizer::normalize( - Header::tag()->addThemeProvider('muted', DefaultThemeProvider::class)->render(), - ), + Header::tag() + ->addThemeProvider('muted', DefaultThemeProvider::class) + ->render(), "Failed asserting that element renders correctly with 'addThemeProvider()' method.", ); } @@ -636,7 +620,9 @@ public function testRenderWithTitle(): void
    HTML, - Header::tag()->title('value')->render(), + Header::tag() + ->title('value') + ->render(), "Failed asserting that element renders correctly with 'title' attribute.", ); } @@ -648,9 +634,7 @@ public function testRenderWithToString(): void
    HTML, - LineEndingNormalizer::normalize( - (string) Header::tag(), - ), + (string) Header::tag(), "Failed asserting that '__toString()' method renders correctly.", ); } @@ -662,9 +646,9 @@ public function testRenderWithTranslate(): void
    HTML, - LineEndingNormalizer::normalize( - Header::tag()->translate(false)->render(), - ), + Header::tag() + ->translate(false) + ->render(), "Failed asserting that element renders correctly with 'translate' attribute.", ); } @@ -676,9 +660,9 @@ public function testRenderWithTranslateUsingEnum(): void
    HTML, - LineEndingNormalizer::normalize( - Header::tag()->translate(Translate::NO)->render(), - ), + Header::tag() + ->translate(Translate::NO) + ->render(), "Failed asserting that element renders correctly with 'translate' attribute using enum.", ); } @@ -692,9 +676,7 @@ public function testRenderWithUserOverridesGlobalDefaults(): void
    HTML, - LineEndingNormalizer::normalize( - Header::tag(['id' => 'id-user'])->render(), - ), + Header::tag(['id' => 'id-user'])->render(), 'Failed asserting that user-defined attributes override global defaults correctly.', ); diff --git a/tests/Root/HtmlTest.php b/tests/Root/HtmlTest.php index d73c265..5e1f348 100644 --- a/tests/Root/HtmlTest.php +++ b/tests/Root/HtmlTest.php @@ -4,7 +4,6 @@ namespace UIAwesome\Html\Tests\Root; -use PHPForge\Support\LineEndingNormalizer; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use UIAwesome\Html\Attribute\Values\{ @@ -34,17 +33,16 @@ * @copyright Copyright (C) 2026 Terabytesoftw. * @license https://opensource.org/license/bsd-3-clause BSD 3-Clause License. */ -#[Group('html')] #[Group('root')] final class HtmlTest extends TestCase { public function testContentEncodesValues(): void { - $html = Html::tag()->content(''); - self::assertSame( '<value>', - $html->getContent(), + Html::tag() + ->content('') + ->getContent(), "Failed asserting that 'content()' method encodes values correctly.", ); } @@ -62,7 +60,9 @@ public function testGetAttributesReturnsAssignedAttributes(): void { self::assertSame( ['data-test' => 'value'], - Html::tag()->addAttribute('data-test', 'value')->getAttributes(), + Html::tag() + ->addAttribute('data-test', 'value') + ->getAttributes(), "Failed asserting that 'getAttributes()' returns the assigned attributes.", ); } @@ -75,9 +75,9 @@ public function testHtmlDoesNotEncodeValues(): void HTML, - LineEndingNormalizer::normalize( - Html::tag()->html('')->render(), - ), + Html::tag() + ->html('') + ->render(), "Failed asserting that element renders correctly with 'html()' method.", ); } @@ -89,9 +89,9 @@ public function testRenderWithAccesskey(): void HTML, - LineEndingNormalizer::normalize( - Html::tag()->accesskey('k')->render(), - ), + Html::tag() + ->accesskey('k') + ->render(), "Failed asserting that element renders correctly with 'accesskey' attribute.", ); } @@ -103,9 +103,9 @@ public function testRenderWithAddAriaAttribute(): void HTML, - LineEndingNormalizer::normalize( - Html::tag()->addAriaAttribute('pressed', true)->render(), - ), + Html::tag() + ->addAriaAttribute('pressed', true) + ->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method.", ); } @@ -117,9 +117,9 @@ public function testRenderWithAddAriaAttributeUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - Html::tag()->addAriaAttribute(Aria::PRESSED, true)->render(), - ), + Html::tag() + ->addAriaAttribute(Aria::PRESSED, true) + ->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method.", ); } @@ -131,9 +131,9 @@ public function testRenderWithAddAttribute(): void HTML, - LineEndingNormalizer::normalize( - Html::tag()->addAttribute('data-test', 'value')->render(), - ), + Html::tag() + ->addAttribute('data-test', 'value') + ->render(), "Failed asserting that element renders correctly with 'addAttribute()' method.", ); } @@ -145,9 +145,9 @@ public function testRenderWithAddAttributeUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - Html::tag()->addAttribute(GlobalAttribute::TITLE, 'value')->render(), - ), + Html::tag() + ->addAttribute(GlobalAttribute::TITLE, 'value') + ->render(), "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", ); } @@ -159,9 +159,9 @@ public function testRenderWithAddDataAttribute(): void HTML, - LineEndingNormalizer::normalize( - Html::tag()->addDataAttribute('value', 'value')->render(), - ), + Html::tag() + ->addDataAttribute('value', 'value') + ->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method.", ); } @@ -173,9 +173,9 @@ public function testRenderWithAddDataAttributeUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - Html::tag()->addDataAttribute(Data::VALUE, 'value')->render(), - ), + Html::tag() + ->addDataAttribute(Data::VALUE, 'value') + ->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method.", ); } @@ -187,17 +187,15 @@ public function testRenderWithAriaAttributes(): void HTML, - LineEndingNormalizer::normalize( - Html::tag() - ->ariaAttributes( - [ - 'controls' => static fn(): string => 'modal-1', - 'hidden' => false, - 'label' => 'Close', - ], - ) - ->render(), - ), + Html::tag() + ->ariaAttributes( + [ + 'controls' => static fn(): string => 'modal-1', + 'hidden' => false, + 'label' => 'Close', + ], + ) + ->render(), "Failed asserting that element renders correctly with 'ariaAttributes()' method.", ); } @@ -209,9 +207,9 @@ public function testRenderWithAttributes(): void HTML, - LineEndingNormalizer::normalize( - Html::tag()->attributes(['class' => 'value'])->render(), - ), + Html::tag() + ->attributes(['class' => 'value']) + ->render(), "Failed asserting that element renders correctly with 'attributes()' method.", ); } @@ -223,9 +221,9 @@ public function testRenderWithAutofocus(): void HTML, - LineEndingNormalizer::normalize( - Html::tag()->autofocus(true)->render(), - ), + Html::tag() + ->autofocus(true) + ->render(), "Failed asserting that element renders correctly with 'autofocus' attribute.", ); } @@ -238,9 +236,7 @@ public function testRenderWithBeginEnd(): void Content HTML, - LineEndingNormalizer::normalize( - Html::tag()->begin() . 'Content' . Html::end(), - ), + Html::tag()->begin() . 'Content' . Html::end(), "Failed asserting that element renders correctly with 'begin()' and 'end()' methods.", ); } @@ -252,9 +248,9 @@ public function testRenderWithClass(): void HTML, - LineEndingNormalizer::normalize( - Html::tag()->class('value')->render(), - ), + Html::tag() + ->class('value') + ->render(), "Failed asserting that element renders correctly with 'class' attribute.", ); } @@ -267,9 +263,9 @@ public function testRenderWithContent(): void value HTML, - LineEndingNormalizer::normalize( - Html::tag()->content('value')->render(), - ), + Html::tag() + ->content('value') + ->render(), 'Failed asserting that element renders correctly with default values.', ); } @@ -281,9 +277,9 @@ public function testRenderWithContentEditable(): void HTML, - LineEndingNormalizer::normalize( - Html::tag()->contentEditable(true)->render(), - ), + Html::tag() + ->contentEditable(true) + ->render(), "Failed asserting that element renders correctly with 'contentEditable' attribute.", ); } @@ -295,9 +291,9 @@ public function testRenderWithContentEditableUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - Html::tag()->contentEditable(ContentEditable::TRUE)->render(), - ), + Html::tag() + ->contentEditable(ContentEditable::TRUE) + ->render(), "Failed asserting that element renders correctly with 'contentEditable' attribute using enum.", ); } @@ -309,9 +305,9 @@ public function testRenderWithDataAttributes(): void HTML, - LineEndingNormalizer::normalize( - Html::tag()->dataAttributes(['value' => 'value'])->render(), - ), + Html::tag() + ->dataAttributes(['value' => 'value']) + ->render(), "Failed asserting that element renders correctly with 'dataAttributes()' method.", ); } @@ -323,9 +319,7 @@ public function testRenderWithDefaultConfigurationValues(): void HTML, - LineEndingNormalizer::normalize( - Html::tag(['class' => 'default-class'])->render(), - ), + Html::tag(['class' => 'default-class'])->render(), 'Failed asserting that default configuration values are applied correctly.', ); } @@ -337,9 +331,9 @@ public function testRenderWithDefaultProvider(): void HTML, - LineEndingNormalizer::normalize( - Html::tag()->addDefaultProvider(DefaultProvider::class)->render(), - ), + Html::tag() + ->addDefaultProvider(DefaultProvider::class) + ->render(), 'Failed asserting that default provider is applied correctly.', ); } @@ -351,9 +345,9 @@ public function testRenderWithDir(): void HTML, - LineEndingNormalizer::normalize( - Html::tag()->dir('ltr')->render(), - ), + Html::tag() + ->dir('ltr') + ->render(), "Failed asserting that element renders correctly with 'dir' attribute.", ); } @@ -365,9 +359,9 @@ public function testRenderWithDirUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - Html::tag()->dir(Direction::LTR)->render(), - ), + Html::tag() + ->dir(Direction::LTR) + ->render(), "Failed asserting that element renders correctly with 'dir' attribute using enum.", ); } @@ -379,9 +373,9 @@ public function testRenderWithDraggable(): void HTML, - LineEndingNormalizer::normalize( - Html::tag()->draggable(true)->render(), - ), + Html::tag() + ->draggable(true) + ->render(), "Failed asserting that element renders correctly with 'draggable' attribute.", ); } @@ -393,9 +387,9 @@ public function testRenderWithDraggableUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - Html::tag()->draggable(Draggable::TRUE)->render(), - ), + Html::tag() + ->draggable(Draggable::TRUE) + ->render(), "Failed asserting that element renders correctly with 'draggable' attribute using enum.", ); } @@ -409,9 +403,7 @@ public function testRenderWithGlobalDefaultsAreApplied(): void HTML, - LineEndingNormalizer::normalize( - Html::tag()->render(), - ), + Html::tag()->render(), 'Failed asserting that global defaults are applied correctly.', ); @@ -425,9 +417,9 @@ public function testRenderWithHidden(): void HTML, - LineEndingNormalizer::normalize( - Html::tag()->hidden(true)->render(), - ), + Html::tag() + ->hidden(true) + ->render(), "Failed asserting that element renders correctly with 'hidden' attribute.", ); } @@ -439,9 +431,9 @@ public function testRenderWithId(): void HTML, - LineEndingNormalizer::normalize( - Html::tag()->id('test-id')->render(), - ), + Html::tag() + ->id('test-id') + ->render(), "Failed asserting that element renders correctly with 'id' attribute.", ); } @@ -453,9 +445,9 @@ public function testRenderWithLang(): void HTML, - LineEndingNormalizer::normalize( - Html::tag()->lang('es')->render(), - ), + Html::tag() + ->lang('es') + ->render(), "Failed asserting that element renders correctly with 'lang' attribute.", ); } @@ -467,9 +459,9 @@ public function testRenderWithLangUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - Html::tag()->lang(Language::SPANISH)->render(), - ), + Html::tag() + ->lang(Language::SPANISH) + ->render(), "Failed asserting that element renders correctly with 'lang' attribute using enum.", ); } @@ -481,15 +473,13 @@ public function testRenderWithMicroData(): void HTML, - LineEndingNormalizer::normalize( - Html::tag() - ->itemId('https://example.com/item') - ->itemProp('name') - ->itemRef('info') - ->itemScope(true) - ->itemType('https://schema.org/Thing') - ->render(), - ), + Html::tag() + ->itemId('https://example.com/item') + ->itemProp('name') + ->itemRef('info') + ->itemScope(true) + ->itemType('https://schema.org/Thing') + ->render(), 'Failed asserting that element renders correctly with microdata attributes.', ); } @@ -501,12 +491,10 @@ public function testRenderWithRemoveAriaAttribute(): void HTML, - LineEndingNormalizer::normalize( - Html::tag() - ->addAriaAttribute('label', 'Close') - ->removeAriaAttribute('label') - ->render(), - ), + Html::tag() + ->addAriaAttribute('label', 'Close') + ->removeAriaAttribute('label') + ->render(), "Failed asserting that element renders correctly with 'removeAriaAttribute()' method.", ); } @@ -518,12 +506,10 @@ public function testRenderWithRemoveAttribute(): void HTML, - LineEndingNormalizer::normalize( - Html::tag() - ->addAttribute('data-test', 'value') - ->removeAttribute('data-test') - ->render(), - ), + Html::tag() + ->addAttribute('data-test', 'value') + ->removeAttribute('data-test') + ->render(), "Failed asserting that element renders correctly with 'removeAttribute()' method.", ); } @@ -535,12 +521,10 @@ public function testRenderWithRemoveDataAttribute(): void HTML, - LineEndingNormalizer::normalize( - Html::tag() - ->addDataAttribute('value', 'test') - ->removeDataAttribute('value') - ->render(), - ), + Html::tag() + ->addDataAttribute('value', 'test') + ->removeDataAttribute('value') + ->render(), "Failed asserting that element renders correctly with 'removeDataAttribute()' method.", ); } @@ -552,9 +536,9 @@ public function testRenderWithRole(): void HTML, - LineEndingNormalizer::normalize( - Html::tag()->role('banner')->render(), - ), + Html::tag() + ->role('banner') + ->render(), "Failed asserting that element renders correctly with 'role' attribute.", ); } @@ -566,9 +550,9 @@ public function testRenderWithRoleUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - Html::tag()->role(Role::BANNER)->render(), - ), + Html::tag() + ->role(Role::BANNER) + ->render(), "Failed asserting that element renders correctly with 'role' attribute using enum.", ); } @@ -580,9 +564,9 @@ public function testRenderWithSpellcheck(): void HTML, - LineEndingNormalizer::normalize( - Html::tag()->spellcheck(true)->render(), - ), + Html::tag() + ->spellcheck(true) + ->render(), "Failed asserting that element renders correctly with 'spellcheck' attribute.", ); } @@ -594,9 +578,9 @@ public function testRenderWithStyle(): void HTML, - LineEndingNormalizer::normalize( - Html::tag()->style('value')->render(), - ), + Html::tag() + ->style('value') + ->render(), "Failed asserting that element renders correctly with 'style' attribute.", ); } @@ -608,9 +592,9 @@ public function testRenderWithTabindex(): void HTML, - LineEndingNormalizer::normalize( - Html::tag()->tabIndex(3)->render(), - ), + Html::tag() + ->tabIndex(3) + ->render(), "Failed asserting that element renders correctly with 'tabindex' attribute.", ); } @@ -622,9 +606,9 @@ public function testRenderWithThemeProvider(): void HTML, - LineEndingNormalizer::normalize( - Html::tag()->addThemeProvider('primary', DefaultThemeProvider::class)->render(), - ), + Html::tag() + ->addThemeProvider('primary', DefaultThemeProvider::class) + ->render(), "Failed asserting that element renders correctly with 'addThemeProvider()' method.", ); } @@ -636,9 +620,9 @@ public function testRenderWithTitle(): void HTML, - LineEndingNormalizer::normalize( - Html::tag()->title('value')->render(), - ), + Html::tag() + ->title('value') + ->render(), "Failed asserting that element renders correctly with 'title' attribute.", ); } @@ -650,9 +634,7 @@ public function testRenderWithToString(): void HTML, - LineEndingNormalizer::normalize( - (string) Html::tag(), - ), + (string) Html::tag(), "Failed asserting that '__toString()' method renders correctly.", ); } @@ -664,9 +646,9 @@ public function testRenderWithTranslate(): void HTML, - LineEndingNormalizer::normalize( - Html::tag()->translate(false)->render(), - ), + Html::tag() + ->translate(false) + ->render(), "Failed asserting that element renders correctly with 'translate' attribute.", ); } @@ -678,9 +660,9 @@ public function testRenderWithTranslateUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - Html::tag()->translate(Translate::NO)->render(), - ), + Html::tag() + ->translate(Translate::NO) + ->render(), "Failed asserting that element renders correctly with 'translate' attribute using enum.", ); } @@ -694,9 +676,7 @@ public function testRenderWithUserOverridesGlobalDefaults(): void HTML, - LineEndingNormalizer::normalize( - Html::tag(['id' => 'id-user'])->render(), - ), + Html::tag(['id' => 'id-user'])->render(), 'Failed asserting that user-defined attributes override global defaults correctly.', ); diff --git a/tests/Sectioning/ArticleTest.php b/tests/Sectioning/ArticleTest.php index 238a9bc..3558649 100644 --- a/tests/Sectioning/ArticleTest.php +++ b/tests/Sectioning/ArticleTest.php @@ -4,7 +4,6 @@ namespace UIAwesome\Html\Tests\Sectioning; -use PHPForge\Support\LineEndingNormalizer; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use UIAwesome\Html\Attribute\Values\{ @@ -34,17 +33,16 @@ * @copyright Copyright (C) 2026 Terabytesoftw. * @license https://opensource.org/license/bsd-3-clause BSD 3-Clause License. */ -#[Group('html')] #[Group('sectioning')] final class ArticleTest extends TestCase { public function testContentEncodesValues(): void { - $article = Article::tag()->content(''); - self::assertSame( '<value>', - $article->getContent(), + Article::tag() + ->content('') + ->getContent(), "Failed asserting that 'content()' method encodes values correctly.", ); } @@ -62,7 +60,9 @@ public function testGetAttributesReturnsAssignedAttributes(): void { self::assertSame( ['data-test' => 'value'], - Article::tag()->addAttribute('data-test', 'value')->getAttributes(), + Article::tag() + ->addAttribute('data-test', 'value') + ->getAttributes(), "Failed asserting that 'getAttributes()' returns the assigned attributes.", ); } @@ -75,9 +75,9 @@ public function testHtmlDoesNotEncodeValues(): void HTML, - LineEndingNormalizer::normalize( - Article::tag()->html('')->render(), - ), + Article::tag() + ->html('') + ->render(), "Failed asserting that element renders correctly with 'html()' method.", ); } @@ -89,9 +89,9 @@ public function testRenderWithAccesskey(): void
    HTML, - LineEndingNormalizer::normalize( - Article::tag()->accesskey('k')->render(), - ), + Article::tag() + ->accesskey('k') + ->render(), "Failed asserting that element renders correctly with 'accesskey' attribute.", ); } @@ -103,9 +103,9 @@ public function testRenderWithAddAriaAttribute(): void
    HTML, - LineEndingNormalizer::normalize( - Article::tag()->addAriaAttribute('pressed', true)->render(), - ), + Article::tag() + ->addAriaAttribute('pressed', true) + ->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method.", ); } @@ -117,9 +117,9 @@ public function testRenderWithAddAriaAttributeUsingEnum(): void
    HTML, - LineEndingNormalizer::normalize( - Article::tag()->addAriaAttribute(Aria::PRESSED, true)->render(), - ), + Article::tag() + ->addAriaAttribute(Aria::PRESSED, true) + ->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method.", ); } @@ -131,9 +131,9 @@ public function testRenderWithAddAttribute(): void
    HTML, - LineEndingNormalizer::normalize( - Article::tag()->addAttribute('data-test', 'value')->render(), - ), + Article::tag() + ->addAttribute('data-test', 'value') + ->render(), "Failed asserting that element renders correctly with 'addAttribute()' method.", ); } @@ -145,9 +145,9 @@ public function testRenderWithAddAttributeUsingEnum(): void
    HTML, - LineEndingNormalizer::normalize( - Article::tag()->addAttribute(GlobalAttribute::TITLE, 'value')->render(), - ), + Article::tag() + ->addAttribute(GlobalAttribute::TITLE, 'value') + ->render(), "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", ); } @@ -159,9 +159,9 @@ public function testRenderWithAddDataAttribute(): void
    HTML, - LineEndingNormalizer::normalize( - Article::tag()->addDataAttribute('value', 'value')->render(), - ), + Article::tag() + ->addDataAttribute('value', 'value') + ->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method.", ); } @@ -173,9 +173,9 @@ public function testRenderWithAddDataAttributeUsingEnum(): void
    HTML, - LineEndingNormalizer::normalize( - Article::tag()->addDataAttribute(Data::VALUE, 'value')->render(), - ), + Article::tag() + ->addDataAttribute(Data::VALUE, 'value') + ->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method.", ); } @@ -187,17 +187,15 @@ public function testRenderWithAriaAttributes(): void
    HTML, - LineEndingNormalizer::normalize( - Article::tag() - ->ariaAttributes( - [ - 'controls' => static fn(): string => 'modal-1', - 'hidden' => false, - 'label' => 'Close', - ], - ) - ->render(), - ), + Article::tag() + ->ariaAttributes( + [ + 'controls' => static fn(): string => 'modal-1', + 'hidden' => false, + 'label' => 'Close', + ], + ) + ->render(), "Failed asserting that element renders correctly with 'ariaAttributes()' method.", ); } @@ -209,9 +207,9 @@ public function testRenderWithAttributes(): void
    HTML, - LineEndingNormalizer::normalize( - Article::tag()->attributes(['class' => 'value'])->render(), - ), + Article::tag() + ->attributes(['class' => 'value']) + ->render(), "Failed asserting that element renders correctly with 'attributes()' method.", ); } @@ -223,9 +221,9 @@ public function testRenderWithAutofocus(): void
    HTML, - LineEndingNormalizer::normalize( - Article::tag()->autofocus(true)->render(), - ), + Article::tag() + ->autofocus(true) + ->render(), "Failed asserting that element renders correctly with 'autofocus' attribute.", ); } @@ -238,9 +236,7 @@ public function testRenderWithBeginEnd(): void Content HTML, - LineEndingNormalizer::normalize( - Article::tag()->begin() . 'Content' . Article::end(), - ), + Article::tag()->begin() . 'Content' . Article::end(), "Failed asserting that element renders correctly with 'begin()' and 'end()' methods.", ); } @@ -252,9 +248,9 @@ public function testRenderWithClass(): void
    HTML, - LineEndingNormalizer::normalize( - Article::tag()->class('value')->render(), - ), + Article::tag() + ->class('value') + ->render(), "Failed asserting that element renders correctly with 'class' attribute.", ); } @@ -267,9 +263,9 @@ public function testRenderWithContent(): void value HTML, - LineEndingNormalizer::normalize( - Article::tag()->content('value')->render(), - ), + Article::tag() + ->content('value') + ->render(), 'Failed asserting that element renders correctly with default values.', ); } @@ -281,9 +277,9 @@ public function testRenderWithContentEditable(): void
    HTML, - LineEndingNormalizer::normalize( - Article::tag()->contentEditable(true)->render(), - ), + Article::tag() + ->contentEditable(true) + ->render(), "Failed asserting that element renders correctly with 'contentEditable' attribute.", ); } @@ -295,9 +291,9 @@ public function testRenderWithContentEditableUsingEnum(): void
    HTML, - LineEndingNormalizer::normalize( - Article::tag()->contentEditable(ContentEditable::TRUE)->render(), - ), + Article::tag() + ->contentEditable(ContentEditable::TRUE) + ->render(), "Failed asserting that element renders correctly with 'contentEditable' attribute using enum.", ); } @@ -309,9 +305,9 @@ public function testRenderWithDataAttributes(): void
    HTML, - LineEndingNormalizer::normalize( - Article::tag()->dataAttributes(['value' => 'value'])->render(), - ), + Article::tag() + ->dataAttributes(['value' => 'value']) + ->render(), "Failed asserting that element renders correctly with 'dataAttributes()' method.", ); } @@ -323,9 +319,7 @@ public function testRenderWithDefaultConfigurationValues(): void
    HTML, - LineEndingNormalizer::normalize( - Article::tag(['class' => 'default-class'])->render(), - ), + Article::tag(['class' => 'default-class'])->render(), 'Failed asserting that default configuration values are applied correctly.', ); } @@ -337,9 +331,9 @@ public function testRenderWithDefaultProvider(): void
    HTML, - LineEndingNormalizer::normalize( - Article::tag()->addDefaultProvider(DefaultProvider::class)->render(), - ), + Article::tag() + ->addDefaultProvider(DefaultProvider::class) + ->render(), 'Failed asserting that default provider is applied correctly.', ); } @@ -351,9 +345,9 @@ public function testRenderWithDir(): void
    HTML, - LineEndingNormalizer::normalize( - Article::tag()->dir('ltr')->render(), - ), + Article::tag() + ->dir('ltr') + ->render(), "Failed asserting that element renders correctly with 'dir' attribute.", ); } @@ -365,9 +359,9 @@ public function testRenderWithDirUsingEnum(): void
    HTML, - LineEndingNormalizer::normalize( - Article::tag()->dir(Direction::LTR)->render(), - ), + Article::tag() + ->dir(Direction::LTR) + ->render(), "Failed asserting that element renders correctly with 'dir' attribute using enum.", ); } @@ -379,9 +373,9 @@ public function testRenderWithDraggable(): void
    HTML, - LineEndingNormalizer::normalize( - Article::tag()->draggable(true)->render(), - ), + Article::tag() + ->draggable(true) + ->render(), "Failed asserting that element renders correctly with 'draggable' attribute.", ); } @@ -393,9 +387,9 @@ public function testRenderWithDraggableUsingEnum(): void
    HTML, - LineEndingNormalizer::normalize( - Article::tag()->draggable(Draggable::TRUE)->render(), - ), + Article::tag() + ->draggable(Draggable::TRUE) + ->render(), "Failed asserting that element renders correctly with 'draggable' attribute using enum.", ); } @@ -409,9 +403,7 @@ public function testRenderWithGlobalDefaultsAreApplied(): void
    HTML, - LineEndingNormalizer::normalize( - Article::tag()->render(), - ), + Article::tag()->render(), 'Failed asserting that global defaults are applied correctly.', ); @@ -425,9 +417,9 @@ public function testRenderWithHidden(): void HTML, - LineEndingNormalizer::normalize( - Article::tag()->hidden(true)->render(), - ), + Article::tag() + ->hidden(true) + ->render(), "Failed asserting that element renders correctly with 'hidden' attribute.", ); } @@ -439,9 +431,9 @@ public function testRenderWithId(): void
    HTML, - LineEndingNormalizer::normalize( - Article::tag()->id('test-id')->render(), - ), + Article::tag() + ->id('test-id') + ->render(), "Failed asserting that element renders correctly with 'id' attribute.", ); } @@ -453,9 +445,9 @@ public function testRenderWithLang(): void
    HTML, - LineEndingNormalizer::normalize( - Article::tag()->lang('es')->render(), - ), + Article::tag() + ->lang('es') + ->render(), "Failed asserting that element renders correctly with 'lang' attribute.", ); } @@ -467,9 +459,9 @@ public function testRenderWithLangUsingEnum(): void
    HTML, - LineEndingNormalizer::normalize( - Article::tag()->lang(Language::SPANISH)->render(), - ), + Article::tag() + ->lang(Language::SPANISH) + ->render(), "Failed asserting that element renders correctly with 'lang' attribute using enum.", ); } @@ -481,15 +473,13 @@ public function testRenderWithMicroData(): void
    HTML, - LineEndingNormalizer::normalize( - Article::tag() - ->itemId('https://example.com/item') - ->itemProp('name') - ->itemRef('info') - ->itemScope(true) - ->itemType('https://schema.org/Thing') - ->render(), - ), + Article::tag() + ->itemId('https://example.com/item') + ->itemProp('name') + ->itemRef('info') + ->itemScope(true) + ->itemType('https://schema.org/Thing') + ->render(), 'Failed asserting that element renders correctly with microdata attributes.', ); } @@ -501,12 +491,10 @@ public function testRenderWithRemoveAriaAttribute(): void
    HTML, - LineEndingNormalizer::normalize( - Article::tag() - ->addAriaAttribute('label', 'Close') - ->removeAriaAttribute('label') - ->render(), - ), + Article::tag() + ->addAriaAttribute('label', 'Close') + ->removeAriaAttribute('label') + ->render(), "Failed asserting that element renders correctly with 'removeAriaAttribute()' method.", ); } @@ -518,12 +506,10 @@ public function testRenderWithRemoveAttribute(): void
    HTML, - LineEndingNormalizer::normalize( - Article::tag() - ->addAttribute('data-test', 'value') - ->removeAttribute('data-test') - ->render(), - ), + Article::tag() + ->addAttribute('data-test', 'value') + ->removeAttribute('data-test') + ->render(), "Failed asserting that element renders correctly with 'removeAttribute()' method.", ); } @@ -535,12 +521,10 @@ public function testRenderWithRemoveDataAttribute(): void
    HTML, - LineEndingNormalizer::normalize( - Article::tag() - ->addDataAttribute('value', 'test') - ->removeDataAttribute('value') - ->render(), - ), + Article::tag() + ->addDataAttribute('value', 'test') + ->removeDataAttribute('value') + ->render(), "Failed asserting that element renders correctly with 'removeDataAttribute()' method.", ); } @@ -552,9 +536,9 @@ public function testRenderWithRole(): void
    HTML, - LineEndingNormalizer::normalize( - Article::tag()->role('article')->render(), - ), + Article::tag() + ->role('article') + ->render(), "Failed asserting that element renders correctly with 'role' attribute.", ); } @@ -566,9 +550,9 @@ public function testRenderWithRoleUsingEnum(): void
    HTML, - LineEndingNormalizer::normalize( - Article::tag()->role(Role::ARTICLE)->render(), - ), + Article::tag() + ->role(Role::ARTICLE) + ->render(), "Failed asserting that element renders correctly with 'role' attribute using enum.", ); } @@ -580,9 +564,9 @@ public function testRenderWithSpellcheck(): void
    HTML, - LineEndingNormalizer::normalize( - Article::tag()->spellcheck(true)->render(), - ), + Article::tag() + ->spellcheck(true) + ->render(), "Failed asserting that element renders correctly with 'spellcheck' attribute.", ); } @@ -594,9 +578,9 @@ public function testRenderWithStyle(): void
    HTML, - LineEndingNormalizer::normalize( - Article::tag()->style('value')->render(), - ), + Article::tag() + ->style('value') + ->render(), "Failed asserting that element renders correctly with 'style' attribute.", ); } @@ -608,9 +592,9 @@ public function testRenderWithTabindex(): void
    HTML, - LineEndingNormalizer::normalize( - Article::tag()->tabIndex(3)->render(), - ), + Article::tag() + ->tabIndex(3) + ->render(), "Failed asserting that element renders correctly with 'tabindex' attribute.", ); } @@ -622,9 +606,9 @@ public function testRenderWithThemeProvider(): void
    HTML, - LineEndingNormalizer::normalize( - Article::tag()->addThemeProvider('muted', DefaultThemeProvider::class)->render(), - ), + Article::tag() + ->addThemeProvider('muted', DefaultThemeProvider::class) + ->render(), "Failed asserting that element renders correctly with 'addThemeProvider()' method.", ); } @@ -648,9 +632,7 @@ public function testRenderWithToString(): void
    HTML, - LineEndingNormalizer::normalize( - (string) Article::tag(), - ), + (string) Article::tag(), "Failed asserting that '__toString()' method renders correctly.", ); } @@ -662,9 +644,9 @@ public function testRenderWithTranslate(): void
    HTML, - LineEndingNormalizer::normalize( - Article::tag()->translate(false)->render(), - ), + Article::tag() + ->translate(false) + ->render(), "Failed asserting that element renders correctly with 'translate' attribute.", ); } @@ -676,9 +658,9 @@ public function testRenderWithTranslateUsingEnum(): void
    HTML, - LineEndingNormalizer::normalize( - Article::tag()->translate(Translate::NO)->render(), - ), + Article::tag() + ->translate(Translate::NO) + ->render(), "Failed asserting that element renders correctly with 'translate' attribute using enum.", ); } @@ -692,9 +674,7 @@ public function testRenderWithUserOverridesGlobalDefaults(): void
    HTML, - LineEndingNormalizer::normalize( - Article::tag(['id' => 'id-user'])->render(), - ), + Article::tag(['id' => 'id-user'])->render(), 'Failed asserting that user-defined attributes override global defaults correctly.', ); diff --git a/tests/Sectioning/AsideTest.php b/tests/Sectioning/AsideTest.php index b7c3354..0fc448e 100644 --- a/tests/Sectioning/AsideTest.php +++ b/tests/Sectioning/AsideTest.php @@ -4,7 +4,6 @@ namespace UIAwesome\Html\Tests\Sectioning; -use PHPForge\Support\LineEndingNormalizer; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use UIAwesome\Html\Attribute\Values\{ @@ -34,17 +33,16 @@ * @copyright Copyright (C) 2026 Terabytesoftw. * @license https://opensource.org/license/bsd-3-clause BSD 3-Clause License. */ -#[Group('html')] #[Group('sectioning')] final class AsideTest extends TestCase { public function testContentEncodesValues(): void { - $aside = Aside::tag()->content(''); - self::assertSame( '<value>', - $aside->getContent(), + Aside::tag() + ->content('') + ->getContent(), "Failed asserting that 'content()' method encodes values correctly.", ); } @@ -62,7 +60,9 @@ public function testGetAttributesReturnsAssignedAttributes(): void { self::assertSame( ['data-test' => 'value'], - Aside::tag()->addAttribute('data-test', 'value')->getAttributes(), + Aside::tag() + ->addAttribute('data-test', 'value') + ->getAttributes(), "Failed asserting that 'getAttributes()' returns the assigned attributes.", ); } @@ -75,9 +75,9 @@ public function testHtmlDoesNotEncodeValues(): void HTML, - LineEndingNormalizer::normalize( - Aside::tag()->html('')->render(), - ), + Aside::tag() + ->html('') + ->render(), "Failed asserting that element renders correctly with 'html()' method.", ); } @@ -89,9 +89,9 @@ public function testRenderWithAccesskey(): void HTML, - LineEndingNormalizer::normalize( - Aside::tag()->accesskey('k')->render(), - ), + Aside::tag() + ->accesskey('k') + ->render(), "Failed asserting that element renders correctly with 'accesskey' attribute.", ); } @@ -103,9 +103,9 @@ public function testRenderWithAddAriaAttribute(): void HTML, - LineEndingNormalizer::normalize( - Aside::tag()->addAriaAttribute('pressed', true)->render(), - ), + Aside::tag() + ->addAriaAttribute('pressed', true) + ->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method.", ); } @@ -117,9 +117,9 @@ public function testRenderWithAddAriaAttributeUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - Aside::tag()->addAriaAttribute(Aria::PRESSED, true)->render(), - ), + Aside::tag() + ->addAriaAttribute(Aria::PRESSED, true) + ->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method.", ); } @@ -131,9 +131,9 @@ public function testRenderWithAddAttribute(): void HTML, - LineEndingNormalizer::normalize( - Aside::tag()->addAttribute('data-test', 'value')->render(), - ), + Aside::tag() + ->addAttribute('data-test', 'value') + ->render(), "Failed asserting that element renders correctly with 'addAttribute()' method.", ); } @@ -145,9 +145,9 @@ public function testRenderWithAddAttributeUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - Aside::tag()->addAttribute(GlobalAttribute::TITLE, 'value')->render(), - ), + Aside::tag() + ->addAttribute(GlobalAttribute::TITLE, 'value') + ->render(), "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", ); } @@ -159,9 +159,9 @@ public function testRenderWithAddDataAttribute(): void HTML, - LineEndingNormalizer::normalize( - Aside::tag()->addDataAttribute('value', 'value')->render(), - ), + Aside::tag() + ->addDataAttribute('value', 'value') + ->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method.", ); } @@ -173,9 +173,9 @@ public function testRenderWithAddDataAttributeUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - Aside::tag()->addDataAttribute(Data::VALUE, 'value')->render(), - ), + Aside::tag() + ->addDataAttribute(Data::VALUE, 'value') + ->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method.", ); } @@ -187,17 +187,15 @@ public function testRenderWithAriaAttributes(): void HTML, - LineEndingNormalizer::normalize( - Aside::tag() - ->ariaAttributes( - [ - 'controls' => static fn(): string => 'modal-1', - 'hidden' => false, - 'label' => 'Close', - ], - ) - ->render(), - ), + Aside::tag() + ->ariaAttributes( + [ + 'controls' => static fn(): string => 'modal-1', + 'hidden' => false, + 'label' => 'Close', + ], + ) + ->render(), "Failed asserting that element renders correctly with 'ariaAttributes()' method.", ); } @@ -209,9 +207,9 @@ public function testRenderWithAttributes(): void HTML, - LineEndingNormalizer::normalize( - Aside::tag()->attributes(['class' => 'value'])->render(), - ), + Aside::tag() + ->attributes(['class' => 'value']) + ->render(), "Failed asserting that element renders correctly with 'attributes()' method.", ); } @@ -223,9 +221,9 @@ public function testRenderWithAutofocus(): void HTML, - LineEndingNormalizer::normalize( - Aside::tag()->autofocus(true)->render(), - ), + Aside::tag() + ->autofocus(true) + ->render(), "Failed asserting that element renders correctly with 'autofocus' attribute.", ); } @@ -238,9 +236,7 @@ public function testRenderWithBeginEnd(): void Content HTML, - LineEndingNormalizer::normalize( - Aside::tag()->begin() . 'Content' . Aside::end(), - ), + Aside::tag()->begin() . 'Content' . Aside::end(), "Failed asserting that element renders correctly with 'begin()' and 'end()' methods.", ); } @@ -252,9 +248,9 @@ public function testRenderWithClass(): void HTML, - LineEndingNormalizer::normalize( - Aside::tag()->class('value')->render(), - ), + Aside::tag() + ->class('value') + ->render(), "Failed asserting that element renders correctly with 'class' attribute.", ); } @@ -267,9 +263,9 @@ public function testRenderWithContent(): void value HTML, - LineEndingNormalizer::normalize( - Aside::tag()->content('value')->render(), - ), + Aside::tag() + ->content('value') + ->render(), 'Failed asserting that element renders correctly with default values.', ); } @@ -281,9 +277,9 @@ public function testRenderWithContentEditable(): void HTML, - LineEndingNormalizer::normalize( - Aside::tag()->contentEditable(true)->render(), - ), + Aside::tag() + ->contentEditable(true) + ->render(), "Failed asserting that element renders correctly with 'contentEditable' attribute.", ); } @@ -295,9 +291,9 @@ public function testRenderWithContentEditableUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - Aside::tag()->contentEditable(ContentEditable::TRUE)->render(), - ), + Aside::tag() + ->contentEditable(ContentEditable::TRUE) + ->render(), "Failed asserting that element renders correctly with 'contentEditable' attribute using enum.", ); } @@ -309,9 +305,9 @@ public function testRenderWithDataAttributes(): void HTML, - LineEndingNormalizer::normalize( - Aside::tag()->dataAttributes(['value' => 'value'])->render(), - ), + Aside::tag() + ->dataAttributes(['value' => 'value']) + ->render(), "Failed asserting that element renders correctly with 'dataAttributes()' method.", ); } @@ -323,9 +319,7 @@ public function testRenderWithDefaultConfigurationValues(): void HTML, - LineEndingNormalizer::normalize( - Aside::tag(['class' => 'default-class'])->render(), - ), + Aside::tag(['class' => 'default-class'])->render(), 'Failed asserting that default configuration values are applied correctly.', ); } @@ -337,9 +331,9 @@ public function testRenderWithDefaultProvider(): void HTML, - LineEndingNormalizer::normalize( - Aside::tag()->addDefaultProvider(DefaultProvider::class)->render(), - ), + Aside::tag() + ->addDefaultProvider(DefaultProvider::class) + ->render(), 'Failed asserting that default provider is applied correctly.', ); } @@ -351,9 +345,9 @@ public function testRenderWithDir(): void HTML, - LineEndingNormalizer::normalize( - Aside::tag()->dir('ltr')->render(), - ), + Aside::tag() + ->dir('ltr') + ->render(), "Failed asserting that element renders correctly with 'dir' attribute.", ); } @@ -365,9 +359,9 @@ public function testRenderWithDirUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - Aside::tag()->dir(Direction::LTR)->render(), - ), + Aside::tag() + ->dir(Direction::LTR) + ->render(), "Failed asserting that element renders correctly with 'dir' attribute using enum.", ); } @@ -379,9 +373,9 @@ public function testRenderWithDraggable(): void HTML, - LineEndingNormalizer::normalize( - Aside::tag()->draggable(true)->render(), - ), + Aside::tag() + ->draggable(true) + ->render(), "Failed asserting that element renders correctly with 'draggable' attribute.", ); } @@ -393,9 +387,9 @@ public function testRenderWithDraggableUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - Aside::tag()->draggable(Draggable::TRUE)->render(), - ), + Aside::tag() + ->draggable(Draggable::TRUE) + ->render(), "Failed asserting that element renders correctly with 'draggable' attribute using enum.", ); } @@ -409,9 +403,7 @@ public function testRenderWithGlobalDefaultsAreApplied(): void HTML, - LineEndingNormalizer::normalize( - Aside::tag()->render(), - ), + Aside::tag()->render(), 'Failed asserting that global defaults are applied correctly.', ); @@ -425,9 +417,9 @@ public function testRenderWithHidden(): void HTML, - LineEndingNormalizer::normalize( - Aside::tag()->hidden(true)->render(), - ), + Aside::tag() + ->hidden(true) + ->render(), "Failed asserting that element renders correctly with 'hidden' attribute.", ); } @@ -439,9 +431,9 @@ public function testRenderWithId(): void HTML, - LineEndingNormalizer::normalize( - Aside::tag()->id('test-id')->render(), - ), + Aside::tag() + ->id('test-id') + ->render(), "Failed asserting that element renders correctly with 'id' attribute.", ); } @@ -453,9 +445,9 @@ public function testRenderWithLang(): void HTML, - LineEndingNormalizer::normalize( - Aside::tag()->lang('es')->render(), - ), + Aside::tag() + ->lang('es') + ->render(), "Failed asserting that element renders correctly with 'lang' attribute.", ); } @@ -467,9 +459,9 @@ public function testRenderWithLangUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - Aside::tag()->lang(Language::SPANISH)->render(), - ), + Aside::tag() + ->lang(Language::SPANISH) + ->render(), "Failed asserting that element renders correctly with 'lang' attribute using enum.", ); } @@ -481,15 +473,13 @@ public function testRenderWithMicroData(): void HTML, - LineEndingNormalizer::normalize( - Aside::tag() - ->itemId('https://example.com/item') - ->itemProp('name') - ->itemRef('info') - ->itemScope(true) - ->itemType('https://schema.org/Thing') - ->render(), - ), + Aside::tag() + ->itemId('https://example.com/item') + ->itemProp('name') + ->itemRef('info') + ->itemScope(true) + ->itemType('https://schema.org/Thing') + ->render(), 'Failed asserting that element renders correctly with microdata attributes.', ); } @@ -501,12 +491,10 @@ public function testRenderWithRemoveAriaAttribute(): void HTML, - LineEndingNormalizer::normalize( - Aside::tag() - ->addAriaAttribute('label', 'Close') - ->removeAriaAttribute('label') - ->render(), - ), + Aside::tag() + ->addAriaAttribute('label', 'Close') + ->removeAriaAttribute('label') + ->render(), "Failed asserting that element renders correctly with 'removeAriaAttribute()' method.", ); } @@ -518,12 +506,10 @@ public function testRenderWithRemoveAttribute(): void HTML, - LineEndingNormalizer::normalize( - Aside::tag() - ->addAttribute('data-test', 'value') - ->removeAttribute('data-test') - ->render(), - ), + Aside::tag() + ->addAttribute('data-test', 'value') + ->removeAttribute('data-test') + ->render(), "Failed asserting that element renders correctly with 'removeAttribute()' method.", ); } @@ -535,12 +521,10 @@ public function testRenderWithRemoveDataAttribute(): void HTML, - LineEndingNormalizer::normalize( - Aside::tag() - ->addDataAttribute('value', 'test') - ->removeDataAttribute('value') - ->render(), - ), + Aside::tag() + ->addDataAttribute('value', 'test') + ->removeDataAttribute('value') + ->render(), "Failed asserting that element renders correctly with 'removeDataAttribute()' method.", ); } @@ -552,9 +536,9 @@ public function testRenderWithRole(): void HTML, - LineEndingNormalizer::normalize( - Aside::tag()->role('complementary')->render(), - ), + Aside::tag() + ->role('complementary') + ->render(), "Failed asserting that element renders correctly with 'role' attribute.", ); } @@ -566,9 +550,9 @@ public function testRenderWithRoleUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - Aside::tag()->role(Role::COMPLEMENTARY)->render(), - ), + Aside::tag() + ->role(Role::COMPLEMENTARY) + ->render(), "Failed asserting that element renders correctly with 'role' attribute using enum.", ); } @@ -580,9 +564,9 @@ public function testRenderWithSpellcheck(): void HTML, - LineEndingNormalizer::normalize( - Aside::tag()->spellcheck(true)->render(), - ), + Aside::tag() + ->spellcheck(true) + ->render(), "Failed asserting that element renders correctly with 'spellcheck' attribute.", ); } @@ -594,9 +578,9 @@ public function testRenderWithStyle(): void HTML, - LineEndingNormalizer::normalize( - Aside::tag()->style('value')->render(), - ), + Aside::tag() + ->style('value') + ->render(), "Failed asserting that element renders correctly with 'style' attribute.", ); } @@ -608,9 +592,9 @@ public function testRenderWithTabindex(): void HTML, - LineEndingNormalizer::normalize( - Aside::tag()->tabIndex(3)->render(), - ), + Aside::tag() + ->tabIndex(3) + ->render(), "Failed asserting that element renders correctly with 'tabindex' attribute.", ); } @@ -622,9 +606,9 @@ public function testRenderWithThemeProvider(): void HTML, - LineEndingNormalizer::normalize( - Aside::tag()->addThemeProvider('muted', DefaultThemeProvider::class)->render(), - ), + Aside::tag() + ->addThemeProvider('muted', DefaultThemeProvider::class) + ->render(), "Failed asserting that element renders correctly with 'addThemeProvider()' method.", ); } @@ -636,7 +620,9 @@ public function testRenderWithTitle(): void HTML, - Aside::tag()->title('value')->render(), + Aside::tag() + ->title('value') + ->render(), "Failed asserting that element renders correctly with 'title' attribute.", ); } @@ -648,9 +634,7 @@ public function testRenderWithToString(): void HTML, - LineEndingNormalizer::normalize( - (string) Aside::tag(), - ), + (string) Aside::tag(), "Failed asserting that '__toString()' method renders correctly.", ); } @@ -662,9 +646,9 @@ public function testRenderWithTranslate(): void HTML, - LineEndingNormalizer::normalize( - Aside::tag()->translate(false)->render(), - ), + Aside::tag() + ->translate(false) + ->render(), "Failed asserting that element renders correctly with 'translate' attribute.", ); } @@ -676,9 +660,9 @@ public function testRenderWithTranslateUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - Aside::tag()->translate(Translate::NO)->render(), - ), + Aside::tag() + ->translate(Translate::NO) + ->render(), "Failed asserting that element renders correctly with 'translate' attribute using enum.", ); } @@ -692,9 +676,7 @@ public function testRenderWithUserOverridesGlobalDefaults(): void HTML, - LineEndingNormalizer::normalize( - Aside::tag(['id' => 'id-user'])->render(), - ), + Aside::tag(['id' => 'id-user'])->render(), 'Failed asserting that user-defined attributes override global defaults correctly.', ); diff --git a/tests/Sectioning/NavTest.php b/tests/Sectioning/NavTest.php index 1b3b633..1afd8d2 100644 --- a/tests/Sectioning/NavTest.php +++ b/tests/Sectioning/NavTest.php @@ -4,7 +4,6 @@ namespace UIAwesome\Html\Tests\Sectioning; -use PHPForge\Support\LineEndingNormalizer; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use UIAwesome\Html\Attribute\Values\{ @@ -34,17 +33,16 @@ * @copyright Copyright (C) 2026 Terabytesoftw. * @license https://opensource.org/license/bsd-3-clause BSD 3-Clause License. */ -#[Group('html')] #[Group('sectioning')] final class NavTest extends TestCase { public function testContentEncodesValues(): void { - $nav = Nav::tag()->content(''); - self::assertSame( '<value>', - $nav->getContent(), + Nav::tag() + ->content('') + ->getContent(), "Failed asserting that 'content()' method encodes values correctly.", ); } @@ -62,7 +60,9 @@ public function testGetAttributesReturnsAssignedAttributes(): void { self::assertSame( ['data-test' => 'value'], - Nav::tag()->addAttribute('data-test', 'value')->getAttributes(), + Nav::tag() + ->addAttribute('data-test', 'value') + ->getAttributes(), "Failed asserting that 'getAttributes()' returns the assigned attributes.", ); } @@ -75,9 +75,9 @@ public function testHtmlDoesNotEncodeValues(): void HTML, - LineEndingNormalizer::normalize( - Nav::tag()->html('')->render(), - ), + Nav::tag() + ->html('') + ->render(), "Failed asserting that element renders correctly with 'html()' method.", ); } @@ -89,9 +89,9 @@ public function testRenderWithAccesskey(): void HTML, - LineEndingNormalizer::normalize( - Nav::tag()->accesskey('k')->render(), - ), + Nav::tag() + ->accesskey('k') + ->render(), "Failed asserting that element renders correctly with 'accesskey' attribute.", ); } @@ -103,9 +103,9 @@ public function testRenderWithAddAriaAttribute(): void HTML, - LineEndingNormalizer::normalize( - Nav::tag()->addAriaAttribute('pressed', true)->render(), - ), + Nav::tag() + ->addAriaAttribute('pressed', true) + ->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method.", ); } @@ -117,9 +117,9 @@ public function testRenderWithAddAriaAttributeUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - Nav::tag()->addAriaAttribute(Aria::PRESSED, true)->render(), - ), + Nav::tag() + ->addAriaAttribute(Aria::PRESSED, true) + ->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method.", ); } @@ -131,9 +131,9 @@ public function testRenderWithAddAttribute(): void HTML, - LineEndingNormalizer::normalize( - Nav::tag()->addAttribute('data-test', 'value')->render(), - ), + Nav::tag() + ->addAttribute('data-test', 'value') + ->render(), "Failed asserting that element renders correctly with 'addAttribute()' method.", ); } @@ -145,9 +145,9 @@ public function testRenderWithAddAttributeUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - Nav::tag()->addAttribute(GlobalAttribute::TITLE, 'value')->render(), - ), + Nav::tag() + ->addAttribute(GlobalAttribute::TITLE, 'value') + ->render(), "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", ); } @@ -159,9 +159,9 @@ public function testRenderWithAddDataAttribute(): void HTML, - LineEndingNormalizer::normalize( - Nav::tag()->addDataAttribute('value', 'value')->render(), - ), + Nav::tag() + ->addDataAttribute('value', 'value') + ->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method.", ); } @@ -173,9 +173,9 @@ public function testRenderWithAddDataAttributeUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - Nav::tag()->addDataAttribute(Data::VALUE, 'value')->render(), - ), + Nav::tag() + ->addDataAttribute(Data::VALUE, 'value') + ->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method.", ); } @@ -187,17 +187,15 @@ public function testRenderWithAriaAttributes(): void HTML, - LineEndingNormalizer::normalize( - Nav::tag() - ->ariaAttributes( - [ - 'controls' => static fn(): string => 'modal-1', - 'hidden' => false, - 'label' => 'Close', - ], - ) - ->render(), - ), + Nav::tag() + ->ariaAttributes( + [ + 'controls' => static fn(): string => 'modal-1', + 'hidden' => false, + 'label' => 'Close', + ], + ) + ->render(), "Failed asserting that element renders correctly with 'ariaAttributes()' method.", ); } @@ -209,9 +207,9 @@ public function testRenderWithAttributes(): void HTML, - LineEndingNormalizer::normalize( - Nav::tag()->attributes(['class' => 'value'])->render(), - ), + Nav::tag() + ->attributes(['class' => 'value']) + ->render(), "Failed asserting that element renders correctly with 'attributes()' method.", ); } @@ -223,9 +221,9 @@ public function testRenderWithAutofocus(): void HTML, - LineEndingNormalizer::normalize( - Nav::tag()->autofocus(true)->render(), - ), + Nav::tag() + ->autofocus(true) + ->render(), "Failed asserting that element renders correctly with 'autofocus' attribute.", ); } @@ -238,9 +236,7 @@ public function testRenderWithBeginEnd(): void Content HTML, - LineEndingNormalizer::normalize( - Nav::tag()->begin() . 'Content' . Nav::end(), - ), + Nav::tag()->begin() . 'Content' . Nav::end(), "Failed asserting that element renders correctly with 'begin()' and 'end()' methods.", ); } @@ -252,9 +248,9 @@ public function testRenderWithClass(): void HTML, - LineEndingNormalizer::normalize( - Nav::tag()->class('value')->render(), - ), + Nav::tag() + ->class('value') + ->render(), "Failed asserting that element renders correctly with 'class' attribute.", ); } @@ -267,9 +263,9 @@ public function testRenderWithContent(): void value HTML, - LineEndingNormalizer::normalize( - Nav::tag()->content('value')->render(), - ), + Nav::tag() + ->content('value') + ->render(), 'Failed asserting that element renders correctly with default values.', ); } @@ -281,9 +277,9 @@ public function testRenderWithContentEditable(): void HTML, - LineEndingNormalizer::normalize( - Nav::tag()->contentEditable(true)->render(), - ), + Nav::tag() + ->contentEditable(true) + ->render(), "Failed asserting that element renders correctly with 'contentEditable' attribute.", ); } @@ -295,9 +291,9 @@ public function testRenderWithContentEditableUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - Nav::tag()->contentEditable(ContentEditable::TRUE)->render(), - ), + Nav::tag() + ->contentEditable(ContentEditable::TRUE) + ->render(), "Failed asserting that element renders correctly with 'contentEditable' attribute using enum.", ); } @@ -309,9 +305,9 @@ public function testRenderWithDataAttributes(): void HTML, - LineEndingNormalizer::normalize( - Nav::tag()->dataAttributes(['value' => 'value'])->render(), - ), + Nav::tag() + ->dataAttributes(['value' => 'value']) + ->render(), "Failed asserting that element renders correctly with 'dataAttributes()' method.", ); } @@ -323,9 +319,7 @@ public function testRenderWithDefaultConfigurationValues(): void HTML, - LineEndingNormalizer::normalize( - Nav::tag(['class' => 'default-class'])->render(), - ), + Nav::tag(['class' => 'default-class'])->render(), 'Failed asserting that default configuration values are applied correctly.', ); } @@ -337,9 +331,9 @@ public function testRenderWithDefaultProvider(): void HTML, - LineEndingNormalizer::normalize( - Nav::tag()->addDefaultProvider(DefaultProvider::class)->render(), - ), + Nav::tag() + ->addDefaultProvider(DefaultProvider::class) + ->render(), 'Failed asserting that default provider is applied correctly.', ); } @@ -351,9 +345,9 @@ public function testRenderWithDir(): void HTML, - LineEndingNormalizer::normalize( - Nav::tag()->dir('ltr')->render(), - ), + Nav::tag() + ->dir('ltr') + ->render(), "Failed asserting that element renders correctly with 'dir' attribute.", ); } @@ -365,9 +359,9 @@ public function testRenderWithDirUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - Nav::tag()->dir(Direction::LTR)->render(), - ), + Nav::tag() + ->dir(Direction::LTR) + ->render(), "Failed asserting that element renders correctly with 'dir' attribute using enum.", ); } @@ -379,9 +373,9 @@ public function testRenderWithDraggable(): void HTML, - LineEndingNormalizer::normalize( - Nav::tag()->draggable(true)->render(), - ), + Nav::tag() + ->draggable(true) + ->render(), "Failed asserting that element renders correctly with 'draggable' attribute.", ); } @@ -393,9 +387,9 @@ public function testRenderWithDraggableUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - Nav::tag()->draggable(Draggable::TRUE)->render(), - ), + Nav::tag() + ->draggable(Draggable::TRUE) + ->render(), "Failed asserting that element renders correctly with 'draggable' attribute using enum.", ); } @@ -409,9 +403,7 @@ public function testRenderWithGlobalDefaultsAreApplied(): void HTML, - LineEndingNormalizer::normalize( - Nav::tag()->render(), - ), + Nav::tag()->render(), 'Failed asserting that global defaults are applied correctly.', ); @@ -425,9 +417,9 @@ public function testRenderWithHidden(): void HTML, - LineEndingNormalizer::normalize( - Nav::tag()->hidden(true)->render(), - ), + Nav::tag() + ->hidden(true) + ->render(), "Failed asserting that element renders correctly with 'hidden' attribute.", ); } @@ -439,9 +431,9 @@ public function testRenderWithId(): void HTML, - LineEndingNormalizer::normalize( - Nav::tag()->id('test-id')->render(), - ), + Nav::tag() + ->id('test-id') + ->render(), "Failed asserting that element renders correctly with 'id' attribute.", ); } @@ -453,9 +445,9 @@ public function testRenderWithLang(): void HTML, - LineEndingNormalizer::normalize( - Nav::tag()->lang('es')->render(), - ), + Nav::tag() + ->lang('es') + ->render(), "Failed asserting that element renders correctly with 'lang' attribute.", ); } @@ -467,9 +459,9 @@ public function testRenderWithLangUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - Nav::tag()->lang(Language::SPANISH)->render(), - ), + Nav::tag() + ->lang(Language::SPANISH) + ->render(), "Failed asserting that element renders correctly with 'lang' attribute using enum.", ); } @@ -481,15 +473,13 @@ public function testRenderWithMicroData(): void HTML, - LineEndingNormalizer::normalize( - Nav::tag() - ->itemId('https://example.com/item') - ->itemProp('name') - ->itemRef('info') - ->itemScope(true) - ->itemType('https://schema.org/Thing') - ->render(), - ), + Nav::tag() + ->itemId('https://example.com/item') + ->itemProp('name') + ->itemRef('info') + ->itemScope(true) + ->itemType('https://schema.org/Thing') + ->render(), 'Failed asserting that element renders correctly with microdata attributes.', ); } @@ -501,12 +491,10 @@ public function testRenderWithRemoveAriaAttribute(): void HTML, - LineEndingNormalizer::normalize( - Nav::tag() - ->addAriaAttribute('label', 'Close') - ->removeAriaAttribute('label') - ->render(), - ), + Nav::tag() + ->addAriaAttribute('label', 'Close') + ->removeAriaAttribute('label') + ->render(), "Failed asserting that element renders correctly with 'removeAriaAttribute()' method.", ); } @@ -518,12 +506,10 @@ public function testRenderWithRemoveAttribute(): void HTML, - LineEndingNormalizer::normalize( - Nav::tag() - ->addAttribute('data-test', 'value') - ->removeAttribute('data-test') - ->render(), - ), + Nav::tag() + ->addAttribute('data-test', 'value') + ->removeAttribute('data-test') + ->render(), "Failed asserting that element renders correctly with 'removeAttribute()' method.", ); } @@ -535,12 +521,10 @@ public function testRenderWithRemoveDataAttribute(): void HTML, - LineEndingNormalizer::normalize( - Nav::tag() - ->addDataAttribute('value', 'test') - ->removeDataAttribute('value') - ->render(), - ), + Nav::tag() + ->addDataAttribute('value', 'test') + ->removeDataAttribute('value') + ->render(), "Failed asserting that element renders correctly with 'removeDataAttribute()' method.", ); } @@ -552,9 +536,9 @@ public function testRenderWithRole(): void HTML, - LineEndingNormalizer::normalize( - Nav::tag()->role('navigation')->render(), - ), + Nav::tag() + ->role('navigation') + ->render(), "Failed asserting that element renders correctly with 'role' attribute.", ); } @@ -566,9 +550,9 @@ public function testRenderWithRoleUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - Nav::tag()->role(Role::NAVIGATION)->render(), - ), + Nav::tag() + ->role(Role::NAVIGATION) + ->render(), "Failed asserting that element renders correctly with 'role' attribute using enum.", ); } @@ -580,9 +564,9 @@ public function testRenderWithSpellcheck(): void HTML, - LineEndingNormalizer::normalize( - Nav::tag()->spellcheck(true)->render(), - ), + Nav::tag() + ->spellcheck(true) + ->render(), "Failed asserting that element renders correctly with 'spellcheck' attribute.", ); } @@ -594,9 +578,9 @@ public function testRenderWithStyle(): void HTML, - LineEndingNormalizer::normalize( - Nav::tag()->style('value')->render(), - ), + Nav::tag() + ->style('value') + ->render(), "Failed asserting that element renders correctly with 'style' attribute.", ); } @@ -608,9 +592,9 @@ public function testRenderWithTabindex(): void HTML, - LineEndingNormalizer::normalize( - Nav::tag()->tabIndex(3)->render(), - ), + Nav::tag() + ->tabIndex(3) + ->render(), "Failed asserting that element renders correctly with 'tabindex' attribute.", ); } @@ -622,9 +606,9 @@ public function testRenderWithThemeProvider(): void HTML, - LineEndingNormalizer::normalize( - Nav::tag()->addThemeProvider('muted', DefaultThemeProvider::class)->render(), - ), + Nav::tag() + ->addThemeProvider('muted', DefaultThemeProvider::class) + ->render(), "Failed asserting that element renders correctly with 'addThemeProvider()' method.", ); } @@ -636,7 +620,9 @@ public function testRenderWithTitle(): void HTML, - Nav::tag()->title('value')->render(), + Nav::tag() + ->title('value') + ->render(), "Failed asserting that element renders correctly with 'title' attribute.", ); } @@ -648,9 +634,7 @@ public function testRenderWithToString(): void HTML, - LineEndingNormalizer::normalize( - (string) Nav::tag(), - ), + (string) Nav::tag(), "Failed asserting that '__toString()' method renders correctly.", ); } @@ -662,9 +646,9 @@ public function testRenderWithTranslate(): void HTML, - LineEndingNormalizer::normalize( - Nav::tag()->translate(false)->render(), - ), + Nav::tag() + ->translate(false) + ->render(), "Failed asserting that element renders correctly with 'translate' attribute.", ); } @@ -676,9 +660,9 @@ public function testRenderWithTranslateUsingEnum(): void HTML, - LineEndingNormalizer::normalize( - Nav::tag()->translate(Translate::NO)->render(), - ), + Nav::tag() + ->translate(Translate::NO) + ->render(), "Failed asserting that element renders correctly with 'translate' attribute using enum.", ); } @@ -692,9 +676,7 @@ public function testRenderWithUserOverridesGlobalDefaults(): void HTML, - LineEndingNormalizer::normalize( - Nav::tag(['id' => 'id-user'])->render(), - ), + Nav::tag(['id' => 'id-user'])->render(), 'Failed asserting that user-defined attributes override global defaults correctly.', ); diff --git a/tests/Sectioning/SectionTest.php b/tests/Sectioning/SectionTest.php index 099e112..fd5c210 100644 --- a/tests/Sectioning/SectionTest.php +++ b/tests/Sectioning/SectionTest.php @@ -4,7 +4,6 @@ namespace UIAwesome\Html\Tests\Sectioning; -use PHPForge\Support\LineEndingNormalizer; use PHPUnit\Framework\Attributes\Group; use PHPUnit\Framework\TestCase; use UIAwesome\Html\Attribute\Values\{ @@ -34,17 +33,16 @@ * @copyright Copyright (C) 2026 Terabytesoftw. * @license https://opensource.org/license/bsd-3-clause BSD 3-Clause License. */ -#[Group('html')] #[Group('sectioning')] final class SectionTest extends TestCase { public function testContentEncodesValues(): void { - $section = Section::tag()->content(''); - self::assertSame( '<value>', - $section->getContent(), + Section::tag() + ->content('') + ->getContent(), "Failed asserting that 'content()' method encodes values correctly.", ); } @@ -62,7 +60,9 @@ public function testGetAttributesReturnsAssignedAttributes(): void { self::assertSame( ['data-test' => 'value'], - Section::tag()->addAttribute('data-test', 'value')->getAttributes(), + Section::tag() + ->addAttribute('data-test', 'value') + ->getAttributes(), "Failed asserting that 'getAttributes()' returns the assigned attributes.", ); } @@ -75,9 +75,9 @@ public function testHtmlDoesNotEncodeValues(): void HTML, - LineEndingNormalizer::normalize( - Section::tag()->html('')->render(), - ), + Section::tag() + ->html('') + ->render(), "Failed asserting that element renders correctly with 'html()' method.", ); } @@ -89,9 +89,9 @@ public function testRenderWithAccesskey(): void
    HTML, - LineEndingNormalizer::normalize( - Section::tag()->accesskey('k')->render(), - ), + Section::tag() + ->accesskey('k') + ->render(), "Failed asserting that element renders correctly with 'accesskey' attribute.", ); } @@ -103,9 +103,9 @@ public function testRenderWithAddAriaAttribute(): void
    HTML, - LineEndingNormalizer::normalize( - Section::tag()->addAriaAttribute('pressed', true)->render(), - ), + Section::tag() + ->addAriaAttribute('pressed', true) + ->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method.", ); } @@ -117,9 +117,9 @@ public function testRenderWithAddAriaAttributeUsingEnum(): void
    HTML, - LineEndingNormalizer::normalize( - Section::tag()->addAriaAttribute(Aria::PRESSED, true)->render(), - ), + Section::tag() + ->addAriaAttribute(Aria::PRESSED, true) + ->render(), "Failed asserting that element renders correctly with 'addAriaAttribute()' method.", ); } @@ -131,9 +131,9 @@ public function testRenderWithAddAttribute(): void
    HTML, - LineEndingNormalizer::normalize( - Section::tag()->addAttribute('data-test', 'value')->render(), - ), + Section::tag() + ->addAttribute('data-test', 'value') + ->render(), "Failed asserting that element renders correctly with 'addAttribute()' method.", ); } @@ -145,9 +145,9 @@ public function testRenderWithAddAttributeUsingEnum(): void
    HTML, - LineEndingNormalizer::normalize( - Section::tag()->addAttribute(GlobalAttribute::TITLE, 'value')->render(), - ), + Section::tag() + ->addAttribute(GlobalAttribute::TITLE, 'value') + ->render(), "Failed asserting that element renders correctly with 'addAttribute()' method using enum.", ); } @@ -159,9 +159,9 @@ public function testRenderWithAddDataAttribute(): void
    HTML, - LineEndingNormalizer::normalize( - Section::tag()->addDataAttribute('value', 'value')->render(), - ), + Section::tag() + ->addDataAttribute('value', 'value') + ->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method.", ); } @@ -173,9 +173,9 @@ public function testRenderWithAddDataAttributeUsingEnum(): void
    HTML, - LineEndingNormalizer::normalize( - Section::tag()->addDataAttribute(Data::VALUE, 'value')->render(), - ), + Section::tag() + ->addDataAttribute(Data::VALUE, 'value') + ->render(), "Failed asserting that element renders correctly with 'addDataAttribute()' method.", ); } @@ -187,17 +187,15 @@ public function testRenderWithAriaAttributes(): void
    HTML, - LineEndingNormalizer::normalize( - Section::tag() - ->ariaAttributes( - [ - 'controls' => static fn(): string => 'modal-1', - 'hidden' => false, - 'label' => 'Close', - ], - ) - ->render(), - ), + Section::tag() + ->ariaAttributes( + [ + 'controls' => static fn(): string => 'modal-1', + 'hidden' => false, + 'label' => 'Close', + ], + ) + ->render(), "Failed asserting that element renders correctly with 'ariaAttributes()' method.", ); } @@ -209,9 +207,9 @@ public function testRenderWithAttributes(): void
    HTML, - LineEndingNormalizer::normalize( - Section::tag()->attributes(['class' => 'value'])->render(), - ), + Section::tag() + ->attributes(['class' => 'value']) + ->render(), "Failed asserting that element renders correctly with 'attributes()' method.", ); } @@ -223,9 +221,9 @@ public function testRenderWithAutofocus(): void
    HTML, - LineEndingNormalizer::normalize( - Section::tag()->autofocus(true)->render(), - ), + Section::tag() + ->autofocus(true) + ->render(), "Failed asserting that element renders correctly with 'autofocus' attribute.", ); } @@ -238,9 +236,7 @@ public function testRenderWithBeginEnd(): void Content HTML, - LineEndingNormalizer::normalize( - Section::tag()->begin() . 'Content' . Section::end(), - ), + Section::tag()->begin() . 'Content' . Section::end(), "Failed asserting that element renders correctly with 'begin()' and 'end()' methods.", ); } @@ -252,9 +248,9 @@ public function testRenderWithClass(): void
    HTML, - LineEndingNormalizer::normalize( - Section::tag()->class('value')->render(), - ), + Section::tag() + ->class('value') + ->render(), "Failed asserting that element renders correctly with 'class' attribute.", ); } @@ -267,9 +263,9 @@ public function testRenderWithContent(): void value HTML, - LineEndingNormalizer::normalize( - Section::tag()->content('value')->render(), - ), + Section::tag() + ->content('value') + ->render(), 'Failed asserting that element renders correctly with default values.', ); } @@ -281,9 +277,9 @@ public function testRenderWithContentEditable(): void
    HTML, - LineEndingNormalizer::normalize( - Section::tag()->contentEditable(true)->render(), - ), + Section::tag() + ->contentEditable(true) + ->render(), "Failed asserting that element renders correctly with 'contentEditable' attribute.", ); } @@ -295,9 +291,9 @@ public function testRenderWithContentEditableUsingEnum(): void
    HTML, - LineEndingNormalizer::normalize( - Section::tag()->contentEditable(ContentEditable::TRUE)->render(), - ), + Section::tag() + ->contentEditable(ContentEditable::TRUE) + ->render(), "Failed asserting that element renders correctly with 'contentEditable' attribute using enum.", ); } @@ -309,9 +305,9 @@ public function testRenderWithDataAttributes(): void
    HTML, - LineEndingNormalizer::normalize( - Section::tag()->dataAttributes(['value' => 'value'])->render(), - ), + Section::tag() + ->dataAttributes(['value' => 'value']) + ->render(), "Failed asserting that element renders correctly with 'dataAttributes()' method.", ); } @@ -323,9 +319,7 @@ public function testRenderWithDefaultConfigurationValues(): void
    HTML, - LineEndingNormalizer::normalize( - Section::tag(['class' => 'default-class'])->render(), - ), + Section::tag(['class' => 'default-class'])->render(), 'Failed asserting that default configuration values are applied correctly.', ); } @@ -337,9 +331,9 @@ public function testRenderWithDefaultProvider(): void
    HTML, - LineEndingNormalizer::normalize( - Section::tag()->addDefaultProvider(DefaultProvider::class)->render(), - ), + Section::tag() + ->addDefaultProvider(DefaultProvider::class) + ->render(), 'Failed asserting that default provider is applied correctly.', ); } @@ -351,9 +345,9 @@ public function testRenderWithDir(): void
    HTML, - LineEndingNormalizer::normalize( - Section::tag()->dir('ltr')->render(), - ), + Section::tag() + ->dir('ltr') + ->render(), "Failed asserting that element renders correctly with 'dir' attribute.", ); } @@ -365,9 +359,9 @@ public function testRenderWithDirUsingEnum(): void
    HTML, - LineEndingNormalizer::normalize( - Section::tag()->dir(Direction::LTR)->render(), - ), + Section::tag() + ->dir(Direction::LTR) + ->render(), "Failed asserting that element renders correctly with 'dir' attribute using enum.", ); } @@ -379,9 +373,9 @@ public function testRenderWithDraggable(): void
    HTML, - LineEndingNormalizer::normalize( - Section::tag()->draggable(true)->render(), - ), + Section::tag() + ->draggable(true) + ->render(), "Failed asserting that element renders correctly with 'draggable' attribute.", ); } @@ -393,9 +387,9 @@ public function testRenderWithDraggableUsingEnum(): void
    HTML, - LineEndingNormalizer::normalize( - Section::tag()->draggable(Draggable::TRUE)->render(), - ), + Section::tag() + ->draggable(Draggable::TRUE) + ->render(), "Failed asserting that element renders correctly with 'draggable' attribute using enum.", ); } @@ -409,9 +403,7 @@ public function testRenderWithGlobalDefaultsAreApplied(): void
    HTML, - LineEndingNormalizer::normalize( - Section::tag()->render(), - ), + Section::tag()->render(), 'Failed asserting that global defaults are applied correctly.', ); @@ -425,9 +417,9 @@ public function testRenderWithHidden(): void HTML, - LineEndingNormalizer::normalize( - Section::tag()->hidden(true)->render(), - ), + Section::tag() + ->hidden(true) + ->render(), "Failed asserting that element renders correctly with 'hidden' attribute.", ); } @@ -439,9 +431,9 @@ public function testRenderWithId(): void
    HTML, - LineEndingNormalizer::normalize( - Section::tag()->id('test-id')->render(), - ), + Section::tag() + ->id('test-id') + ->render(), "Failed asserting that element renders correctly with 'id' attribute.", ); } @@ -453,9 +445,9 @@ public function testRenderWithLang(): void
    HTML, - LineEndingNormalizer::normalize( - Section::tag()->lang('es')->render(), - ), + Section::tag() + ->lang('es') + ->render(), "Failed asserting that element renders correctly with 'lang' attribute.", ); } @@ -467,9 +459,9 @@ public function testRenderWithLangUsingEnum(): void
    HTML, - LineEndingNormalizer::normalize( - Section::tag()->lang(Language::SPANISH)->render(), - ), + Section::tag() + ->lang(Language::SPANISH) + ->render(), "Failed asserting that element renders correctly with 'lang' attribute using enum.", ); } @@ -481,15 +473,13 @@ public function testRenderWithMicroData(): void
    HTML, - LineEndingNormalizer::normalize( - Section::tag() - ->itemId('https://example.com/item') - ->itemProp('name') - ->itemRef('info') - ->itemScope(true) - ->itemType('https://schema.org/Thing') - ->render(), - ), + Section::tag() + ->itemId('https://example.com/item') + ->itemProp('name') + ->itemRef('info') + ->itemScope(true) + ->itemType('https://schema.org/Thing') + ->render(), 'Failed asserting that element renders correctly with microdata attributes.', ); } @@ -501,12 +491,10 @@ public function testRenderWithRemoveAriaAttribute(): void
    HTML, - LineEndingNormalizer::normalize( - Section::tag() - ->addAriaAttribute('label', 'Close') - ->removeAriaAttribute('label') - ->render(), - ), + Section::tag() + ->addAriaAttribute('label', 'Close') + ->removeAriaAttribute('label') + ->render(), "Failed asserting that element renders correctly with 'removeAriaAttribute()' method.", ); } @@ -518,12 +506,10 @@ public function testRenderWithRemoveAttribute(): void
    HTML, - LineEndingNormalizer::normalize( - Section::tag() - ->addAttribute('data-test', 'value') - ->removeAttribute('data-test') - ->render(), - ), + Section::tag() + ->addAttribute('data-test', 'value') + ->removeAttribute('data-test') + ->render(), "Failed asserting that element renders correctly with 'removeAttribute()' method.", ); } @@ -535,12 +521,10 @@ public function testRenderWithRemoveDataAttribute(): void
    HTML, - LineEndingNormalizer::normalize( - Section::tag() - ->addDataAttribute('value', 'test') - ->removeDataAttribute('value') - ->render(), - ), + Section::tag() + ->addDataAttribute('value', 'test') + ->removeDataAttribute('value') + ->render(), "Failed asserting that element renders correctly with 'removeDataAttribute()' method.", ); } @@ -552,9 +536,9 @@ public function testRenderWithRole(): void
    HTML, - LineEndingNormalizer::normalize( - Section::tag()->role('region')->render(), - ), + Section::tag() + ->role('region') + ->render(), "Failed asserting that element renders correctly with 'role' attribute.", ); } @@ -566,9 +550,9 @@ public function testRenderWithRoleUsingEnum(): void
    HTML, - LineEndingNormalizer::normalize( - Section::tag()->role(Role::REGION)->render(), - ), + Section::tag() + ->role(Role::REGION) + ->render(), "Failed asserting that element renders correctly with 'role' attribute using enum.", ); } @@ -580,9 +564,9 @@ public function testRenderWithSpellcheck(): void
    HTML, - LineEndingNormalizer::normalize( - Section::tag()->spellcheck(true)->render(), - ), + Section::tag() + ->spellcheck(true) + ->render(), "Failed asserting that element renders correctly with 'spellcheck' attribute.", ); } @@ -594,9 +578,9 @@ public function testRenderWithStyle(): void
    HTML, - LineEndingNormalizer::normalize( - Section::tag()->style('value')->render(), - ), + Section::tag() + ->style('value') + ->render(), "Failed asserting that element renders correctly with 'style' attribute.", ); } @@ -608,9 +592,9 @@ public function testRenderWithTabindex(): void
    HTML, - LineEndingNormalizer::normalize( - Section::tag()->tabIndex(3)->render(), - ), + Section::tag() + ->tabIndex(3) + ->render(), "Failed asserting that element renders correctly with 'tabindex' attribute.", ); } @@ -622,9 +606,9 @@ public function testRenderWithThemeProvider(): void
    HTML, - LineEndingNormalizer::normalize( - Section::tag()->addThemeProvider('muted', DefaultThemeProvider::class)->render(), - ), + Section::tag() + ->addThemeProvider('muted', DefaultThemeProvider::class) + ->render(), "Failed asserting that element renders correctly with 'addThemeProvider()' method.", ); } @@ -636,7 +620,9 @@ public function testRenderWithTitle(): void
    HTML, - Section::tag()->title('value')->render(), + Section::tag() + ->title('value') + ->render(), "Failed asserting that element renders correctly with 'title' attribute.", ); } @@ -648,9 +634,7 @@ public function testRenderWithToString(): void
    HTML, - LineEndingNormalizer::normalize( - (string) Section::tag(), - ), + (string) Section::tag(), "Failed asserting that '__toString()' method renders correctly.", ); } @@ -662,9 +646,9 @@ public function testRenderWithTranslate(): void
    HTML, - LineEndingNormalizer::normalize( - Section::tag()->translate(false)->render(), - ), + Section::tag() + ->translate(false) + ->render(), "Failed asserting that element renders correctly with 'translate' attribute.", ); } @@ -676,9 +660,9 @@ public function testRenderWithTranslateUsingEnum(): void
    HTML, - LineEndingNormalizer::normalize( - Section::tag()->translate(Translate::NO)->render(), - ), + Section::tag() + ->translate(Translate::NO) + ->render(), "Failed asserting that element renders correctly with 'translate' attribute using enum.", ); } @@ -692,9 +676,7 @@ public function testRenderWithUserOverridesGlobalDefaults(): void
    HTML, - LineEndingNormalizer::normalize( - Section::tag(['id' => 'id-user'])->render(), - ), + Section::tag(['id' => 'id-user'])->render(), 'Failed asserting that user-defined attributes override global defaults correctly.', );