22
33namespace Sevavietl \Arrays \Tests \Unit ;
44
5+ use PHPUnit \Framework \TestCase ;
56use Sevavietl \Arrays \CompositeKeyArray ;
67use Sevavietl \Arrays \UndefinedOffsetException ;
78
8- class CompositeKeyArrayTest extends \ TestCase
9+ class CompositeKeyArrayTest extends TestCase
910{
1011 /**
1112 * @dataProvider arrayDataProviderForIssetTesting
1213 */
13- public function testOffsetExists ($ array , $ offset , $ exists )
14+ public function testOffsetExists ($ array , $ offset , bool $ exists ): void
1415 {
1516 $ array = new CompositeKeyArray ($ array );
1617
17- $ this ->assertEquals (
18- $ exists ,
19- isset ($ array [$ offset ])
20- );
18+ $ this ->assertEquals ($ exists , isset ($ array [$ offset ]));
2119 }
2220
23- public function arrayDataProviderForIssetTesting ()
21+ public function arrayDataProviderForIssetTesting (): array
2422 {
2523 return [
2624 [[1 ], 0 , true ],
@@ -41,17 +39,14 @@ public function arrayDataProviderForIssetTesting()
4139 /**
4240 * @dataProvider arrayDataProviderForGetTesting
4341 */
44- public function testOffsetGet ($ array , $ offset , $ value )
42+ public function testOffsetGet ($ array , $ offset , $ value ): void
4543 {
4644 $ array = new CompositeKeyArray ($ array );
4745
48- $ this ->assertEquals (
49- $ value ,
50- $ array [$ offset ]
51- );
46+ $ this ->assertEquals ($ value , $ array [$ offset ]);
5247 }
5348
54- public function arrayDataProviderForGetTesting ()
49+ public function arrayDataProviderForGetTesting (): array
5550 {
5651 return [
5752 [[1 ], 0 , 1 ],
@@ -63,11 +58,10 @@ public function arrayDataProviderForGetTesting()
6358 ];
6459 }
6560
66- /**
67- * @expectedException Sevavietl\Arrays\UndefinedOffsetException
68- */
69- public function testOffsetGetThrowsException ()
61+ public function testOffsetGetThrowsException (): void
7062 {
63+ $ this ->expectException (UndefinedOffsetException::class);
64+
7165 $ array = new CompositeKeyArray ();
7266
7367 $ value = $ array [['foo ' , 'bar ' ]];
@@ -76,72 +70,52 @@ public function testOffsetGetThrowsException()
7670 /**
7771 * @dataProvider arrayDataProviderForSetTesting
7872 */
79- public function testOffsetSet ($ array , $ offset , $ value )
73+ public function testOffsetSet ($ array , $ offset , $ value ): void
8074 {
8175 $ array = new CompositeKeyArray ($ array );
82-
8376 $ array [$ offset ] = $ value ;
8477
85- $ this ->assertEquals (
86- $ value ,
87- $ array [$ offset ]
88- );
78+ $ this ->assertEquals ($ value , $ array [$ offset ]);
8979 }
9080
91- public function arrayDataProviderForSetTesting ()
81+ public function arrayDataProviderForSetTesting (): array
9282 {
9383 return [
9484 [[], 0 , 1 ],
9585 [[], [0 , 1 ], 2 ],
9686 ];
9787 }
9888
99- public function testOffsetSetEdgeCases ()
89+ public function testOffsetSetEdgeCases (): void
10090 {
10191 $ array = new CompositeKeyArray ();
102-
10392 $ array [[[]]] = 'foo ' ;
10493
105- $ this ->assertEquals (
106- 'foo ' ,
107- $ array [0 ]
108- );
94+ $ this ->assertEquals ('foo ' , $ array [0 ]);
10995
11096 $ array = new CompositeKeyArray ();
111-
11297 $ array [[1 , [], 2 ]] = 3 ;
11398
114- $ this ->assertEquals (
115- 3 ,
116- $ array [[1 , 0 , 2 ]]
117- );
99+ $ this ->assertEquals (3 , $ array [[1 , 0 , 2 ]]);
118100
119101 $ array = new CompositeKeyArray ();
120-
121102 $ array [[1 , [], [], [], 2 ]] = 3 ;
122103
123- $ this ->assertEquals (
124- 3 ,
125- $ array [[1 , 0 , 0 , 0 , 2 ]]
126- );
104+ $ this ->assertEquals (3 , $ array [[1 , 0 , 0 , 0 , 2 ]]);
127105 }
128106
129107 /**
130108 * @dataProvider arrayDataProviderForUnsetTesting
131109 */
132- public function testOffsetUnset ($ array , $ offset , $ arrayAfterUnset )
110+ public function testOffsetUnset ($ array , $ offset , $ arrayAfterUnset ): void
133111 {
134112 $ array = new CompositeKeyArray ($ array );
135-
136113 unset($ array [$ offset ]);
137114
138- $ this ->assertEquals (
139- $ arrayAfterUnset ,
140- $ array ->toArray ()
141- );
115+ $ this ->assertEquals ($ arrayAfterUnset , $ array ->toArray ());
142116 }
143117
144- public function arrayDataProviderForUnsetTesting ()
118+ public function arrayDataProviderForUnsetTesting (): array
145119 {
146120 return [
147121 [[1 ], 0 , []],
@@ -157,7 +131,7 @@ public function arrayDataProviderForUnsetTesting()
157131 ];
158132 }
159133
160- public function testItIsIterable ()
134+ public function testItIsIterable (): void
161135 {
162136 $ arr = new CompositeKeyArray ($ initial = [
163137 'foo ' => ['bar ' => ['baz ' ]],
0 commit comments