Skip to content

Commit d6bf39b

Browse files
authored
[TASK] Add tests for RuleValueList::getArrayRepresentation() (#1577)
Part of #1440.
1 parent 797090e commit d6bf39b

1 file changed

Lines changed: 57 additions & 0 deletions

File tree

tests/Unit/Value/RuleValueListTest.php

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use PHPUnit\Framework\TestCase;
88
use Sabberworm\CSS\Value\RuleValueList;
9+
use Sabberworm\CSS\Value\Size;
910

1011
/**
1112
* @covers \Sabberworm\CSS\Value\RuleValueList
@@ -25,4 +26,60 @@ public function getArrayRepresentationIncludesClassName(): void
2526

2627
self::assertSame('RuleValueList', $result['class']);
2728
}
29+
30+
/**
31+
* @test
32+
*/
33+
public function getArrayRepresentationIncludesStringComponent(): void
34+
{
35+
$subject = new RuleValueList();
36+
$subject->addListComponent('Helvetica');
37+
38+
$result = $subject->getArrayRepresentation();
39+
40+
self::assertSame('Helvetica', $result['components'][0]['value']);
41+
}
42+
43+
/**
44+
* @test
45+
*/
46+
public function getArrayRepresentationIncludesValueComponent(): void
47+
{
48+
$subject = new RuleValueList();
49+
$subject->addListComponent(new Size(1));
50+
51+
$result = $subject->getArrayRepresentation();
52+
53+
self::assertSame('Size', $result['components'][0]['class']);
54+
}
55+
56+
/**
57+
* @test
58+
*/
59+
public function getArrayRepresentationIncludesMultipleMixedComponents(): void
60+
{
61+
$subject = new RuleValueList();
62+
$subject->addListComponent(new Size(1));
63+
$subject->addListComponent('+');
64+
$subject->addListComponent(new Size(2));
65+
66+
$result = $subject->getArrayRepresentation();
67+
68+
self::assertSame('Size', $result['components'][0]['class']);
69+
self::assertSame('+', $result['components'][1]['value']);
70+
self::assertSame('Size', $result['components'][2]['class']);
71+
}
72+
73+
/**
74+
* @test
75+
*/
76+
public function getArrayRepresentationIncludesSeparator(): void
77+
{
78+
$separator = ', ';
79+
$subject = new RuleValueList($separator);
80+
81+
$result = $subject->getArrayRepresentation();
82+
83+
self::assertSame($separator, $result['separator']);
84+
}
2885
}

0 commit comments

Comments
 (0)