Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions src/Value/LineName.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,4 @@ public function render(OutputFormat $outputFormat): string
{
return '[' . parent::render(OutputFormat::createCompact()) . ']';
}

/**
* @return array<string, bool|int|float|string|array<mixed>|null>
*
* @internal
*/
public function getArrayRepresentation(): array
{
throw new \BadMethodCallException('`getArrayRepresentation` is not yet implemented for `' . self::class . '`');
}
}
57 changes: 54 additions & 3 deletions tests/Unit/Value/LineNameTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use PHPUnit\Framework\TestCase;
use Sabberworm\CSS\Value\LineName;
use Sabberworm\CSS\Value\Size;

/**
* @covers \Sabberworm\CSS\Value\LineName
Expand All @@ -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']);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would prefer not to have a font name, which is confusing. It should be some made-up idendifier like main-start.


$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']);
}
Comment on lines +42 to +66
Copy link
Copy Markdown
Collaborator

@JakeQZ JakeQZ May 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These tests are invalid, because LineName should not accept Size in the argument list. Instead we should have a test that two string identifiers are represented (as well as that for a single string identifier which isn't a font name).


/**
* @test
*/
public function getArrayRepresentationIncludesSpaceSeparator(): void
{
$subject = new LineName();

$subject->getArrayRepresentation();
$result = $subject->getArrayRepresentation();

self::assertSame(' ', $result['separator']);
}
}