|
7 | 7 | use PHPUnit\Framework\TestCase; |
8 | 8 | use Sabberworm\CSS\CSSElement; |
9 | 9 | use Sabberworm\CSS\CSSList\CSSListItem; |
| 10 | +use Sabberworm\CSS\Property\Declaration; |
10 | 11 | use Sabberworm\CSS\RuleSet\RuleSet; |
11 | 12 |
|
12 | 13 | /** |
@@ -83,10 +84,53 @@ public function getLineNumberReturnsLineNumberPassedToConstructor(?int $lineNumb |
83 | 84 | /** |
84 | 85 | * @test |
85 | 86 | */ |
86 | | - public function getArrayRepresentationThrowsException(): void |
| 87 | + public function getArrayRepresentationIncludesClassName(): void |
87 | 88 | { |
88 | | - $this->expectException(\BadMethodCallException::class); |
| 89 | + $subject = new RuleSet(); |
89 | 90 |
|
90 | | - $this->subject->getArrayRepresentation(); |
| 91 | + $result = $subject->getArrayRepresentation(); |
| 92 | + |
| 93 | + self::assertSame('RuleSet', $result['class']); |
| 94 | + } |
| 95 | + |
| 96 | + /** |
| 97 | + * @test |
| 98 | + */ |
| 99 | + public function getArrayRepresentationIncludesDeclarations(): void |
| 100 | + { |
| 101 | + $subject = new RuleSet(); |
| 102 | + $subject->addDeclaration(new Declaration('line-height')); |
| 103 | + $subject->addDeclaration(new Declaration('line-height')); |
| 104 | + $subject->addDeclaration(new Declaration('color')); |
| 105 | + |
| 106 | + $result = $subject->getArrayRepresentation(); |
| 107 | + |
| 108 | + self::assertSame( |
| 109 | + [ |
| 110 | + 'line-height' => [ |
| 111 | + [ |
| 112 | + 'class' => 'Declaration', |
| 113 | + 'propertyName' => 'line-height', |
| 114 | + 'propertyValue' => null, |
| 115 | + 'important' => false, |
| 116 | + ], |
| 117 | + [ |
| 118 | + 'class' => 'Declaration', |
| 119 | + 'propertyName' => 'line-height', |
| 120 | + 'propertyValue' => null, |
| 121 | + 'important' => false, |
| 122 | + ], |
| 123 | + ], |
| 124 | + 'color' => [ |
| 125 | + [ |
| 126 | + 'class' => 'Declaration', |
| 127 | + 'propertyName' => 'color', |
| 128 | + 'propertyValue' => null, |
| 129 | + 'important' => false, |
| 130 | + ], |
| 131 | + ], |
| 132 | + ], |
| 133 | + $result['declarations'] |
| 134 | + ); |
91 | 135 | } |
92 | 136 | } |
0 commit comments