Total Complexity | 5 |
Total Lines | 53 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
14 | final class MapTypeTest extends TypeTest |
||
15 | { |
||
16 | protected function createType() : Type |
||
17 | { |
||
18 | return new MapType($this->getKeyType(), $this->getValueType()); |
||
19 | } |
||
20 | |||
21 | public function testDescribe() : void |
||
22 | { |
||
23 | self::assertSame('array<string, mixed>', $this->getType()->describe()); |
||
24 | } |
||
25 | |||
26 | public function validValidateValuesProvider() : iterable |
||
27 | { |
||
28 | yield [ |
||
29 | ['foo' => 'bar'], |
||
30 | ['baz' => 42], |
||
31 | ['woof' => new stdClass()], |
||
32 | ['meow' => null], |
||
33 | [ |
||
34 | 'multiple' => 1, |
||
35 | 'items' => static function () : void { |
||
36 | }, |
||
37 | 'with' => new class () { |
||
38 | }, |
||
39 | 'different' => null, |
||
40 | 'types' => 'test', |
||
41 | ], |
||
42 | ]; |
||
43 | } |
||
44 | |||
45 | public function invalidValidateValuesProvider() : iterable |
||
46 | { |
||
47 | yield [ |
||
48 | ['foo', 1], |
||
49 | [1 => 'bar'], |
||
50 | ['baz' => new stdClass(), 1 => 'zaz'], |
||
51 | ]; |
||
52 | } |
||
53 | |||
54 | public function testAcceptsNull() : void |
||
55 | { |
||
56 | self::assertSame($this->getValueType()->acceptsNull(), $this->getType()->acceptsNull()); |
||
57 | } |
||
58 | |||
59 | private function getKeyType() : ScalarType |
||
60 | { |
||
61 | return new StringType(); |
||
62 | } |
||
63 | |||
64 | private function getValueType() : Type |
||
67 | } |
||
68 | } |
||
69 |