From 560fb8c22e77274b6dde2dc63b7ef9baecd2012d Mon Sep 17 00:00:00 2001 From: Oliver Klee Date: Sun, 3 May 2026 11:39:35 +0200 Subject: [PATCH] [TASK] Test `LineName::getArrayRepresentation()` The tests are basically the same as those for the parent class `ValueList`. The main difference is that the default separator now is a space, not a comma. Part of #1440. --- src/Value/LineName.php | 10 ------ tests/Unit/Value/LineNameTest.php | 57 +++++++++++++++++++++++++++++-- 2 files changed, 54 insertions(+), 13 deletions(-) diff --git a/src/Value/LineName.php b/src/Value/LineName.php index 7b7690f88..763cc48ea 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 e48670f8a..3167b5ca2 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']); } }