diff --git a/src/Value/LineName.php b/src/Value/LineName.php index 7b7690f8..763cc48e 100644 --- a/src/Value/LineName.php +++ b/src/Value/LineName.php @@ -56,14 +56,4 @@ public function render(OutputFormat $outputFormat): string { return '[' . parent::render(OutputFormat::createCompact()) . ']'; } - - /** - * @return array|null> - * - * @internal - */ - public function getArrayRepresentation(): array - { - throw new \BadMethodCallException('`getArrayRepresentation` is not yet implemented for `' . self::class . '`'); - } } diff --git a/tests/Unit/Value/LineNameTest.php b/tests/Unit/Value/LineNameTest.php index e48670f8..3167b5ca 100644 --- a/tests/Unit/Value/LineNameTest.php +++ b/tests/Unit/Value/LineNameTest.php @@ -6,6 +6,7 @@ use PHPUnit\Framework\TestCase; use Sabberworm\CSS\Value\LineName; +use Sabberworm\CSS\Value\Size; /** * @covers \Sabberworm\CSS\Value\LineName @@ -17,12 +18,62 @@ final class LineNameTest extends TestCase /** * @test */ - public function getArrayRepresentationThrowsException(): void + public function getArrayRepresentationIncludesClassName(): void { - $this->expectException(\BadMethodCallException::class); + $subject = new LineName(); + + $result = $subject->getArrayRepresentation(); + + self::assertSame('LineName', $result['class']); + } + + /** + * @test + */ + public function getArrayRepresentationIncludesStringComponent(): void + { + $subject = new LineName(['Helvetica']); + + $result = $subject->getArrayRepresentation(); + + self::assertSame('Helvetica', $result['components'][0]['value']); + } + + /** + * @test + */ + public function getArrayRepresentationIncludesValueComponent(): void + { + $subject = new LineName([new Size(1)]); + $result = $subject->getArrayRepresentation(); + + self::assertSame('Size', $result['components'][0]['class']); + } + + /** + * @test + */ + public function getArrayRepresentationIncludesMultipleMixedComponents(): void + { + $subject = new LineName([new Size(1), '+', new Size(2)]); + + $result = $subject->getArrayRepresentation(); + + self::assertSame('Size', $result['components'][0]['class']); + self::assertSame('+', $result['components'][1]['value']); + self::assertSame('Size', $result['components'][2]['class']); + } + + /** + * @test + */ + public function getArrayRepresentationIncludesSpaceSeparator(): void + { $subject = new LineName(); - $subject->getArrayRepresentation(); + $result = $subject->getArrayRepresentation(); + + self::assertSame(' ', $result['separator']); } }