Skip to content

Commit f3635b0

Browse files
authored
[TASK] Test LineName::getArrayRepresentation() (#1582)
The tests are similar to those for the parent class `ValueList`. The main differences are that the values are always strings and the separator is always a space, not a comma.
1 parent 608fab5 commit f3635b0

2 files changed

Lines changed: 44 additions & 13 deletions

File tree

src/Value/LineName.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,4 @@ public function render(OutputFormat $outputFormat): string
6262
{
6363
return '[' . parent::render(OutputFormat::createCompact()) . ']';
6464
}
65-
66-
/**
67-
* @return array<string, bool|int|float|string|array<mixed>|null>
68-
*
69-
* @internal
70-
*/
71-
public function getArrayRepresentation(): array
72-
{
73-
throw new \BadMethodCallException('`getArrayRepresentation` is not yet implemented for `' . self::class . '`');
74-
}
7565
}

tests/Unit/Value/LineNameTest.php

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,53 @@ final class LineNameTest extends TestCase
1717
/**
1818
* @test
1919
*/
20-
public function getArrayRepresentationThrowsException(): void
20+
public function getArrayRepresentationIncludesClassName(): void
2121
{
22-
$this->expectException(\BadMethodCallException::class);
22+
$subject = new LineName();
23+
24+
$result = $subject->getArrayRepresentation();
25+
26+
self::assertSame('LineName', $result['class']);
27+
}
28+
29+
/**
30+
* @test
31+
*/
32+
public function getArrayRepresentationCanIncludeOneStringComponent(): void
33+
{
34+
$name = 'main-start';
35+
$subject = new LineName([$name]);
36+
37+
$result = $subject->getArrayRepresentation();
38+
39+
self::assertSame($name, $result['components'][0]['value']);
40+
}
41+
42+
/**
43+
* @test
44+
*/
45+
public function getArrayRepresentationCanIncludeMultipleStringComponents(): void
46+
{
47+
$name1 = 'main-start';
48+
$name2 = 'main-end';
49+
$subject = new LineName([$name1, $name2]);
50+
51+
$result = $subject->getArrayRepresentation();
52+
53+
self::assertSame($name1, $result['components'][0]['value']);
54+
self::assertSame($name2, $result['components'][1]['value']);
55+
}
2356

57+
58+
/**
59+
* @test
60+
*/
61+
public function getArrayRepresentationIncludesSpaceSeparator(): void
62+
{
2463
$subject = new LineName();
2564

26-
$subject->getArrayRepresentation();
65+
$result = $subject->getArrayRepresentation();
66+
67+
self::assertSame(' ', $result['separator']);
2768
}
2869
}

0 commit comments

Comments
 (0)