|
8 | 8 | use Sabberworm\CSS\CSSList\CSSListItem; |
9 | 9 | use Sabberworm\CSS\Property\CSSNamespace; |
10 | 10 | use Sabberworm\CSS\Value\CSSString; |
| 11 | +use Sabberworm\CSS\Value\URL; |
11 | 12 |
|
12 | 13 | /** |
13 | 14 | * @covers \Sabberworm\CSS\Property\CSSNamespace |
@@ -35,10 +36,82 @@ public function implementsCSSListItem(): void |
35 | 36 | /** |
36 | 37 | * @test |
37 | 38 | */ |
38 | | - public function getArrayRepresentationThrowsException(): void |
| 39 | + public function getArrayRepresentationIncludesClassName(): void |
39 | 40 | { |
40 | | - $this->expectException(\BadMethodCallException::class); |
| 41 | + $subject = new CSSNamespace(new CSSString('http://www.w3.org/2000/svg')); |
41 | 42 |
|
42 | | - $this->subject->getArrayRepresentation(); |
| 43 | + $result = $subject->getArrayRepresentation(); |
| 44 | + |
| 45 | + self::assertSame('CSSNamespace', $result['class']); |
| 46 | + } |
| 47 | + |
| 48 | + /** |
| 49 | + * @test |
| 50 | + */ |
| 51 | + public function getArrayRepresentationIncludesUrlProvidedAsCssString(): void |
| 52 | + { |
| 53 | + $uri = 'http://www.w3.org/2000/svg'; |
| 54 | + $uriAsCssString = new CSSString($uri); |
| 55 | + $subject = new CSSNamespace($uriAsCssString); |
| 56 | + |
| 57 | + $result = $subject->getArrayRepresentation(); |
| 58 | + |
| 59 | + self::assertSame( |
| 60 | + [ |
| 61 | + 'class' => 'CSSString', |
| 62 | + 'contents' => $uri, |
| 63 | + ], |
| 64 | + $result['url'] |
| 65 | + ); |
| 66 | + } |
| 67 | + |
| 68 | + /** |
| 69 | + * @test |
| 70 | + */ |
| 71 | + public function getArrayRepresentationIncludesUrlProvidedAsUrl(): void |
| 72 | + { |
| 73 | + $uri = 'http://www.w3.org/2000/svg'; |
| 74 | + $uriAsCssString = new CSSString($uri); |
| 75 | + $url = new URL($uriAsCssString); |
| 76 | + $subject = new CSSNamespace($url); |
| 77 | + |
| 78 | + $result = $subject->getArrayRepresentation(); |
| 79 | + |
| 80 | + self::assertSame( |
| 81 | + [ |
| 82 | + 'class' => 'URL', |
| 83 | + 'uri' => [ |
| 84 | + 'class' => 'CSSString', |
| 85 | + 'contents' => $uri, |
| 86 | + ], |
| 87 | + ], |
| 88 | + $result['url'] |
| 89 | + ); |
| 90 | + } |
| 91 | + |
| 92 | + /** |
| 93 | + * @test |
| 94 | + */ |
| 95 | + public function getArrayRepresentationIncludesPrefixForNullPrefix(): void |
| 96 | + { |
| 97 | + $subject = new CSSNamespace(new CSSString('http://www.w3.org/2000/svg'), null); |
| 98 | + |
| 99 | + $result = $subject->getArrayRepresentation(); |
| 100 | + |
| 101 | + self::assertNull($result['prefix']); |
| 102 | + } |
| 103 | + |
| 104 | + /** |
| 105 | + * @test |
| 106 | + */ |
| 107 | + public function getArrayRepresentationIncludesPrefixForStringPrefix(): void |
| 108 | + { |
| 109 | + $prefix = 'hello'; |
| 110 | + |
| 111 | + $subject = new CSSNamespace(new CSSString('http://www.w3.org/2000/svg'), $prefix); |
| 112 | + |
| 113 | + $result = $subject->getArrayRepresentation(); |
| 114 | + |
| 115 | + self::assertSame($prefix, $result['prefix']); |
43 | 116 | } |
44 | 117 | } |
0 commit comments