[TASK] Test LineName::getArrayRepresentation()#1582
Conversation
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.
JakeQZ
left a comment
There was a problem hiding this comment.
I've never used line names (aka named grid lines).
It seems that they are user-defined identifiers (i.e. strings), and that the LineName constructor should actually only allow strings in the $components parameter, not Values (for another PR).
In the meantime, we should be consistent with what the class is representing: a non-empty list of user-defined string identifiers, which are whitespace-separated in the rendered CSS.
| */ | ||
| public function getArrayRepresentationIncludesStringComponent(): void | ||
| { | ||
| $subject = new LineName(['Helvetica']); |
There was a problem hiding this comment.
Would prefer not to have a font name, which is confusing. It should be some made-up idendifier like main-start.
| /** | ||
| * @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']); | ||
| } |
There was a problem hiding this comment.
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).
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.