From a45c741c8d1a04936c2e47750454632d2e5ef4e2 Mon Sep 17 00:00:00 2001 From: "i.lisitski" Date: Tue, 14 Jan 2025 23:45:19 +0300 Subject: [PATCH 01/12] Fix #234. Remove useless tags attributes sorting. Fix tests --- src/Html.php | 49 ------ tests/HtmlTest.php | 8 +- tests/Tag/Base/BooleanInputTagTest.php | 30 ++-- tests/Tag/Base/MediaTagTest.php | 6 +- tests/Tag/Base/TagTest.php | 4 +- tests/Tag/ColgroupTest.php | 4 +- tests/Tag/FormTest.php | 4 +- tests/Tag/Input/CheckboxTest.php | 2 +- tests/Tag/Input/FileTest.php | 32 ++-- tests/Tag/Input/RadioTest.php | 2 +- tests/Tag/Input/RangeTest.php | 40 ++--- tests/Tag/InputTest.php | 8 +- tests/Tag/LinkTest.php | 8 +- tests/Tag/SelectTest.php | 8 +- tests/Tag/SourceTest.php | 2 +- tests/Tag/TrackTest.php | 2 +- tests/Widget/ButtonGroupTest.php | 4 +- tests/Widget/CheckboxListTest.php | 220 ++++++++++++------------- tests/Widget/RadioListTest.php | 4 +- 19 files changed, 194 insertions(+), 243 deletions(-) diff --git a/src/Html.php b/src/Html.php index 1dd35949..e95c0cea 100644 --- a/src/Html.php +++ b/src/Html.php @@ -96,45 +96,6 @@ */ final class Html { - /** - * The preferred order of attributes in a tag. This mainly affects the order of the attributes that are - * rendered by {@see renderTagAttributes()}. - */ - private const ATTRIBUTE_ORDER = [ - 'type', - 'id', - 'class', - 'name', - 'value', - - 'href', - 'loading', - 'src', - 'srcset', - 'form', - 'action', - 'method', - - 'selected', - 'checked', - 'readonly', - 'disabled', - 'multiple', - - 'size', - 'maxlength', - 'minlength', - 'width', - 'height', - 'rows', - 'cols', - - 'alt', - 'title', - 'rel', - 'media', - ]; - /** * List of tag attributes that should be specially handled when their values are of array type. * In particular, if the value of the `data` attribute is `['name' => 'xyz', 'age' => 13]`, two attributes will be @@ -1613,16 +1574,6 @@ public static function address(string|Stringable $content = '', array $attribute */ public static function renderTagAttributes(array $attributes): string { - if (count($attributes) > 1) { - $sorted = []; - foreach (self::ATTRIBUTE_ORDER as $name) { - if (isset($attributes[$name])) { - $sorted[$name] = $attributes[$name]; - } - } - $attributes = array_merge($sorted, $attributes); - } - $html = ''; /** * @var string $name diff --git a/tests/HtmlTest.php b/tests/HtmlTest.php index 196079c4..1988dbf3 100644 --- a/tests/HtmlTest.php +++ b/tests/HtmlTest.php @@ -206,7 +206,7 @@ public function testMailto(): void Html::mailto('contact me', 'info@example.com')->render() ); $this->assertSame( - 'contact me', + 'contact me', Html::mailto('contact me', 'info@example.com', ['id' => 'contact'])->render() ); } @@ -534,9 +534,9 @@ public function testRadioList(): void $this->assertSame( '' . "\n" . '
' . "\n" . - '' . "\n" . - '' . "\n" . - '' . "\n" . + '' . "\n" . + '' . "\n" . + '' . "\n" . '
', Html::radioList('test') ->items([1 => 'One', 2 => 'Two', 5 => 'Five']) diff --git a/tests/Tag/Base/BooleanInputTagTest.php b/tests/Tag/Base/BooleanInputTagTest.php index b35fb133..3bb6b032 100644 --- a/tests/Tag/Base/BooleanInputTagTest.php +++ b/tests/Tag/Base/BooleanInputTagTest.php @@ -12,7 +12,7 @@ final class BooleanInputTagTest extends TestCase { public function testChecked(): void { - $this->assertSame('', (string)TestBooleanInputTag::tag()->checked()); + $this->assertSame('', (string)TestBooleanInputTag::tag()->checked()); $this->assertSame('', (string)TestBooleanInputTag::tag()->checked(false)); $this->assertSame('', (string)TestBooleanInputTag::tag() ->checked(true) @@ -64,7 +64,7 @@ public function testLabel(string $expected, ?string $label, array $attributes): public function testLabelNoWrap(): void { $this->assertSame( - ' ', + ' ', (string) TestBooleanInputTag::tag() ->id('ID') ->label('Voronezh', wrap: false), @@ -74,7 +74,7 @@ public function testLabelNoWrap(): void public function testLabelWithId(): void { $this->assertSame( - '', + '', TestBooleanInputTag::tag() ->id('Test') ->label('One') @@ -85,7 +85,7 @@ public function testLabelWithId(): void public function testSideLabel(): void { $this->assertMatchesRegularExpression( - '~ ~', + '~ ~', TestBooleanInputTag::tag() ->sideLabel('One') ->render() @@ -95,7 +95,7 @@ public function testSideLabel(): void public function testSideLabelEmpty(): void { $this->assertMatchesRegularExpression( - '~ ~', + '~ ~', TestBooleanInputTag::tag() ->sideLabel('') ->render() @@ -115,7 +115,7 @@ public function testSideLabelNull(): void public function testSideLabelWithId(): void { $this->assertSame( - ' ', + ' ', TestBooleanInputTag::tag() ->id('Test') ->sideLabel('One') @@ -126,7 +126,7 @@ public function testSideLabelWithId(): void public function testSideLabelWithAttributes(): void { $this->assertMatchesRegularExpression( - '~ ~', + '~ ~', TestBooleanInputTag::tag() ->sideLabel('One', ['class' => 'red']) ->render() @@ -136,7 +136,7 @@ public function testSideLabelWithAttributes(): void public function testSideLabelId(): void { $this->assertSame( - ' ', + ' ', TestBooleanInputTag::tag() ->sideLabel('One') ->id('count') @@ -160,15 +160,15 @@ public static function dataUncheckValue(): array return [ ['', null, null], ['', null, 7], - ['', 'color', null], - ['', 'color[]', null], + ['', 'color', null], + ['', 'color[]', null], [ - '', + '', 'color', 7, ], [ - '', + '', 'color[]', 7, ], @@ -191,7 +191,7 @@ public function testUncheckValueDisabled(): void { $this->assertSame( '' . - '', + '', TestBooleanInputTag::tag() ->name('color') ->uncheckValue(7) @@ -204,7 +204,7 @@ public function testUncheckValueForm(): void { $this->assertSame( '' . - '', + '', TestBooleanInputTag::tag() ->name('color') ->uncheckValue(7) @@ -217,7 +217,7 @@ public function testUncheckValueWithLabel(): void { $this->assertSame( '' . - '', + '', TestBooleanInputTag::tag() ->name('color') ->uncheckValue(7) diff --git a/tests/Tag/Base/MediaTagTest.php b/tests/Tag/Base/MediaTagTest.php index 8b89c9ba..6f103d5b 100644 --- a/tests/Tag/Base/MediaTagTest.php +++ b/tests/Tag/Base/MediaTagTest.php @@ -169,9 +169,9 @@ public function testWrongTrackDefault(): void $this->assertSame( '' . "\n" . - '' . "\n" . - '' . "\n" . - '' . "\n" . + '' . "\n" . + '' . "\n" . + '' . "\n" . '', $tag->render() ); diff --git a/tests/Tag/Base/TagTest.php b/tests/Tag/Base/TagTest.php index d5bc4a5a..ec0205f7 100644 --- a/tests/Tag/Base/TagTest.php +++ b/tests/Tag/Base/TagTest.php @@ -28,7 +28,7 @@ public static function dataAttributes(): array ['', ['class' => ['first', 'second']]], ['', ['class' => []]], ['', ['style' => ['width' => '100px', 'height' => '200px']]], - ['', ['value' => 42, 'name' => 'position']], + ['', ['value' => 42, 'name' => 'position']], [ '', [ @@ -93,7 +93,7 @@ public function testReplaceAttributes(): void public function testUnionAttributes(): void { $this->assertSame( - '', + '', TestTag::tag() ->class('red') ->unionAttributes(['class' => 'green', 'id' => 'color']) diff --git a/tests/Tag/ColgroupTest.php b/tests/Tag/ColgroupTest.php index dedeab0d..492040c0 100644 --- a/tests/Tag/ColgroupTest.php +++ b/tests/Tag/ColgroupTest.php @@ -16,8 +16,8 @@ public function testBase(): void $this->assertSame( '' . "\n" . '' . "\n" . - '' . "\n" . - '' . "\n" . + '' . "\n" . + '' . "\n" . '', Colgroup::tag() ->columns( diff --git a/tests/Tag/FormTest.php b/tests/Tag/FormTest.php index 17c8f58b..88d20dbc 100644 --- a/tests/Tag/FormTest.php +++ b/tests/Tag/FormTest.php @@ -36,7 +36,7 @@ public function testBase(): void public function testGet(): void { $this->assertSame( - '
', + '
', Form::tag() ->get('https://example.com/send') ->render() @@ -56,7 +56,7 @@ public function testGetWithoutUrl(): void public function testPost(): void { $this->assertSame( - '
', + '
', Form::tag() ->post('https://example.com/send') ->render() diff --git a/tests/Tag/Input/CheckboxTest.php b/tests/Tag/Input/CheckboxTest.php index 066c16b3..40334a88 100644 --- a/tests/Tag/Input/CheckboxTest.php +++ b/tests/Tag/Input/CheckboxTest.php @@ -12,7 +12,7 @@ final class CheckboxTest extends TestCase public function testBase(): void { $this->assertSame( - '', + '', Checkbox::tag() ->name('number') ->value(42) diff --git a/tests/Tag/Input/FileTest.php b/tests/Tag/Input/FileTest.php index 02d8ed4a..943a5cb2 100644 --- a/tests/Tag/Input/FileTest.php +++ b/tests/Tag/Input/FileTest.php @@ -13,7 +13,7 @@ final class FileTest extends TestCase public function testBase(): void { $this->assertSame( - '', + '', File::tag() ->name('avatar') ->render() @@ -25,15 +25,15 @@ public static function dataUncheckValue(): array return [ ['', null, null], ['', null, 7], - ['', 'avatar', null], - ['', 'avatar[]', null], + ['', 'avatar', null], + ['', 'avatar[]', null], [ - '', + '', 'avatar', 7, ], [ - '', + '', 'avatar[]', 7, ], @@ -56,7 +56,7 @@ public function testUncheckValueDisabled(): void { $this->assertSame( '' . - '', + '', File::tag() ->name('avatar') ->uncheckValue(7) @@ -69,7 +69,7 @@ public function testUncheckValueForm(): void { $this->assertSame( '' . - '', + '', File::tag() ->name('avatar') ->uncheckValue(7) @@ -89,8 +89,8 @@ public function testUncheckInputAttributes(): void ->render(); $this->assertSame( - '' . - '', + '' . + '', $result ); } @@ -106,8 +106,8 @@ public function testReplaceUncheckInputAttributes(): void ->render(); $this->assertSame( - '' . - '', + '' . + '', $result ); } @@ -116,11 +116,11 @@ public static function dataAccept(): array { return [ [ - '', + '', null, ], [ - '', + '', '.doc,.docx', ], ]; @@ -142,11 +142,11 @@ public static function dataMultiple(): array { return [ [ - '', + '', true, ], [ - '', + '', false, ], ]; @@ -167,7 +167,7 @@ public function testMultiple(string $expected, ?bool $multiple): void public function testMultipleDefault(): void { $this->assertSame( - '', + '', File::tag() ->name('avatar') ->multiple() diff --git a/tests/Tag/Input/RadioTest.php b/tests/Tag/Input/RadioTest.php index 0040cebe..1372dab2 100644 --- a/tests/Tag/Input/RadioTest.php +++ b/tests/Tag/Input/RadioTest.php @@ -12,7 +12,7 @@ final class RadioTest extends TestCase public function testBase(): void { $this->assertSame( - '', + '', Radio::tag() ->name('number') ->value(42) diff --git a/tests/Tag/Input/RangeTest.php b/tests/Tag/Input/RangeTest.php index c10eeba5..49f857f2 100644 --- a/tests/Tag/Input/RangeTest.php +++ b/tests/Tag/Input/RangeTest.php @@ -21,7 +21,7 @@ public function testBase(): void ->step(10); $this->assertSame( - '', + '', $tag->render() ); } @@ -30,11 +30,11 @@ public static function dataMin(): array { return [ ['', null], - ['', ''], - ['', '2.5'], - ['', 10], - ['', 42.7], - ['', new StringableObject('99')], + ['', ''], + ['', '2.5'], + ['', 10], + ['', 42.7], + ['', new StringableObject('99')], ]; } @@ -50,11 +50,11 @@ public static function dataMax(): array { return [ ['', null], - ['', ''], - ['', '2.5'], - ['', 10], - ['', 42.7], - ['', new StringableObject('99')], + ['', ''], + ['', '2.5'], + ['', 10], + ['', 42.7], + ['', new StringableObject('99')], ]; } @@ -70,11 +70,11 @@ public static function dataStep(): array { return [ ['', null], - ['', ''], - ['', '2.5'], - ['', 10], - ['', 42.7], - ['', new StringableObject('99')], + ['', ''], + ['', '2.5'], + ['', 10], + ['', 42.7], + ['', new StringableObject('99')], ]; } @@ -90,7 +90,7 @@ public static function dataList(): array { return [ ['', null], - ['', 'DataList'], + ['', 'DataList'], ]; } @@ -124,7 +124,7 @@ public function testAddOutputAttributes(): void $this->assertSame( '' . - "\n" . '-', + "\n" . '-', $tag->render() ); } @@ -181,7 +181,7 @@ public function testOutputWithCustomAttributes(): void $this->assertMatchesRegularExpression( '~' . - "\n" . '-~', + "\n" . '-~', $tag->render() ); } @@ -193,7 +193,7 @@ public function testOutputWithValue(): void ->value(10); $this->assertMatchesRegularExpression( - '~' . "\n" . '10~', $tag->render() diff --git a/tests/Tag/InputTest.php b/tests/Tag/InputTest.php index a6daebe8..d06639dd 100644 --- a/tests/Tag/InputTest.php +++ b/tests/Tag/InputTest.php @@ -48,7 +48,7 @@ public function testPassword(): void public function testFile(): void { $this->assertSame( - '', + '', (string)Input::file('photo', 'c:\\path\\') ); } @@ -56,7 +56,7 @@ public function testFile(): void public function testCheckbox(): void { $this->assertSame( - '', + '', (string)Input::checkbox('subscribe')->checked() ); } @@ -64,7 +64,7 @@ public function testCheckbox(): void public function testRadio(): void { $this->assertSame( - '', + '', (string)Input::radio('count', 'one') ); } @@ -72,7 +72,7 @@ public function testRadio(): void public function testRange(): void { $this->assertSame( - '', + '', (string) Input::range('count', 10) ); } diff --git a/tests/Tag/LinkTest.php b/tests/Tag/LinkTest.php index 0a404202..ee5d15c9 100644 --- a/tests/Tag/LinkTest.php +++ b/tests/Tag/LinkTest.php @@ -13,7 +13,7 @@ final class LinkTest extends TestCase public function testBase(): void { $this->assertSame( - '', + '', (string)Link::tag() ->url('/rss') ->type('application/rss+xml') @@ -25,7 +25,7 @@ public function testBase(): void public function testToCssFile(): void { $this->assertSame( - '', + '', (string)Link::toCssFile('main.css') ); } @@ -119,8 +119,8 @@ public function testAs(string $expected, ?string $as): void public static function dataPreload(): array { return [ - ['', '/main.css'], - ['', '/main.css', 'style'], + ['', '/main.css'], + ['', '/main.css', 'style'], ]; } diff --git a/tests/Tag/SelectTest.php b/tests/Tag/SelectTest.php index 2a7f6c6b..97847f2c 100644 --- a/tests/Tag/SelectTest.php +++ b/tests/Tag/SelectTest.php @@ -33,15 +33,15 @@ public static function dataNameForMultiple(): array { return [ ['', null], - ['', ''], + ['', ''], [ '' . "\n" . - '', + '', 'age', ], [ '' . "\n" . - '', + '', 'place[]', ], ]; @@ -360,7 +360,7 @@ public function testOptionsAndGroupsAttributes(): void $this->assertStringContainsStringIgnoringLineEndings( << - + diff --git a/tests/Tag/SourceTest.php b/tests/Tag/SourceTest.php index f7c28a63..ea660ba8 100644 --- a/tests/Tag/SourceTest.php +++ b/tests/Tag/SourceTest.php @@ -13,7 +13,7 @@ final class SourceTest extends TestCase public function testBase(): void { $this->assertSame( - '', + '', (string) Source::tag() ->src('audio.ogg') ->type('audio/ogg; codecs=vorbis') diff --git a/tests/Tag/TrackTest.php b/tests/Tag/TrackTest.php index 7c6f7555..b89a0863 100644 --- a/tests/Tag/TrackTest.php +++ b/tests/Tag/TrackTest.php @@ -13,7 +13,7 @@ final class TrackTest extends TestCase public function testBase(): void { $this->assertSame( - '', + '', (string) Track::tag() ->kind(Track::SUBTITLES) ->src('brave.en.vtt') diff --git a/tests/Widget/ButtonGroupTest.php b/tests/Widget/ButtonGroupTest.php index 88f7f4c4..048f31b2 100644 --- a/tests/Widget/ButtonGroupTest.php +++ b/tests/Widget/ButtonGroupTest.php @@ -198,8 +198,8 @@ public function testMergeButtonAttributes(): void $this->assertStringContainsStringIgnoringLineEndings( << - - + + HTML, $widget->render(), diff --git a/tests/Widget/CheckboxListTest.php b/tests/Widget/CheckboxListTest.php index 230a19cd..982e4001 100644 --- a/tests/Widget/CheckboxListTest.php +++ b/tests/Widget/CheckboxListTest.php @@ -21,9 +21,9 @@ public function testBase(): void $this->assertSame( '' . "\n" . '
' . "\n" . - '' . "\n" . - '' . "\n" . - '' . "\n" . + '' . "\n" . + '' . "\n" . + '' . "\n" . '
', CheckboxList::create('test') ->items([1 => 'One', 2 => 'Two', 5 => 'Five']) @@ -42,7 +42,7 @@ public function testName(): void $this->assertSame( '
' . "\n" . - '' . "\n" . + '' . "\n" . '
', $widget->render() ); @@ -51,7 +51,7 @@ public function testName(): void public function testWithoutContainer(): void { $this->assertSame( - '', + '', CheckboxList::create('test') ->items([1 => 'One']) ->withoutContainer() @@ -63,16 +63,16 @@ public static function dataContainerTag(): array { return [ [ - '', + '', null, ], [ - '', + '', '', ], [ '
' . "\n" . - '' . "\n" . + '' . "\n" . '
', 'section', ], @@ -95,7 +95,7 @@ public function testContainerAttributes(): void { $this->assertSame( '
' . "\n" . - '' . "\n" . + '' . "\n" . '
', CheckboxList::create('test') ->items([1 => 'One']) @@ -107,8 +107,8 @@ public function testContainerAttributes(): void public function testCheckboxAttributes(): void { $this->assertSame( - '' . "\n" . - '', + '' . "\n" . + '', CheckboxList::create('test') ->items([ 1 => 'One', @@ -123,8 +123,8 @@ public function testCheckboxAttributes(): void public function testCheckboxAttributesMerge(): void { $this->assertSame( - '' . "\n" . - '', + '' . "\n" . + '', CheckboxList::create('test') ->items([ 1 => 'One', @@ -140,8 +140,8 @@ public function testCheckboxAttributesMerge(): void public function testReplaceCheckboxAttributes(): void { $this->assertSame( - '' . "\n" . - '', + '' . "\n" . + '', CheckboxList::create('test') ->items([ 1 => 'One', @@ -157,8 +157,8 @@ public function testReplaceCheckboxAttributes(): void public function testCheckboxLabelAttributes(): void { $this->assertSame( - '' . "\n" . - '', + '' . "\n" . + '', CheckboxList::create('test') ->items([1 => 'One', 2 => 'Two']) ->checkboxLabelAttributes(['class' => 'red']) @@ -170,8 +170,8 @@ public function testCheckboxLabelAttributes(): void public function testCheckboxLabelAttributesMerge(): void { $this->assertSame( - '' . "\n" . - '', + '' . "\n" . + '', CheckboxList::create('test') ->items([1 => 'One', 2 => 'Two']) ->checkboxLabelAttributes(['class' => 'red']) @@ -184,9 +184,9 @@ public function testCheckboxLabelAttributesMerge(): void public function testAddIndividualInputAttributes(): void { $this->assertSame( - '' . "\n" . - '' . "\n" . - '', + '' . "\n" . + '' . "\n" . + '', CheckboxList::create('test') ->items([ 1 => 'One', @@ -206,9 +206,9 @@ public function testAddIndividualInputAttributes(): void public function testIndividualUncheckInputAttributes(): void { $this->assertSame( - '' . "\n" . - '' . "\n" . - '', + '' . "\n" . + '' . "\n" . + '', CheckboxList::create('test') ->items([ 1 => 'One', @@ -227,9 +227,9 @@ public function testIndividualUncheckInputAttributes(): void public function testIndividualInputAttributesMerge(): void { $this->assertSame( - '' . "\n" . - '' . "\n" . - '', + '' . "\n" . + '' . "\n" . + '', CheckboxList::create('test') ->items([ 1 => 'One', @@ -253,9 +253,9 @@ public function testIndividualInputAttributesMerge(): void public function testIndividualInputAttributesReplace(): void { $this->assertSame( - '' . "\n" . - '' . "\n" . - '', + '' . "\n" . + '' . "\n" . + '', CheckboxList::create('test') ->items([ 1 => 'One', @@ -278,8 +278,8 @@ public function testIndividualInputAttributesReplace(): void public function testItems(): void { $this->assertSame( - '' . "\n" . - '', + '' . "\n" . + '', CheckboxList::create('test') ->items([ 1 => 'One', @@ -293,8 +293,8 @@ public function testItems(): void public function testItemsWithoutEncodeLabel(): void { $this->assertSame( - '' . "\n" . - '', + '' . "\n" . + '', CheckboxList::create('test') ->items([ 1 => 'One', @@ -309,18 +309,18 @@ public static function dataItemsFromValues(): array { return [ [ - '' . "\n" . - '', + '' . "\n" . + '', [1, 2], ], [ - '' . "\n" . - '', + '' . "\n" . + '', ['One', 'Two'], ], [ - '' . "\n" . - '', + '' . "\n" . + '', [true, false], ], ]; @@ -341,8 +341,8 @@ public function testItemsFromValues(string $expected, array $values): void public function testItemsFromValuesWithoutEncodeLabel(): void { $this->assertSame( - '' . "\n" . - '', + '' . "\n" . + '', CheckboxList::create('test') ->itemsFromValues([ 'One', @@ -360,41 +360,41 @@ public static function dataValue(): array ["
\n
", [], [42]], [ '
' . "\n" . - '' . "\n" . - '' . "\n" . + '' . "\n" . + '' . "\n" . '
', [1 => 'One', 2 => 'Two'], [], ], [ '
' . "\n" . - '' . "\n" . - '' . "\n" . + '' . "\n" . + '' . "\n" . '
', [1 => 'One', 2 => 'Two'], [7], ], [ '
' . "\n" . - '' . "\n" . - '' . "\n" . + '' . "\n" . + '' . "\n" . '
', [1 => 'One', 2 => 'Two'], [1], ], [ '
' . "\n" . - '' . "\n" . - '' . "\n" . + '' . "\n" . + '' . "\n" . '
', [1 => 'One', 2 => 'Two'], [2], ], [ '
' . "\n" . - '' . "\n" . - '' . "\n" . - '' . "\n" . + '' . "\n" . + '' . "\n" . + '' . "\n" . '
', [1 => 'One', 2 => 'Two', 3 => 'Three'], [1, 3], @@ -402,25 +402,25 @@ public static function dataValue(): array ["
\n
", [], [StringEnum::A]], [ '
' . "\n" . - '' . "\n" . - '' . "\n" . + '' . "\n" . + '' . "\n" . '
', [StringEnum::A->value => 'One', StringEnum::B->value => 'Two'], [StringEnum::C], ], [ '
' . "\n" . - '' . "\n" . - '' . "\n" . + '' . "\n" . + '' . "\n" . '
', [StringEnum::A->value => 'One', StringEnum::B->value => 'Two'], [StringEnum::B], ], [ '
' . "\n" . - '' . "\n" . - '' . "\n" . - '' . "\n" . + '' . "\n" . + '' . "\n" . + '' . "\n" . '
', [StringEnum::A->value => 'One', StringEnum::B->value => 'Two', StringEnum::C->value => 'Three'], [StringEnum::B, StringEnum::C], @@ -428,25 +428,25 @@ public static function dataValue(): array ["
\n
", [], [IntegerEnum::A]], [ '
' . "\n" . - '' . "\n" . - '' . "\n" . + '' . "\n" . + '' . "\n" . '
', [IntegerEnum::A->value => 'One', IntegerEnum::B->value => 'Two'], [IntegerEnum::C], ], [ '
' . "\n" . - '' . "\n" . - '' . "\n" . + '' . "\n" . + '' . "\n" . '
', [IntegerEnum::A->value => 'One', IntegerEnum::B->value => 'Two'], [IntegerEnum::B], ], [ '
' . "\n" . - '' . "\n" . - '' . "\n" . - '' . "\n" . + '' . "\n" . + '' . "\n" . + '' . "\n" . '
', [IntegerEnum::A->value => 'One', IntegerEnum::B->value => 'Two', IntegerEnum::C->value => 'Three'], [IntegerEnum::B, IntegerEnum::C], @@ -492,22 +492,22 @@ public static function dataForm(): array return [ [ '
' . "\n" . - '' . "\n" . - '' . "\n" . + '' . "\n" . + '' . "\n" . '
', null, ], [ '
' . "\n" . - '' . "\n" . - '' . "\n" . + '' . "\n" . + '' . "\n" . '
', '', ], [ '
' . "\n" . - '' . "\n" . - '' . "\n" . + '' . "\n" . + '' . "\n" . '
', 'post', ], @@ -539,8 +539,8 @@ public function testReadonly(): void $this->assertSame( '
' . "\n" . - '' . "\n" . - '' . "\n" . + '' . "\n" . + '' . "\n" . '
', $checkbox ->readonly() @@ -549,8 +549,8 @@ public function testReadonly(): void $this->assertSame( '
' . "\n" . - '' . "\n" . - '' . "\n" . + '' . "\n" . + '' . "\n" . '
', $checkbox ->readonly(false) @@ -558,8 +558,8 @@ public function testReadonly(): void ); $this->assertSame( '
' . "\n" . - '' . "\n" . - '' . "\n" . + '' . "\n" . + '' . "\n" . '
', $checkbox ->readonly(true) @@ -578,8 +578,8 @@ public function testDisabled(): void $this->assertSame( '
' . "\n" . - '' . "\n" . - '' . "\n" . + '' . "\n" . + '' . "\n" . '
', $checkbox ->disabled() @@ -588,8 +588,8 @@ public function testDisabled(): void $this->assertSame( '
' . "\n" . - '' . "\n" . - '' . "\n" . + '' . "\n" . + '' . "\n" . '
', $checkbox ->disabled(false) @@ -597,8 +597,8 @@ public function testDisabled(): void ); $this->assertSame( '
' . "\n" . - '' . "\n" . - '' . "\n" . + '' . "\n" . + '' . "\n" . '
', $checkbox ->disabled(true) @@ -612,16 +612,16 @@ public static function dataUncheckValue(): array return [ [ '
' . "\n" . - '' . "\n" . - '' . "\n" . + '' . "\n" . + '' . "\n" . '
', 'test', null, ], [ '
' . "\n" . - '' . "\n" . - '' . "\n" . + '' . "\n" . + '' . "\n" . '
', 'test[]', null, @@ -629,8 +629,8 @@ public static function dataUncheckValue(): array [ '' . "\n" . '
' . "\n" . - '' . "\n" . - '' . "\n" . + '' . "\n" . + '' . "\n" . '
', 'test', 7, @@ -638,8 +638,8 @@ public static function dataUncheckValue(): array [ '' . "\n" . '
' . "\n" . - '' . "\n" . - '' . "\n" . + '' . "\n" . + '' . "\n" . '
', 'test[]', 7, @@ -666,8 +666,8 @@ public function testUncheckValueDisabled(): void { $this->assertSame( '' . "\n" . - '' . "\n" . - '', + '' . "\n" . + '', CheckboxList::create('test') ->items([ 1 => 'One', @@ -684,8 +684,8 @@ public function testUncheckValueForm(): void { $this->assertSame( '' . "\n" . - '' . "\n" . - '', + '' . "\n" . + '', CheckboxList::create('test') ->items([ 1 => 'One', @@ -702,8 +702,8 @@ public function testSeparator(): void { $this->assertSame( '
' . "\n" . - '
' . - '' . "\n" . + '
' . + '' . "\n" . '
', CheckboxList::create('test') ->items([1 => 'One', 2 => 'Two']) @@ -716,8 +716,8 @@ public function testItemFormatter(): void { $this->assertSame( '
' . "\n" . - '
0)
' . - '
1)
' . "\n" . + '
0)
' . + '
1)
' . "\n" . '
', CheckboxList::create('test') ->items([1 => 'One', 2 => 'Two']) @@ -750,8 +750,8 @@ public function testDisableCheckboxLabelWrap(): void $this->assertSame( << - - + + HTML, $html, @@ -770,10 +770,10 @@ public function testCheckboxWrap(): void <<
- +
- +
HTML, @@ -807,10 +807,10 @@ public function testCheckboxWrapClass(string $expected, array $class): void << - + - + HTML, @@ -843,10 +843,10 @@ public function testAddCheckboxWrapClass(string $expected, array $class): void << - + - + HTML, diff --git a/tests/Widget/RadioListTest.php b/tests/Widget/RadioListTest.php index d0ffbdac..cc1aa510 100644 --- a/tests/Widget/RadioListTest.php +++ b/tests/Widget/RadioListTest.php @@ -757,10 +757,10 @@ public function testRadioWrapClass(string $expected, array $class): void << - + - + HTML, From 2c077f31596ae41b830904a64fa14c2ad013df33 Mon Sep 17 00:00:00 2001 From: "i.lisitski" Date: Wed, 15 Jan 2025 00:13:28 +0300 Subject: [PATCH 02/12] Fix #234 all test pass --- tests/HtmlTest.php | 60 +++++----- tests/Tag/FormTest.php | 2 +- tests/Tag/PictureTest.php | 4 +- tests/Widget/RadioListTest.php | 198 ++++++++++++++++----------------- 4 files changed, 132 insertions(+), 132 deletions(-) diff --git a/tests/HtmlTest.php b/tests/HtmlTest.php index 1988dbf3..9dbe5264 100644 --- a/tests/HtmlTest.php +++ b/tests/HtmlTest.php @@ -135,7 +135,7 @@ public function testMeta(): void { $this->assertSame('', Html::meta()->render()); $this->assertSame( - '', + '', Html::meta(['name' => 'keywords', 'content' => 'yii', 'id' => 'main'])->render() ); } @@ -154,15 +154,15 @@ public function testLink(): void public function testCssFile(): void { $this->assertSame( - '', + '', Html::cssFile('http://example.com')->render() ); $this->assertSame( - '', + '', Html::cssFile('')->render() ); $this->assertSame( - '', + '', Html::cssFile('http://example.com', ['id' => 'main'])->render() ); } @@ -178,7 +178,7 @@ public function testJavaScriptFile(): void Html::javaScriptFile('')->render() ); $this->assertSame( - '', + '', Html::javaScriptFile('http://example.com', ['id' => 'main'])->render() ); } @@ -393,7 +393,7 @@ public function testHiddenInput(): void Html::hiddenInput('test', '43')->render(), ); $this->assertSame( - '', + '', Html::hiddenInput('test', '43', ['id' => 'ABC'])->render(), ); } @@ -417,15 +417,15 @@ public function testPasswordInput(): void public function testFile(): void { $this->assertSame('', Html::file()->render()); - $this->assertSame('', Html::file('')->render()); - $this->assertSame('', Html::file(null, '')->render()); - $this->assertSame('', Html::file('test')->render()); + $this->assertSame('', Html::file('')->render()); + $this->assertSame('', Html::file(null, '')->render()); + $this->assertSame('', Html::file('test')->render()); $this->assertSame( - '', + '', Html::file('test', '43')->render(), ); $this->assertSame( - '', + '', Html::file('test', '43', ['class' => 'photo'])->render(), ); } @@ -433,15 +433,15 @@ public function testFile(): void public function testRadio(): void { $this->assertSame('', Html::radio()->render()); - $this->assertSame('', Html::radio('')->render()); - $this->assertSame('', Html::radio(null, '')->render()); - $this->assertSame('', Html::radio('test')->render()); + $this->assertSame('', Html::radio('')->render()); + $this->assertSame('', Html::radio(null, '')->render()); + $this->assertSame('', Html::radio('test')->render()); $this->assertSame( - '', + '', Html::radio('test', '43')->render(), ); $this->assertSame( - '', + '', Html::radio('test', '43', ['readonly' => true])->render(), ); } @@ -449,15 +449,15 @@ public function testRadio(): void public function testCheckbox(): void { $this->assertSame('', Html::checkbox()->render()); - $this->assertSame('', Html::checkbox('')->render()); - $this->assertSame('', Html::checkbox(null, '')->render()); - $this->assertSame('', Html::checkbox('test')->render()); + $this->assertSame('', Html::checkbox('')->render()); + $this->assertSame('', Html::checkbox(null, '')->render()); + $this->assertSame('', Html::checkbox('test')->render()); $this->assertSame( - '', + '', Html::checkbox('test', '43')->render(), ); $this->assertSame( - '', + '', Html::checkbox('test', '43', ['readonly' => true])->render(), ); } @@ -465,15 +465,15 @@ public function testCheckbox(): void public function testRange(): void { $this->assertSame('', Html::range()->render()); - $this->assertSame('', Html::range('')->render()); - $this->assertSame('', Html::range(null, '')->render()); - $this->assertSame('', Html::range('test')->render()); + $this->assertSame('', Html::range('')->render()); + $this->assertSame('', Html::range(null, '')->render()); + $this->assertSame('', Html::range('test')->render()); $this->assertSame( - '', + '', Html::range('test', '43')->render(), ); $this->assertSame( - '', + '', Html::range('test', '43', ['readonly' => true])->render(), ); } @@ -516,9 +516,9 @@ public function testCheckboxList(): void $this->assertSame( '' . "\n" . '
' . "\n" . - '' . "\n" . - '' . "\n" . - '' . "\n" . + '' . "\n" . + '' . "\n" . + '' . "\n" . '
', Html::checkboxList('test') ->items([1 => 'One', 2 => 'Two', 5 => 'Five']) @@ -819,7 +819,7 @@ public static function dataRenderTagAttributes(): array [' class="first second"', ['class' => ['first', 'second']]], ['', ['class' => []]], [' style="width: 100px; height: 200px;"', ['style' => ['width' => '100px', 'height' => '200px']]], - [' name="position" value="42"', ['value' => 42, 'name' => 'position']], + [' value="42" name="position"', ['value' => 42, 'name' => 'position']], [ ' id="x" class="a b" data-a="1" data-b="2" style="width: 100px;" any=\'[1,2]\'', [ diff --git a/tests/Tag/FormTest.php b/tests/Tag/FormTest.php index 88d20dbc..8cf44fba 100644 --- a/tests/Tag/FormTest.php +++ b/tests/Tag/FormTest.php @@ -18,7 +18,7 @@ public function testBase(): void $tag = Form::tag(); $this->assertSame( - '
' . + '' . '' . '' . '
', diff --git a/tests/Tag/PictureTest.php b/tests/Tag/PictureTest.php index e495c9f7..6c8ffb6e 100644 --- a/tests/Tag/PictureTest.php +++ b/tests/Tag/PictureTest.php @@ -31,8 +31,8 @@ public function testBase(): void $this->assertSame( '' . "\n" . - '' . "\n" . - '' . "\n" . + '' . "\n" . + '' . "\n" . 'Flowers' . "\n" . '', $picture->render() diff --git a/tests/Widget/RadioListTest.php b/tests/Widget/RadioListTest.php index cc1aa510..3d413d92 100644 --- a/tests/Widget/RadioListTest.php +++ b/tests/Widget/RadioListTest.php @@ -19,9 +19,9 @@ public function testBase(): void $this->assertSame( '' . "\n" . '
' . "\n" . - '' . "\n" . - '' . "\n" . - '' . "\n" . + '' . "\n" . + '' . "\n" . + '' . "\n" . '
', RadioList::create('test') ->items([1 => 'One', 2 => 'Two', 5 => 'Five']) @@ -40,7 +40,7 @@ public function testName(): void $this->assertSame( '
' . "\n" . - '' . "\n" . + '' . "\n" . '
', $widget->render() ); @@ -49,7 +49,7 @@ public function testName(): void public function testWithoutContainer(): void { $this->assertSame( - '', + '', RadioList::create('test') ->items([1 => 'One']) ->withoutContainer() @@ -61,16 +61,16 @@ public static function dataContainerTag(): array { return [ [ - '', + '', null, ], [ - '', + '', '', ], [ '
' . "\n" . - '' . "\n" . + '' . "\n" . '
', 'section', ], @@ -93,7 +93,7 @@ public function testContainerAttributes(): void { $this->assertSame( '
' . "\n" . - '' . "\n" . + '' . "\n" . '
', RadioList::create('test') ->items([1 => 'One']) @@ -105,8 +105,8 @@ public function testContainerAttributes(): void public function testRadioAttributes(): void { $this->assertSame( - '' . "\n" . - '', + '' . "\n" . + '', RadioList::create('test') ->items([ 1 => 'One', @@ -121,8 +121,8 @@ public function testRadioAttributes(): void public function testRadioAttributesMerge(): void { $this->assertSame( - '' . "\n" . - '', + '' . "\n" . + '', RadioList::create('test') ->items([ 1 => 'One', @@ -138,8 +138,8 @@ public function testRadioAttributesMerge(): void public function testReplaceRadioAttributes(): void { $this->assertSame( - '' . "\n" . - '', + '' . "\n" . + '', RadioList::create('test') ->items([ 1 => 'One', @@ -155,8 +155,8 @@ public function testReplaceRadioAttributes(): void public function testRadioLabelAttributes(): void { $this->assertSame( - '' . "\n" . - '', + '' . "\n" . + '', RadioList::create('test') ->items([1 => 'One', 2 => 'Two']) ->radioLabelAttributes(['class' => 'red']) @@ -168,8 +168,8 @@ public function testRadioLabelAttributes(): void public function testRadioLabelAttributesMerge(): void { $this->assertSame( - '' . "\n" . - '', + '' . "\n" . + '', RadioList::create('test') ->items([1 => 'One', 2 => 'Two']) ->radioLabelAttributes(['class' => 'red']) @@ -182,9 +182,9 @@ public function testRadioLabelAttributesMerge(): void public function testIndividualInputAttributes(): void { $this->assertSame( - '' . "\n" . - '' . "\n" . - '', + '' . "\n" . + '' . "\n" . + '', RadioList::create('test') ->items([ 1 => 'One', @@ -204,9 +204,9 @@ public function testIndividualInputAttributes(): void public function testIndividualUncheckInputAttributes(): void { $this->assertSame( - '' . "\n" . - '' . "\n" . - '', + '' . "\n" . + '' . "\n" . + '', RadioList::create('test') ->items([ 1 => 'One', @@ -225,9 +225,9 @@ public function testIndividualUncheckInputAttributes(): void public function testIndividualInputAttributesMerge(): void { $this->assertSame( - '' . "\n" . - '' . "\n" . - '', + '' . "\n" . + '' . "\n" . + '', RadioList::create('test') ->items([ 1 => 'One', @@ -251,9 +251,9 @@ public function testIndividualInputAttributesMerge(): void public function testIndividualInputAttributesReplace(): void { $this->assertSame( - '' . "\n" . - '' . "\n" . - '', + '' . "\n" . + '' . "\n" . + '', RadioList::create('test') ->items([ 1 => 'One', @@ -276,8 +276,8 @@ public function testIndividualInputAttributesReplace(): void public function testItems(): void { $this->assertSame( - '' . "\n" . - '', + '' . "\n" . + '', RadioList::create('test') ->items([ 1 => 'One', @@ -291,8 +291,8 @@ public function testItems(): void public function testItemsWithoutEncodeLabel(): void { $this->assertSame( - '' . "\n" . - '', + '' . "\n" . + '', RadioList::create('test') ->items([ 1 => 'One', @@ -307,18 +307,18 @@ public static function dataItemsFromValues(): array { return [ [ - '' . "\n" . - '', + '' . "\n" . + '', [1, 2], ], [ - '' . "\n" . - '', + '' . "\n" . + '', ['One', 'Two'], ], [ - '' . "\n" . - '', + '' . "\n" . + '', [true, false], ], ]; @@ -339,8 +339,8 @@ public function testItemsFromValues(string $expected, array $values): void public function testItemsFromValuesWithoutEncodeLabel(): void { $this->assertSame( - '' . "\n" . - '', + '' . "\n" . + '', RadioList::create('test') ->itemsFromValues([ 'One', @@ -358,32 +358,32 @@ public static function dataValue(): array ["
\n
", [], 42], [ '
' . "\n" . - '' . "\n" . - '' . "\n" . + '' . "\n" . + '' . "\n" . '
', [1 => 'One', 2 => 'Two'], null, ], [ '
' . "\n" . - '' . "\n" . - '' . "\n" . + '' . "\n" . + '' . "\n" . '
', [1 => 'One', 2 => 'Two'], 7, ], [ '
' . "\n" . - '' . "\n" . - '' . "\n" . + '' . "\n" . + '' . "\n" . '
', [1 => 'One', 2 => 'Two'], 1, ], [ '
' . "\n" . - '' . "\n" . - '' . "\n" . + '' . "\n" . + '' . "\n" . '
', [1 => 'One', 2 => 'Two'], 2, @@ -391,16 +391,16 @@ public static function dataValue(): array ["
\n
", [], StringEnum::A], [ '
' . "\n" . - '' . "\n" . - '' . "\n" . + '' . "\n" . + '' . "\n" . '
', [StringEnum::A->value => 'One', StringEnum::B->value => 'Two'], StringEnum::C, ], [ '
' . "\n" . - '' . "\n" . - '' . "\n" . + '' . "\n" . + '' . "\n" . '
', [StringEnum::A->value => 'One', StringEnum::B->value => 'Two'], StringEnum::A, @@ -408,16 +408,16 @@ public static function dataValue(): array ["
\n
", [], IntegerEnum::A], [ '
' . "\n" . - '' . "\n" . - '' . "\n" . + '' . "\n" . + '' . "\n" . '
', [IntegerEnum::A->value => 'One', IntegerEnum::B->value => 'Two'], IntegerEnum::C, ], [ '
' . "\n" . - '' . "\n" . - '' . "\n" . + '' . "\n" . + '' . "\n" . '
', [IntegerEnum::A->value => 'One', IntegerEnum::B->value => 'Two'], IntegerEnum::A, @@ -442,22 +442,22 @@ public static function dataForm(): array return [ [ '
' . "\n" . - '' . "\n" . - '' . "\n" . + '' . "\n" . + '' . "\n" . '
', null, ], [ '
' . "\n" . - '' . "\n" . - '' . "\n" . + '' . "\n" . + '' . "\n" . '
', '', ], [ '
' . "\n" . - '' . "\n" . - '' . "\n" . + '' . "\n" . + '' . "\n" . '
', 'post', ], @@ -489,8 +489,8 @@ public function testReadonly(): void $this->assertSame( '
' . "\n" . - '' . "\n" . - '' . "\n" . + '' . "\n" . + '' . "\n" . '
', $checkbox ->readonly() @@ -499,8 +499,8 @@ public function testReadonly(): void $this->assertSame( '
' . "\n" . - '' . "\n" . - '' . "\n" . + '' . "\n" . + '' . "\n" . '
', $checkbox ->readonly(false) @@ -508,8 +508,8 @@ public function testReadonly(): void ); $this->assertSame( '
' . "\n" . - '' . "\n" . - '' . "\n" . + '' . "\n" . + '' . "\n" . '
', $checkbox ->readonly(true) @@ -528,8 +528,8 @@ public function testDisabled(): void $this->assertSame( '
' . "\n" . - '' . "\n" . - '' . "\n" . + '' . "\n" . + '' . "\n" . '
', $checkbox ->disabled() @@ -538,8 +538,8 @@ public function testDisabled(): void $this->assertSame( '
' . "\n" . - '' . "\n" . - '' . "\n" . + '' . "\n" . + '' . "\n" . '
', $checkbox ->disabled(false) @@ -547,8 +547,8 @@ public function testDisabled(): void ); $this->assertSame( '
' . "\n" . - '' . "\n" . - '' . "\n" . + '' . "\n" . + '' . "\n" . '
', $checkbox ->disabled(true) @@ -562,16 +562,16 @@ public static function dataUncheckValue(): array return [ [ '
' . "\n" . - '' . "\n" . - '' . "\n" . + '' . "\n" . + '' . "\n" . '
', 'test', null, ], [ '
' . "\n" . - '' . "\n" . - '' . "\n" . + '' . "\n" . + '' . "\n" . '
', 'test', null, @@ -579,8 +579,8 @@ public static function dataUncheckValue(): array [ '' . "\n" . '
' . "\n" . - '' . "\n" . - '' . "\n" . + '' . "\n" . + '' . "\n" . '
', 'test', 7, @@ -588,8 +588,8 @@ public static function dataUncheckValue(): array [ '' . "\n" . '
' . "\n" . - '' . "\n" . - '' . "\n" . + '' . "\n" . + '' . "\n" . '
', 'test', 7, @@ -616,8 +616,8 @@ public function testUncheckValueDisabled(): void { $this->assertSame( '' . "\n" . - '' . "\n" . - '', + '' . "\n" . + '', RadioList::create('test') ->items([ 1 => 'One', @@ -634,8 +634,8 @@ public function testUncheckValueForm(): void { $this->assertSame( '' . "\n" . - '' . "\n" . - '', + '' . "\n" . + '', RadioList::create('test') ->items([ 1 => 'One', @@ -652,8 +652,8 @@ public function testSeparator(): void { $this->assertSame( '
' . "\n" . - '
' . - '' . "\n" . + '
' . + '' . "\n" . '
', RadioList::create('test') ->items([1 => 'One', 2 => 'Two']) @@ -666,8 +666,8 @@ public function testItemFormatter(): void { $this->assertSame( '
' . "\n" . - '
0)
' . - '
1)
' . "\n" . + '
0)
' . + '
1)
' . "\n" . '
', RadioList::create('test') ->items([1 => 'One', 2 => 'Two']) @@ -700,8 +700,8 @@ public function testDisableRadioLabelWrap(): void $this->assertSame( << - - + + HTML, $html, @@ -720,10 +720,10 @@ public function testRadioWrap(): void <<
- +
- +
HTML, @@ -793,10 +793,10 @@ public function testAddRadioWrapClass(string $expected, array $class): void << - + - + HTML, From 5dbeb8cf104cfe2a7805e43c9d3320875431a357 Mon Sep 17 00:00:00 2001 From: "i.lisitski" Date: Wed, 15 Jan 2025 00:15:25 +0300 Subject: [PATCH 03/12] Fix #234 add changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1f7f86b5..d766cb97 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## 3.9.1 under development - Bug #232: Render `loading` attribute before `src` (@samdark) +- Chg #234: Remove tag attributes sorting ## 3.9.0 November 29, 2024 From 3cce6735f5687b9b67b2be83751ea64a1a86c8a6 Mon Sep 17 00:00:00 2001 From: Illia Lisitski Date: Wed, 15 Jan 2025 15:40:48 +0300 Subject: [PATCH 04/12] Update CHANGELOG.md Co-authored-by: Alexander Makarov --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d766cb97..2597a2b2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ ## 3.9.1 under development - Bug #232: Render `loading` attribute before `src` (@samdark) -- Chg #234: Remove tag attributes sorting +- Chg #234: Remove tag attributes sorting (@FrankiFixx) ## 3.9.0 November 29, 2024 From 7b99374a569ae5401c990dad2275929c90b5514e Mon Sep 17 00:00:00 2001 From: samdark <47294+samdark@users.noreply.github.com> Date: Fri, 2 Jan 2026 12:46:09 +0000 Subject: [PATCH 05/12] Apply PHP CS Fixer and Rector changes (CI) --- tests/HtmlTest.php | 36 +-- tests/Tag/Base/BooleanInputTagTest.php | 18 +- tests/Tag/Base/MediaTagTest.php | 12 +- tests/Tag/ColgroupTest.php | 10 +- tests/Tag/FormTest.php | 8 +- tests/Tag/Input/FileTest.php | 20 +- tests/Tag/Input/RangeTest.php | 26 +- tests/Tag/InputTest.php | 8 +- tests/Tag/LinkTest.php | 4 +- tests/Tag/PictureTest.php | 12 +- tests/Tag/SelectTest.php | 8 +- tests/Widget/CheckboxListTest.php | 330 ++++++++++++------------- tests/Widget/RadioListTest.php | 300 +++++++++++----------- 13 files changed, 396 insertions(+), 396 deletions(-) diff --git a/tests/HtmlTest.php b/tests/HtmlTest.php index a683c43f..7e17c838 100644 --- a/tests/HtmlTest.php +++ b/tests/HtmlTest.php @@ -136,7 +136,7 @@ public function testMeta(): void $this->assertSame('', Html::meta()->render()); $this->assertSame( '', - Html::meta(['name' => 'keywords', 'content' => 'yii', 'id' => 'main'])->render() + Html::meta(['name' => 'keywords', 'content' => 'yii', 'id' => 'main'])->render(), ); } @@ -155,15 +155,15 @@ public function testCssFile(): void { $this->assertSame( '', - Html::cssFile('http://example.com')->render() + Html::cssFile('http://example.com')->render(), ); $this->assertSame( '', - Html::cssFile('')->render() + Html::cssFile('')->render(), ); $this->assertSame( '', - Html::cssFile('http://example.com', ['id' => 'main'])->render() + Html::cssFile('http://example.com', ['id' => 'main'])->render(), ); } @@ -179,7 +179,7 @@ public function testJavaScriptFile(): void ); $this->assertSame( '', - Html::javaScriptFile('http://example.com', ['id' => 'main'])->render() + Html::javaScriptFile('http://example.com', ['id' => 'main'])->render(), ); } @@ -207,7 +207,7 @@ public function testMailto(): void ); $this->assertSame( 'contact me', - Html::mailto('contact me', 'info@example.com', ['id' => 'contact'])->render() + Html::mailto('contact me', 'info@example.com', ['id' => 'contact'])->render(), ); } @@ -530,12 +530,12 @@ public function testTextarea(): void public function testCheckboxList(): void { $this->assertSame( - '' . "\n" . - '
' . "\n" . - '' . "\n" . - '' . "\n" . - '' . "\n" . - '
', + '' . "\n" + . '
' . "\n" + . '' . "\n" + . '' . "\n" + . '' . "\n" + . '
', Html::checkboxList('test') ->items([1 => 'One', 2 => 'Two', 5 => 'Five']) ->uncheckValue(0) @@ -548,12 +548,12 @@ public function testCheckboxList(): void public function testRadioList(): void { $this->assertSame( - '' . "\n" . - '
' . "\n" . - '' . "\n" . - '' . "\n" . - '' . "\n" . - '
', + '' . "\n" + . '
' . "\n" + . '' . "\n" + . '' . "\n" + . '' . "\n" + . '
', Html::radioList('test') ->items([1 => 'One', 2 => 'Two', 5 => 'Five']) ->uncheckValue(0) diff --git a/tests/Tag/Base/BooleanInputTagTest.php b/tests/Tag/Base/BooleanInputTagTest.php index 87b9a949..59bf58fa 100644 --- a/tests/Tag/Base/BooleanInputTagTest.php +++ b/tests/Tag/Base/BooleanInputTagTest.php @@ -12,9 +12,9 @@ final class BooleanInputTagTest extends TestCase { public function testChecked(): void { - $this->assertSame('', (string)TestBooleanInputTag::tag()->checked()); - $this->assertSame('', (string)TestBooleanInputTag::tag()->checked(false)); - $this->assertSame('', (string)TestBooleanInputTag::tag() + $this->assertSame('', (string) TestBooleanInputTag::tag()->checked()); + $this->assertSame('', (string) TestBooleanInputTag::tag()->checked(false)); + $this->assertSame('', (string) TestBooleanInputTag::tag() ->checked(true) ->checked(false)); } @@ -190,8 +190,8 @@ public function testUncheckValue(string $expected, ?string $name, $value): void public function testUncheckValueDisabled(): void { $this->assertSame( - '' . - '', + '' + . '', TestBooleanInputTag::tag() ->name('color') ->uncheckValue(7) @@ -203,8 +203,8 @@ public function testUncheckValueDisabled(): void public function testUncheckValueForm(): void { $this->assertSame( - '' . - '', + '' + . '', TestBooleanInputTag::tag() ->name('color') ->uncheckValue(7) @@ -216,8 +216,8 @@ public function testUncheckValueForm(): void public function testUncheckValueWithLabel(): void { $this->assertSame( - '' . - '', + '' + . '', TestBooleanInputTag::tag() ->name('color') ->uncheckValue(7) diff --git a/tests/Tag/Base/MediaTagTest.php b/tests/Tag/Base/MediaTagTest.php index cfe1078b..f78a2a0a 100644 --- a/tests/Tag/Base/MediaTagTest.php +++ b/tests/Tag/Base/MediaTagTest.php @@ -168,12 +168,12 @@ public function testWrongTrackDefault(): void ); $this->assertSame( - '' . "\n" . - '' . "\n" . - '' . "\n" . - '' . "\n" . - '', - $tag->render() + '' . "\n" + . '' . "\n" + . '' . "\n" + . '' . "\n" + . '', + $tag->render(), ); } diff --git a/tests/Tag/ColgroupTest.php b/tests/Tag/ColgroupTest.php index 7756bf17..b843fe6f 100644 --- a/tests/Tag/ColgroupTest.php +++ b/tests/Tag/ColgroupTest.php @@ -14,11 +14,11 @@ final class ColgroupTest extends TestCase public function testBase(): void { $this->assertSame( - '' . "\n" . - '' . "\n" . - '' . "\n" . - '' . "\n" . - '', + '' . "\n" + . '' . "\n" + . '' . "\n" + . '' . "\n" + . '', Colgroup::tag() ->columns( Col::tag(), diff --git a/tests/Tag/FormTest.php b/tests/Tag/FormTest.php index d617c8a2..d1e2adde 100644 --- a/tests/Tag/FormTest.php +++ b/tests/Tag/FormTest.php @@ -18,10 +18,10 @@ public function testBase(): void $tag = Form::tag(); $this->assertSame( - '
' . - '' . - '' . - '
', + '
' + . '' + . '' + . '
', $tag ->method('GET') ->action('https://example.com/send') diff --git a/tests/Tag/Input/FileTest.php b/tests/Tag/Input/FileTest.php index cabc3f6a..068205a6 100644 --- a/tests/Tag/Input/FileTest.php +++ b/tests/Tag/Input/FileTest.php @@ -55,8 +55,8 @@ public function testUncheckValue(string $expected, ?string $name, $value): void public function testUncheckValueDisabled(): void { $this->assertSame( - '' . - '', + '' + . '', File::tag() ->name('avatar') ->uncheckValue(7) @@ -68,8 +68,8 @@ public function testUncheckValueDisabled(): void public function testUncheckValueForm(): void { $this->assertSame( - '' . - '', + '' + . '', File::tag() ->name('avatar') ->uncheckValue(7) @@ -89,9 +89,9 @@ public function testUncheckInputAttributes(): void ->render(); $this->assertSame( - '' . - '', - $result + '' + . '', + $result, ); } @@ -106,9 +106,9 @@ public function testReplaceUncheckInputAttributes(): void ->render(); $this->assertSame( - '' . - '', - $result + '' + . '', + $result, ); } diff --git a/tests/Tag/Input/RangeTest.php b/tests/Tag/Input/RangeTest.php index 92407401..249fbcc6 100644 --- a/tests/Tag/Input/RangeTest.php +++ b/tests/Tag/Input/RangeTest.php @@ -22,7 +22,7 @@ public function testBase(): void $this->assertSame( '', - $tag->render() + $tag->render(), ); } @@ -122,10 +122,10 @@ public function testAddOutputAttributes(): void ->addOutputAttributes(['id' => 'UID']); $this->assertSame( - '' . - "\n" . '-', - $tag->render() + '' + . "\n" . '-', + $tag->render(), ); } @@ -179,10 +179,10 @@ public function testOutputWithCustomAttributes(): void ->outputAttributes(['class' => 'red']); $this->assertMatchesRegularExpression( - '~' . - "\n" . '-~', - $tag->render() + '~' + . "\n" . '-~', + $tag->render(), ); } @@ -193,10 +193,10 @@ public function testOutputWithValue(): void ->value(10); $this->assertMatchesRegularExpression( - '~' . - "\n" . '10~', - $tag->render() + '~' + . "\n" . '10~', + $tag->render(), ); } diff --git a/tests/Tag/InputTest.php b/tests/Tag/InputTest.php index 16a37d68..a559617f 100644 --- a/tests/Tag/InputTest.php +++ b/tests/Tag/InputTest.php @@ -49,7 +49,7 @@ public function testFile(): void { $this->assertSame( '', - (string)Input::file('photo', 'c:\\path\\') + (string) Input::file('photo', 'c:\\path\\'), ); } @@ -57,7 +57,7 @@ public function testCheckbox(): void { $this->assertSame( '', - (string)Input::checkbox('subscribe')->checked() + (string) Input::checkbox('subscribe')->checked(), ); } @@ -65,7 +65,7 @@ public function testRadio(): void { $this->assertSame( '', - (string)Input::radio('count', 'one') + (string) Input::radio('count', 'one'), ); } @@ -73,7 +73,7 @@ public function testRange(): void { $this->assertSame( '', - (string) Input::range('count', 10) + (string) Input::range('count', 10), ); } diff --git a/tests/Tag/LinkTest.php b/tests/Tag/LinkTest.php index d9a217c2..edd45638 100644 --- a/tests/Tag/LinkTest.php +++ b/tests/Tag/LinkTest.php @@ -14,7 +14,7 @@ public function testBase(): void { $this->assertSame( '', - (string)Link::tag() + (string) Link::tag() ->url('/rss') ->type('application/rss+xml') ->rel('alternate') @@ -26,7 +26,7 @@ public function testToCssFile(): void { $this->assertSame( '', - (string)Link::toCssFile('main.css') + (string) Link::toCssFile('main.css'), ); } diff --git a/tests/Tag/PictureTest.php b/tests/Tag/PictureTest.php index fc727ff8..f0019941 100644 --- a/tests/Tag/PictureTest.php +++ b/tests/Tag/PictureTest.php @@ -30,12 +30,12 @@ public function testBase(): void ); $this->assertSame( - '' . "\n" . - '' . "\n" . - '' . "\n" . - 'Flowers' . "\n" . - '', - $picture->render() + '' . "\n" + . '' . "\n" + . '' . "\n" + . 'Flowers' . "\n" + . '', + $picture->render(), ); } diff --git a/tests/Tag/SelectTest.php b/tests/Tag/SelectTest.php index dc410638..eb30355c 100644 --- a/tests/Tag/SelectTest.php +++ b/tests/Tag/SelectTest.php @@ -37,13 +37,13 @@ public static function dataNameForMultiple(): array ['', null], ['', ''], [ - '' . "\n" . - '', + '' . "\n" + . '', 'age', ], [ - '' . "\n" . - '', + '' . "\n" + . '', 'place[]', ], ]; diff --git a/tests/Widget/CheckboxListTest.php b/tests/Widget/CheckboxListTest.php index 2df4810e..edd2d2ff 100644 --- a/tests/Widget/CheckboxListTest.php +++ b/tests/Widget/CheckboxListTest.php @@ -19,12 +19,12 @@ final class CheckboxListTest extends TestCase public function testBase(): void { $this->assertSame( - '' . "\n" . - '
' . "\n" . - '' . "\n" . - '' . "\n" . - '' . "\n" . - '
', + '' . "\n" + . '
' . "\n" + . '' . "\n" + . '' . "\n" + . '' . "\n" + . '
', CheckboxList::create('test') ->items([1 => 'One', 2 => 'Two', 5 => 'Five']) ->uncheckValue(0) @@ -41,10 +41,10 @@ public function testName(): void ->name('b'); $this->assertSame( - '
' . "\n" . - '' . "\n" . - '
', - $widget->render() + '
' . "\n" + . '' . "\n" + . '
', + $widget->render(), ); } @@ -71,9 +71,9 @@ public static function dataContainerTag(): array '', ], [ - '
' . "\n" . - '' . "\n" . - '
', + '
' . "\n" + . '' . "\n" + . '
', 'section', ], ]; @@ -94,9 +94,9 @@ public function testContainerTag(string $expected, ?string $name): void public function testContainerAttributes(): void { $this->assertSame( - '
' . "\n" . - '' . "\n" . - '
', + '
' . "\n" + . '' . "\n" + . '
', CheckboxList::create('test') ->items([1 => 'One']) ->containerAttributes(['id' => 'main']) @@ -107,8 +107,8 @@ public function testContainerAttributes(): void public function testCheckboxAttributes(): void { $this->assertSame( - '' . "\n" . - '', + '' . "\n" + . '', CheckboxList::create('test') ->items([ 1 => 'One', @@ -123,8 +123,8 @@ public function testCheckboxAttributes(): void public function testCheckboxAttributesMerge(): void { $this->assertSame( - '' . "\n" . - '', + '' . "\n" + . '', CheckboxList::create('test') ->items([ 1 => 'One', @@ -140,8 +140,8 @@ public function testCheckboxAttributesMerge(): void public function testReplaceCheckboxAttributes(): void { $this->assertSame( - '' . "\n" . - '', + '' . "\n" + . '', CheckboxList::create('test') ->items([ 1 => 'One', @@ -157,8 +157,8 @@ public function testReplaceCheckboxAttributes(): void public function testCheckboxLabelAttributes(): void { $this->assertSame( - '' . "\n" . - '', + '' . "\n" + . '', CheckboxList::create('test') ->items([1 => 'One', 2 => 'Two']) ->checkboxLabelAttributes(['class' => 'red']) @@ -170,8 +170,8 @@ public function testCheckboxLabelAttributes(): void public function testCheckboxLabelAttributesMerge(): void { $this->assertSame( - '' . "\n" . - '', + '' . "\n" + . '', CheckboxList::create('test') ->items([1 => 'One', 2 => 'Two']) ->checkboxLabelAttributes(['class' => 'red']) @@ -184,9 +184,9 @@ public function testCheckboxLabelAttributesMerge(): void public function testAddIndividualInputAttributes(): void { $this->assertSame( - '' . "\n" . - '' . "\n" . - '', + '' . "\n" + . '' . "\n" + . '', CheckboxList::create('test') ->items([ 1 => 'One', @@ -206,9 +206,9 @@ public function testAddIndividualInputAttributes(): void public function testIndividualUncheckInputAttributes(): void { $this->assertSame( - '' . "\n" . - '' . "\n" . - '', + '' . "\n" + . '' . "\n" + . '', CheckboxList::create('test') ->items([ 1 => 'One', @@ -227,9 +227,9 @@ public function testIndividualUncheckInputAttributes(): void public function testIndividualInputAttributesMerge(): void { $this->assertSame( - '' . "\n" . - '' . "\n" . - '', + '' . "\n" + . '' . "\n" + . '', CheckboxList::create('test') ->items([ 1 => 'One', @@ -253,9 +253,9 @@ public function testIndividualInputAttributesMerge(): void public function testIndividualInputAttributesReplace(): void { $this->assertSame( - '' . "\n" . - '' . "\n" . - '', + '' . "\n" + . '' . "\n" + . '', CheckboxList::create('test') ->items([ 1 => 'One', @@ -278,8 +278,8 @@ public function testIndividualInputAttributesReplace(): void public function testItems(): void { $this->assertSame( - '' . "\n" . - '', + '' . "\n" + . '', CheckboxList::create('test') ->items([ 1 => 'One', @@ -293,8 +293,8 @@ public function testItems(): void public function testItemsWithoutEncodeLabel(): void { $this->assertSame( - '' . "\n" . - '', + '' . "\n" + . '', CheckboxList::create('test') ->items([ 1 => 'One', @@ -309,18 +309,18 @@ public static function dataItemsFromValues(): array { return [ [ - '' . "\n" . - '', + '' . "\n" + . '', [1, 2], ], [ - '' . "\n" . - '', + '' . "\n" + . '', ['One', 'Two'], ], [ - '' . "\n" . - '', + '' . "\n" + . '', [true, false], ], ]; @@ -341,8 +341,8 @@ public function testItemsFromValues(string $expected, array $values): void public function testItemsFromValuesWithoutEncodeLabel(): void { $this->assertSame( - '' . "\n" . - '', + '' . "\n" + . '', CheckboxList::create('test') ->itemsFromValues([ 'One', @@ -359,95 +359,95 @@ public static function dataValue(): array ["
\n
", [], []], ["
\n
", [], [42]], [ - '
' . "\n" . - '' . "\n" . - '' . "\n" . - '
', + '
' . "\n" + . '' . "\n" + . '' . "\n" + . '
', [1 => 'One', 2 => 'Two'], [], ], [ - '
' . "\n" . - '' . "\n" . - '' . "\n" . - '
', + '
' . "\n" + . '' . "\n" + . '' . "\n" + . '
', [1 => 'One', 2 => 'Two'], [7], ], [ - '
' . "\n" . - '' . "\n" . - '' . "\n" . - '
', + '
' . "\n" + . '' . "\n" + . '' . "\n" + . '
', [1 => 'One', 2 => 'Two'], [1], ], [ - '
' . "\n" . - '' . "\n" . - '' . "\n" . - '
', + '
' . "\n" + . '' . "\n" + . '' . "\n" + . '
', [1 => 'One', 2 => 'Two'], [2], ], [ - '
' . "\n" . - '' . "\n" . - '' . "\n" . - '' . "\n" . - '
', + '
' . "\n" + . '' . "\n" + . '' . "\n" + . '' . "\n" + . '
', [1 => 'One', 2 => 'Two', 3 => 'Three'], [1, 3], ], ["
\n
", [], [StringEnum::A]], [ - '
' . "\n" . - '' . "\n" . - '' . "\n" . - '
', + '
' . "\n" + . '' . "\n" + . '' . "\n" + . '
', [StringEnum::A->value => 'One', StringEnum::B->value => 'Two'], [StringEnum::C], ], [ - '
' . "\n" . - '' . "\n" . - '' . "\n" . - '
', + '
' . "\n" + . '' . "\n" + . '' . "\n" + . '
', [StringEnum::A->value => 'One', StringEnum::B->value => 'Two'], [StringEnum::B], ], [ - '
' . "\n" . - '' . "\n" . - '' . "\n" . - '' . "\n" . - '
', + '
' . "\n" + . '' . "\n" + . '' . "\n" + . '' . "\n" + . '
', [StringEnum::A->value => 'One', StringEnum::B->value => 'Two', StringEnum::C->value => 'Three'], [StringEnum::B, StringEnum::C], ], ["
\n
", [], [IntegerEnum::A]], [ - '
' . "\n" . - '' . "\n" . - '' . "\n" . - '
', + '
' . "\n" + . '' . "\n" + . '' . "\n" + . '
', [IntegerEnum::A->value => 'One', IntegerEnum::B->value => 'Two'], [IntegerEnum::C], ], [ - '
' . "\n" . - '' . "\n" . - '' . "\n" . - '
', + '
' . "\n" + . '' . "\n" + . '' . "\n" + . '
', [IntegerEnum::A->value => 'One', IntegerEnum::B->value => 'Two'], [IntegerEnum::B], ], [ - '
' . "\n" . - '' . "\n" . - '' . "\n" . - '' . "\n" . - '
', + '
' . "\n" + . '' . "\n" + . '' . "\n" + . '' . "\n" + . '
', [IntegerEnum::A->value => 'One', IntegerEnum::B->value => 'Two', IntegerEnum::C->value => 'Three'], [IntegerEnum::B, IntegerEnum::C], ], @@ -491,24 +491,24 @@ public static function dataForm(): array { return [ [ - '
' . "\n" . - '' . "\n" . - '' . "\n" . - '
', + '
' . "\n" + . '' . "\n" + . '' . "\n" + . '
', null, ], [ - '
' . "\n" . - '' . "\n" . - '' . "\n" . - '
', + '
' . "\n" + . '' . "\n" + . '' . "\n" + . '
', '', ], [ - '
' . "\n" . - '' . "\n" . - '' . "\n" . - '
', + '
' . "\n" + . '' . "\n" + . '' . "\n" + . '
', 'post', ], ]; @@ -538,29 +538,29 @@ public function testReadonly(): void ]); $this->assertSame( - '
' . "\n" . - '' . "\n" . - '' . "\n" . - '
', + '
' . "\n" + . '' . "\n" + . '' . "\n" + . '
', $checkbox ->readonly() ->render(), ); $this->assertSame( - '
' . "\n" . - '' . "\n" . - '' . "\n" . - '
', + '
' . "\n" + . '' . "\n" + . '' . "\n" + . '
', $checkbox ->readonly(false) ->render(), ); $this->assertSame( - '
' . "\n" . - '' . "\n" . - '' . "\n" . - '
', + '
' . "\n" + . '' . "\n" + . '' . "\n" + . '
', $checkbox ->readonly(true) ->readonly(false) @@ -577,29 +577,29 @@ public function testDisabled(): void ]); $this->assertSame( - '
' . "\n" . - '' . "\n" . - '' . "\n" . - '
', + '
' . "\n" + . '' . "\n" + . '' . "\n" + . '
', $checkbox ->disabled() ->render(), ); $this->assertSame( - '
' . "\n" . - '' . "\n" . - '' . "\n" . - '
', + '
' . "\n" + . '' . "\n" + . '' . "\n" + . '
', $checkbox ->disabled(false) ->render(), ); $this->assertSame( - '
' . "\n" . - '' . "\n" . - '' . "\n" . - '
', + '
' . "\n" + . '' . "\n" + . '' . "\n" + . '
', $checkbox ->disabled(true) ->disabled(false) @@ -611,36 +611,36 @@ public static function dataUncheckValue(): array { return [ [ - '
' . "\n" . - '' . "\n" . - '' . "\n" . - '
', + '
' . "\n" + . '' . "\n" + . '' . "\n" + . '
', 'test', null, ], [ - '
' . "\n" . - '' . "\n" . - '' . "\n" . - '
', + '
' . "\n" + . '' . "\n" + . '' . "\n" + . '
', 'test[]', null, ], [ - '' . "\n" . - '
' . "\n" . - '' . "\n" . - '' . "\n" . - '
', + '' . "\n" + . '
' . "\n" + . '' . "\n" + . '' . "\n" + . '
', 'test', 7, ], [ - '' . "\n" . - '
' . "\n" . - '' . "\n" . - '' . "\n" . - '
', + '' . "\n" + . '
' . "\n" + . '' . "\n" + . '' . "\n" + . '
', 'test[]', 7, ], @@ -665,9 +665,9 @@ public function testUncheckValue(string $expected, string $name, $value): void public function testUncheckValueDisabled(): void { $this->assertSame( - '' . "\n" . - '' . "\n" . - '', + '' . "\n" + . '' . "\n" + . '', CheckboxList::create('test') ->items([ 1 => 'One', @@ -683,9 +683,9 @@ public function testUncheckValueDisabled(): void public function testUncheckValueForm(): void { $this->assertSame( - '' . "\n" . - '' . "\n" . - '', + '' . "\n" + . '' . "\n" + . '', CheckboxList::create('test') ->items([ 1 => 'One', @@ -701,10 +701,10 @@ public function testUncheckValueForm(): void public function testSeparator(): void { $this->assertSame( - '
' . "\n" . - '
' . - '' . "\n" . - '
', + '
' . "\n" + . '
' + . '' . "\n" + . '
', CheckboxList::create('test') ->items([1 => 'One', 2 => 'Two']) ->separator('
') @@ -715,10 +715,10 @@ public function testSeparator(): void public function testItemFormatter(): void { $this->assertSame( - '
' . "\n" . - '
0)
' . - '
1)
' . "\n" . - '
', + '
' . "\n" + . '
0)
' + . '
1)
' . "\n" + . '
', CheckboxList::create('test') ->items([1 => 'One', 2 => 'Two']) ->itemFormatter(fn(CheckboxItem $item): string => '
' diff --git a/tests/Widget/RadioListTest.php b/tests/Widget/RadioListTest.php index e255d098..8c9333e6 100644 --- a/tests/Widget/RadioListTest.php +++ b/tests/Widget/RadioListTest.php @@ -17,12 +17,12 @@ final class RadioListTest extends TestCase public function testBase(): void { $this->assertSame( - '' . "\n" . - '
' . "\n" . - '' . "\n" . - '' . "\n" . - '' . "\n" . - '
', + '' . "\n" + . '
' . "\n" + . '' . "\n" + . '' . "\n" + . '' . "\n" + . '
', RadioList::create('test') ->items([1 => 'One', 2 => 'Two', 5 => 'Five']) ->uncheckValue(0) @@ -39,10 +39,10 @@ public function testName(): void ->name('b'); $this->assertSame( - '
' . "\n" . - '' . "\n" . - '
', - $widget->render() + '
' . "\n" + . '' . "\n" + . '
', + $widget->render(), ); } @@ -69,9 +69,9 @@ public static function dataContainerTag(): array '', ], [ - '
' . "\n" . - '' . "\n" . - '
', + '
' . "\n" + . '' . "\n" + . '
', 'section', ], ]; @@ -92,9 +92,9 @@ public function testContainerTag(string $expected, ?string $name): void public function testContainerAttributes(): void { $this->assertSame( - '
' . "\n" . - '' . "\n" . - '
', + '
' . "\n" + . '' . "\n" + . '
', RadioList::create('test') ->items([1 => 'One']) ->containerAttributes(['id' => 'main']) @@ -105,8 +105,8 @@ public function testContainerAttributes(): void public function testRadioAttributes(): void { $this->assertSame( - '' . "\n" . - '', + '' . "\n" + . '', RadioList::create('test') ->items([ 1 => 'One', @@ -121,8 +121,8 @@ public function testRadioAttributes(): void public function testRadioAttributesMerge(): void { $this->assertSame( - '' . "\n" . - '', + '' . "\n" + . '', RadioList::create('test') ->items([ 1 => 'One', @@ -138,8 +138,8 @@ public function testRadioAttributesMerge(): void public function testReplaceRadioAttributes(): void { $this->assertSame( - '' . "\n" . - '', + '' . "\n" + . '', RadioList::create('test') ->items([ 1 => 'One', @@ -155,8 +155,8 @@ public function testReplaceRadioAttributes(): void public function testRadioLabelAttributes(): void { $this->assertSame( - '' . "\n" . - '', + '' . "\n" + . '', RadioList::create('test') ->items([1 => 'One', 2 => 'Two']) ->radioLabelAttributes(['class' => 'red']) @@ -168,8 +168,8 @@ public function testRadioLabelAttributes(): void public function testRadioLabelAttributesMerge(): void { $this->assertSame( - '' . "\n" . - '', + '' . "\n" + . '', RadioList::create('test') ->items([1 => 'One', 2 => 'Two']) ->radioLabelAttributes(['class' => 'red']) @@ -182,9 +182,9 @@ public function testRadioLabelAttributesMerge(): void public function testIndividualInputAttributes(): void { $this->assertSame( - '' . "\n" . - '' . "\n" . - '', + '' . "\n" + . '' . "\n" + . '', RadioList::create('test') ->items([ 1 => 'One', @@ -204,9 +204,9 @@ public function testIndividualInputAttributes(): void public function testIndividualUncheckInputAttributes(): void { $this->assertSame( - '' . "\n" . - '' . "\n" . - '', + '' . "\n" + . '' . "\n" + . '', RadioList::create('test') ->items([ 1 => 'One', @@ -225,9 +225,9 @@ public function testIndividualUncheckInputAttributes(): void public function testIndividualInputAttributesMerge(): void { $this->assertSame( - '' . "\n" . - '' . "\n" . - '', + '' . "\n" + . '' . "\n" + . '', RadioList::create('test') ->items([ 1 => 'One', @@ -251,9 +251,9 @@ public function testIndividualInputAttributesMerge(): void public function testIndividualInputAttributesReplace(): void { $this->assertSame( - '' . "\n" . - '' . "\n" . - '', + '' . "\n" + . '' . "\n" + . '', RadioList::create('test') ->items([ 1 => 'One', @@ -276,8 +276,8 @@ public function testIndividualInputAttributesReplace(): void public function testItems(): void { $this->assertSame( - '' . "\n" . - '', + '' . "\n" + . '', RadioList::create('test') ->items([ 1 => 'One', @@ -291,8 +291,8 @@ public function testItems(): void public function testItemsWithoutEncodeLabel(): void { $this->assertSame( - '' . "\n" . - '', + '' . "\n" + . '', RadioList::create('test') ->items([ 1 => 'One', @@ -307,18 +307,18 @@ public static function dataItemsFromValues(): array { return [ [ - '' . "\n" . - '', + '' . "\n" + . '', [1, 2], ], [ - '' . "\n" . - '', + '' . "\n" + . '', ['One', 'Two'], ], [ - '' . "\n" . - '', + '' . "\n" + . '', [true, false], ], ]; @@ -339,8 +339,8 @@ public function testItemsFromValues(string $expected, array $values): void public function testItemsFromValuesWithoutEncodeLabel(): void { $this->assertSame( - '' . "\n" . - '', + '' . "\n" + . '', RadioList::create('test') ->itemsFromValues([ 'One', @@ -357,68 +357,68 @@ public static function dataValue(): array ["
\n
", [], null], ["
\n
", [], 42], [ - '
' . "\n" . - '' . "\n" . - '' . "\n" . - '
', + '
' . "\n" + . '' . "\n" + . '' . "\n" + . '
', [1 => 'One', 2 => 'Two'], null, ], [ - '
' . "\n" . - '' . "\n" . - '' . "\n" . - '
', + '
' . "\n" + . '' . "\n" + . '' . "\n" + . '
', [1 => 'One', 2 => 'Two'], 7, ], [ - '
' . "\n" . - '' . "\n" . - '' . "\n" . - '
', + '
' . "\n" + . '' . "\n" + . '' . "\n" + . '
', [1 => 'One', 2 => 'Two'], 1, ], [ - '
' . "\n" . - '' . "\n" . - '' . "\n" . - '
', + '
' . "\n" + . '' . "\n" + . '' . "\n" + . '
', [1 => 'One', 2 => 'Two'], 2, ], ["
\n
", [], StringEnum::A], [ - '
' . "\n" . - '' . "\n" . - '' . "\n" . - '
', + '
' . "\n" + . '' . "\n" + . '' . "\n" + . '
', [StringEnum::A->value => 'One', StringEnum::B->value => 'Two'], StringEnum::C, ], [ - '
' . "\n" . - '' . "\n" . - '' . "\n" . - '
', + '
' . "\n" + . '' . "\n" + . '' . "\n" + . '
', [StringEnum::A->value => 'One', StringEnum::B->value => 'Two'], StringEnum::A, ], ["
\n
", [], IntegerEnum::A], [ - '
' . "\n" . - '' . "\n" . - '' . "\n" . - '
', + '
' . "\n" + . '' . "\n" + . '' . "\n" + . '
', [IntegerEnum::A->value => 'One', IntegerEnum::B->value => 'Two'], IntegerEnum::C, ], [ - '
' . "\n" . - '' . "\n" . - '' . "\n" . - '
', + '
' . "\n" + . '' . "\n" + . '' . "\n" + . '
', [IntegerEnum::A->value => 'One', IntegerEnum::B->value => 'Two'], IntegerEnum::A, ], @@ -441,24 +441,24 @@ public static function dataForm(): array { return [ [ - '
' . "\n" . - '' . "\n" . - '' . "\n" . - '
', + '
' . "\n" + . '' . "\n" + . '' . "\n" + . '
', null, ], [ - '
' . "\n" . - '' . "\n" . - '' . "\n" . - '
', + '
' . "\n" + . '' . "\n" + . '' . "\n" + . '
', '', ], [ - '
' . "\n" . - '' . "\n" . - '' . "\n" . - '
', + '
' . "\n" + . '' . "\n" + . '' . "\n" + . '
', 'post', ], ]; @@ -488,29 +488,29 @@ public function testReadonly(): void ]); $this->assertSame( - '
' . "\n" . - '' . "\n" . - '' . "\n" . - '
', + '
' . "\n" + . '' . "\n" + . '' . "\n" + . '
', $checkbox ->readonly() ->render(), ); $this->assertSame( - '
' . "\n" . - '' . "\n" . - '' . "\n" . - '
', + '
' . "\n" + . '' . "\n" + . '' . "\n" + . '
', $checkbox ->readonly(false) ->render(), ); $this->assertSame( - '
' . "\n" . - '' . "\n" . - '' . "\n" . - '
', + '
' . "\n" + . '' . "\n" + . '' . "\n" + . '
', $checkbox ->readonly(true) ->readonly(false) @@ -527,29 +527,29 @@ public function testDisabled(): void ]); $this->assertSame( - '
' . "\n" . - '' . "\n" . - '' . "\n" . - '
', + '
' . "\n" + . '' . "\n" + . '' . "\n" + . '
', $checkbox ->disabled() ->render(), ); $this->assertSame( - '
' . "\n" . - '' . "\n" . - '' . "\n" . - '
', + '
' . "\n" + . '' . "\n" + . '' . "\n" + . '
', $checkbox ->disabled(false) ->render(), ); $this->assertSame( - '
' . "\n" . - '' . "\n" . - '' . "\n" . - '
', + '
' . "\n" + . '' . "\n" + . '' . "\n" + . '
', $checkbox ->disabled(true) ->disabled(false) @@ -561,36 +561,36 @@ public static function dataUncheckValue(): array { return [ [ - '
' . "\n" . - '' . "\n" . - '' . "\n" . - '
', + '
' . "\n" + . '' . "\n" + . '' . "\n" + . '
', 'test', null, ], [ - '
' . "\n" . - '' . "\n" . - '' . "\n" . - '
', + '
' . "\n" + . '' . "\n" + . '' . "\n" + . '
', 'test', null, ], [ - '' . "\n" . - '
' . "\n" . - '' . "\n" . - '' . "\n" . - '
', + '' . "\n" + . '
' . "\n" + . '' . "\n" + . '' . "\n" + . '
', 'test', 7, ], [ - '' . "\n" . - '
' . "\n" . - '' . "\n" . - '' . "\n" . - '
', + '' . "\n" + . '
' . "\n" + . '' . "\n" + . '' . "\n" + . '
', 'test', 7, ], @@ -615,9 +615,9 @@ public function testUncheckValue(string $expected, string $name, $value): void public function testUncheckValueDisabled(): void { $this->assertSame( - '' . "\n" . - '' . "\n" . - '', + '' . "\n" + . '' . "\n" + . '', RadioList::create('test') ->items([ 1 => 'One', @@ -633,9 +633,9 @@ public function testUncheckValueDisabled(): void public function testUncheckValueForm(): void { $this->assertSame( - '' . "\n" . - '' . "\n" . - '', + '' . "\n" + . '' . "\n" + . '', RadioList::create('test') ->items([ 1 => 'One', @@ -651,10 +651,10 @@ public function testUncheckValueForm(): void public function testSeparator(): void { $this->assertSame( - '
' . "\n" . - '
' . - '' . "\n" . - '
', + '
' . "\n" + . '
' + . '' . "\n" + . '
', RadioList::create('test') ->items([1 => 'One', 2 => 'Two']) ->separator('
') @@ -665,10 +665,10 @@ public function testSeparator(): void public function testItemFormatter(): void { $this->assertSame( - '
' . "\n" . - '
0)
' . - '
1)
' . "\n" . - '
', + '
' . "\n" + . '
0)
' + . '
1)
' . "\n" + . '
', RadioList::create('test') ->items([1 => 'One', 2 => 'Two']) ->itemFormatter(fn(RadioItem $item): string => '
' From 149ad617fda3e4a5bb3a3b5840dc2b4ecca96b66 Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Fri, 2 Jan 2026 16:29:50 +0300 Subject: [PATCH 06/12] Fix test --- tests/HtmlTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/HtmlTest.php b/tests/HtmlTest.php index 7e17c838..2ba682cc 100644 --- a/tests/HtmlTest.php +++ b/tests/HtmlTest.php @@ -706,7 +706,7 @@ public function testLi(): void $this->assertSame('
  • Hello
  • ', Html::li(Html::span('Hello'))->render()); $this->assertSame( - '
  • Content
  • ', + '
  • Content
  • ', Html::li('Content', ['class' => 'item', 'id' => 'item-1'])->render(), ); $this->assertSame('
  • ', Html::li(attributes: ['class' => 'empty'])->render()); From cca3a4ef832ef4cc0f400c1b51baee421be23051 Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Fri, 2 Jan 2026 16:30:48 +0300 Subject: [PATCH 07/12] Fix assertion in ColorTest for input rendering --- tests/Tag/Input/ColorTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Tag/Input/ColorTest.php b/tests/Tag/Input/ColorTest.php index 576299ff..b30d761d 100644 --- a/tests/Tag/Input/ColorTest.php +++ b/tests/Tag/Input/ColorTest.php @@ -12,7 +12,7 @@ final class ColorTest extends TestCase public function testBase(): void { $this->assertSame( - '', + '', Color::tag() ->name('color') ->value('#ff0000') From 31b014ecc02ce086c56cd82e7f7b536c5b1515f5 Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Fri, 2 Jan 2026 16:31:34 +0300 Subject: [PATCH 08/12] Fix color input test assertion for name attribute --- tests/HtmlTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/HtmlTest.php b/tests/HtmlTest.php index 2ba682cc..2d1b0337 100644 --- a/tests/HtmlTest.php +++ b/tests/HtmlTest.php @@ -385,7 +385,7 @@ public function testTextInput(): void public function testColorInput(): void { $this->assertSame('', Html::color()->render()); - $this->assertSame('', Html::color('')->render()); + $this->assertSame('', Html::color('')->render()); $this->assertSame('', Html::color(null, '')->render()); $this->assertSame('', Html::color('test')->render()); $this->assertSame( From 12d05883ee9fb2eeb242d22e29d20aba72fc0ef4 Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Fri, 2 Jan 2026 16:33:27 +0300 Subject: [PATCH 09/12] Fix order of attributes in color input tests --- tests/HtmlTest.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/HtmlTest.php b/tests/HtmlTest.php index 2d1b0337..1da7e8f8 100644 --- a/tests/HtmlTest.php +++ b/tests/HtmlTest.php @@ -386,14 +386,14 @@ public function testColorInput(): void { $this->assertSame('', Html::color()->render()); $this->assertSame('', Html::color('')->render()); - $this->assertSame('', Html::color(null, '')->render()); - $this->assertSame('', Html::color('test')->render()); + $this->assertSame('', Html::color(null, '')->render()); + $this->assertSame('', Html::color('test')->render()); $this->assertSame( - '', + '', Html::color('test', '#ff0000')->render(), ); $this->assertSame( - '', + '', Html::color('test', '#ff0000', ['required' => true])->render(), ); } From 7c949b09ba8a62bf89031ae963b504635ad92584 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Mon, 5 Jan 2026 11:56:57 +0300 Subject: [PATCH 10/12] Update InputTest.php --- tests/Tag/InputTest.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/Tag/InputTest.php b/tests/Tag/InputTest.php index a559617f..af283308 100644 --- a/tests/Tag/InputTest.php +++ b/tests/Tag/InputTest.php @@ -77,6 +77,14 @@ public function testRange(): void ); } + public function testColor(): void + { + $this->assertSame( + '', + (string) Input::color('color', '#ff0000'), + ); + } + public function testButton(): void { $this->assertSame( From b4018bab5d92671f51a250fc7ed198422473b86e Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Sat, 14 Mar 2026 08:37:09 +0300 Subject: [PATCH 11/12] fix --- CHANGELOG.md | 2 +- tests/Widget/CheckboxListTest.php | 2 +- tests/Widget/RadioListTest.php | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 720bb92d..c78ea560 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,11 +3,11 @@ ## 4.0.0 under development - Chg #221: Throw `LogicException` in `Tag::id()` when id is empty string (@razvbir) +- Chg #234: Remove tag attributes sorting (@FrankiFixx) ## 3.13.0 March 13, 2026 - New #260: Add `$attributes` parameter to `Html::li()` method (@gauravkumar2525) -- Chg #234: Remove tag attributes sorting (@FrankiFixx) - Chg #243: Deprecate static constructors such as `TagName::tag()` in favor of `new TagName()` (@razvbir) - Enh #261: Enhance `RadioList::addRadioWrapClass()` method for cleaner class addition (@vjik) - Enh #263: Explicitly import classes and constants in "use" section (@mspirkov) diff --git a/tests/Widget/CheckboxListTest.php b/tests/Widget/CheckboxListTest.php index a3277334..63130f47 100644 --- a/tests/Widget/CheckboxListTest.php +++ b/tests/Widget/CheckboxListTest.php @@ -55,7 +55,7 @@ public function testCreate(): void $this->assertSame( '
    ' . "\n" - . '' . "\n" + . '' . "\n" . '
    ', $widget->render(), ); diff --git a/tests/Widget/RadioListTest.php b/tests/Widget/RadioListTest.php index b73d8ffd..2ddfa938 100644 --- a/tests/Widget/RadioListTest.php +++ b/tests/Widget/RadioListTest.php @@ -19,9 +19,9 @@ public function testBase(): void $this->assertSame( '' . "\n" . '
    ' . "\n" - . '' . "\n" - . '' . "\n" - . '' . "\n" + . '' . "\n" + . '' . "\n" + . '' . "\n" . '
    ', (new RadioList('test')) ->items([1 => 'One', 2 => 'Two', 5 => 'Five']) From e569969fc97dd808cd4ede235fc21bdbc7d09eae Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Sat, 14 Mar 2026 08:40:04 +0300 Subject: [PATCH 12/12] upgrade --- UPGRADE.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/UPGRADE.md b/UPGRADE.md index 37b8a9f6..c9d749e0 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -9,5 +9,9 @@ application when you upgrade the package from one version to another. ## Upgrade from 3.x -- `Tag::id()` now throws `LogicException` when an empty string is passed. Check your code for places where you call +- `Tag::id()` now throws `LogicException` when an empty string is passed. Check your code for places where you call `Tag::id()` and make sure you are not passing an empty string. +- HTML tag attributes are no longer sorted by `Html::renderTagAttributes()`. Previously, attributes were reordered + according to a predefined priority list (`type`, `id`, `class`, `name`, `value`, etc.). Now attributes are rendered + in the order they are set. If your code or tests depend on a specific attribute order in the rendered HTML, you need + to update them.