|
6 | 6 |
|
7 | 7 | use PHPUnit\Framework\TestCase; |
8 | 8 | use Sabberworm\CSS\CSSList\CSSListItem; |
| 9 | +use Sabberworm\CSS\Property\Declaration; |
9 | 10 | use Sabberworm\CSS\RuleSet\AtRuleSet; |
10 | 11 |
|
11 | 12 | /** |
@@ -34,10 +35,72 @@ public function implementsCSSListItem(): void |
34 | 35 | /** |
35 | 36 | * @test |
36 | 37 | */ |
37 | | - public function getArrayRepresentationThrowsException(): void |
| 38 | + public function getArrayRepresentationIncludesClassName(): void |
38 | 39 | { |
39 | | - $this->expectException(\BadMethodCallException::class); |
| 40 | + $subject = new AtRuleSet('supports'); |
40 | 41 |
|
41 | | - $this->subject->getArrayRepresentation(); |
| 42 | + $result = $subject->getArrayRepresentation(); |
| 43 | + |
| 44 | + self::assertSame('AtRuleSet', $result['class']); |
| 45 | + } |
| 46 | + |
| 47 | + /** |
| 48 | + * @test |
| 49 | + */ |
| 50 | + public function getArrayRepresentationIncludesDeclarations(): void |
| 51 | + { |
| 52 | + $subject = new AtRuleSet('supports'); |
| 53 | + $subject->addDeclaration(new Declaration('display')); |
| 54 | + $subject->addDeclaration(new Declaration('transform-origin')); |
| 55 | + |
| 56 | + $result = $subject->getArrayRepresentation(); |
| 57 | + |
| 58 | + self::assertSame( |
| 59 | + [ |
| 60 | + 'display' => [ |
| 61 | + [ |
| 62 | + 'class' => 'Declaration', |
| 63 | + 'propertyName' => 'display', |
| 64 | + 'propertyValue' => null, |
| 65 | + 'important' => false, |
| 66 | + ], |
| 67 | + ], |
| 68 | + 'transform-origin' => [ |
| 69 | + [ |
| 70 | + 'class' => 'Declaration', |
| 71 | + 'propertyName' => 'transform-origin', |
| 72 | + 'propertyValue' => null, |
| 73 | + 'important' => false, |
| 74 | + ], |
| 75 | + ], |
| 76 | + ], |
| 77 | + $result['declarations'] |
| 78 | + ); |
| 79 | + } |
| 80 | + |
| 81 | + /** |
| 82 | + * @test |
| 83 | + */ |
| 84 | + public function getArrayRepresentationIncludesAtRuleName(): void |
| 85 | + { |
| 86 | + $atRuleName = 'supports'; |
| 87 | + $subject = new AtRuleSet($atRuleName); |
| 88 | + |
| 89 | + $result = $subject->getArrayRepresentation(); |
| 90 | + |
| 91 | + self::assertSame($atRuleName, $result['atRuleName']); |
| 92 | + } |
| 93 | + |
| 94 | + /** |
| 95 | + * @test |
| 96 | + */ |
| 97 | + public function getArrayRepresentationIncludesArguments(): void |
| 98 | + { |
| 99 | + $arguments = 'foo'; |
| 100 | + $subject = new AtRuleSet('supports', $arguments); |
| 101 | + |
| 102 | + $result = $subject->getArrayRepresentation(); |
| 103 | + |
| 104 | + self::assertSame($arguments, $result['arguments']); |
42 | 105 | } |
43 | 106 | } |
0 commit comments