File tree Expand file tree Collapse file tree 2 files changed +24
-4
lines changed
Expand file tree Collapse file tree 2 files changed +24
-4
lines changed Original file line number Diff line number Diff line change 88use Sabberworm \CSS \OutputFormat ;
99use Sabberworm \CSS \Position \Position ;
1010use Sabberworm \CSS \Position \Positionable ;
11+ use Sabberworm \CSS \ShortClassNameProvider ;
1112use Sabberworm \CSS \Value \CSSString ;
1213
1314/**
@@ -22,6 +23,7 @@ class Charset implements AtRule, Positionable
2223{
2324 use CommentContainer;
2425 use Position;
26+ use ShortClassNameProvider;
2527
2628 /**
2729 * @var CSSString
@@ -79,6 +81,9 @@ public function atRuleArgs(): CSSString
7981 */
8082 public function getArrayRepresentation (): array
8183 {
82- throw new \BadMethodCallException ('`getArrayRepresentation` is not yet implemented for ` ' . self ::class . '` ' );
84+ return [
85+ 'class ' => $ this ->getShortClassName (),
86+ 'charset ' => $ this ->charset ->getArrayRepresentation (),
87+ ];
8388 }
8489}
Original file line number Diff line number Diff line change @@ -35,10 +35,25 @@ public function implementsCSSListItem(): void
3535 /**
3636 * @test
3737 */
38- public function getArrayRepresentationThrowsException (): void
38+ public function getArrayRepresentationIncludesClassName (): void
3939 {
40- $ this ->expectException (\BadMethodCallException::class );
40+ $ result = $ this ->subject -> getArrayRepresentation ( );
4141
42- $ this ->subject ->getArrayRepresentation ();
42+ self ::assertArrayHasKey ('class ' , $ result );
43+ self ::assertSame ('Charset ' , $ result ['class ' ]);
44+ }
45+
46+ /**
47+ * @test
48+ */
49+ public function getArrayRepresentationIncludesCharset (): void
50+ {
51+ $ charset = 'iso-8859-15 ' ;
52+ $ subject = new Charset (new CSSString ($ charset ));
53+
54+ $ result = $ subject ->getArrayRepresentation ();
55+
56+ self ::assertArrayHasKey ('charset ' , $ result );
57+ self ::assertSame (['class ' => 'CSSString ' , 'contents ' => $ charset ], $ result ['charset ' ]);
4358 }
4459}
You can’t perform that action at this time.
0 commit comments