1313
1414namespace phpDocumentor \Reflection \Types ;
1515
16+ use phpDocumentor \Reflection \Fqsen ;
1617use PHPUnit \Framework \TestCase ;
1718
1819/**
1920 * @coversDefaultClass \phpDocumentor\Reflection\Types\Array_
2021 */
2122class ArrayTest extends TestCase
2223{
24+ /**
25+ * @covers ::getOriginalKeyType
26+ * @covers ::getOriginalValueType
27+ * @covers ::getKeyType
28+ * @covers ::getValueType
29+ */
30+ public function testCreateWithoutParams (): void
31+ {
32+ $ type = new Array_ ();
33+
34+ $ this ->assertNull ($ type ->getOriginalKeyType ());
35+ $ this ->assertNull ($ type ->getOriginalValueType ());
36+ $ this ->assertEquals (new Compound ([new String_ (), new Integer ()]), $ type ->getKeyType ());
37+ $ this ->assertEquals (new Mixed_ (), $ type ->getValueType ());
38+ }
39+
40+ /**
41+ * @covers ::getOriginalKeyType
42+ * @covers ::getOriginalValueType
43+ * @covers ::getKeyType
44+ * @covers ::getValueType
45+ */
46+ public function testCreateWithParams (): void
47+ {
48+ $ valueType = new Object_ (new Fqsen ('\\phpDocumentor \\Foo \\Bar ' ));
49+ $ keyType = new Compound (
50+ [
51+ new String_ (),
52+ new Integer (),
53+ ]
54+ );
55+
56+ $ type = new Array_ ($ valueType , $ keyType );
57+
58+ $ this ->assertSame ($ keyType , $ type ->getOriginalKeyType ());
59+ $ this ->assertSame ($ valueType , $ type ->getOriginalValueType ());
60+ $ this ->assertSame ($ keyType , $ type ->getKeyType ());
61+ $ this ->assertSame ($ valueType , $ type ->getValueType ());
62+ }
63+
2364 /**
2465 * @dataProvider provideArrays
2566 * @covers ::__toString
@@ -36,7 +77,7 @@ public function provideArrays(): array
3677 {
3778 return [
3879 'simple array ' => [new Array_ (), 'array ' ],
39- 'array of mixed ' => [new Array_ (new Mixed_ ()), 'array ' ],
80+ 'array of mixed ' => [new Array_ (new Mixed_ ()), 'mixed[] ' ],
4081 'array of single type ' => [new Array_ (new String_ ()), 'string[] ' ],
4182 'array of compound type ' => [new Array_ (new Compound ([new Integer (), new String_ ()])), '(int|string)[] ' ],
4283 'array with key type ' => [new Array_ (new String_ (), new Integer ()), 'array<int,string> ' ],
0 commit comments