FormatterTest.php
30 lines
| 1 | <?php declare(strict_types=1); |
| 2 | use PHPUnit\Framework\TestCase; |
| 3 | |
| 4 | final class FormatterTest extends TestCase |
| 5 | { |
| 6 | public function testFromKeyValue(): void { |
| 7 | $data = [ 'foo' => 'bar' ]; |
| 8 | $formatter = FormatObjectList\Factory::fromKeyValue( $data ); |
| 9 | $expected = [ |
| 10 | [ |
| 11 | 'value' => 'foo', |
| 12 | 'label' => 'bar', |
| 13 | ] |
| 14 | ]; |
| 15 | $this->assertEqualsCanonicalizing($formatter->format(), $expected); |
| 16 | } |
| 17 | |
| 18 | public function testFromValueKey(): void { |
| 19 | $data = [ 'foo' => 'bar' ]; |
| 20 | $formatter = FormatObjectList\Factory::fromValueKey( $data ); |
| 21 | $expected = [ |
| 22 | [ |
| 23 | 'value' => 'bar', |
| 24 | 'label' => 'foo', |
| 25 | ] |
| 26 | ]; |
| 27 | $this->assertEqualsCanonicalizing($formatter->format(), $expected); |
| 28 | } |
| 29 | } |
| 30 |