88
99
1010use Ingenerator \PHPUtils \ArrayHelpers \AssociativeArrayUtils ;
11+ use PHPUnit \Framework \Attributes \DataProvider ;
12+ use PHPUnit \Framework \Attributes \TestWith ;
13+ use PHPUnit \Framework \TestCase ;
1114
12- class AssociativeArrayUtilsTest extends \ PHPUnit \ Framework \ TestCase
15+ class AssociativeArrayUtilsTest extends TestCase
1316{
1417
15- /**
16- * @testWith [["one", "two", "three"], false]
17- * [{"1": "mixed indices", "5": "also mixed"}, true]
18- * [{"one": "o clock", "two": "o clock", "three": "o clock"}, true]
19- */
18+ #[TestWith([['one ' , 'two ' , 'three ' ], false ])]
19+ #[TestWith([[1 => 'mixed indices ' , 5 => 'also mixed ' ], true ])]
20+ #[TestWith([['one ' => 'o clock ' , 'two ' => 'o clock ' , 'three ' => 'o clock ' ], true ])]
2021 public function test_is_associative (array $ array , $ expected )
2122 {
2223 $ this ->assertSame (
@@ -25,7 +26,7 @@ public function test_is_associative(array $array, $expected)
2526 );
2627 }
2728
28- public function provider_paths_to_nested ()
29+ public static function provider_paths_to_nested (): array
2930 {
3031 return [
3132 [
@@ -51,15 +52,13 @@ public function provider_paths_to_nested()
5152 ];
5253 }
5354
54- /**
55- * @dataProvider provider_paths_to_nested
56- */
55+ #[DataProvider('provider_paths_to_nested ' )]
5756 public function test_it_converts_pathed_hash_to_nested_arrays ($ input , $ expect )
5857 {
5958 $ this ->assertSame ($ expect , AssociativeArrayUtils::pathsToNested ($ input ));
6059 }
6160
62- public function provider_pop_keys ()
61+ public static function provider_pop_keys (): array
6362 {
6463 return [
6564 [
@@ -90,9 +89,7 @@ public function provider_pop_keys()
9089 ];
9190 }
9291
93- /**
94- * @dataProvider provider_pop_keys
95- */
92+ #[DataProvider('provider_pop_keys ' )]
9693 public function test_it_can_pop_keys_from_a_source_array ($ source , $ pop_keys , $ expect )
9794 {
9895 $ result = AssociativeArrayUtils::popKeys ($ source , $ pop_keys );
@@ -104,7 +101,7 @@ public function test_it_can_pop_keys_from_a_source_array($source, $pop_keys, $ex
104101 *
105102 * @return array
106103 */
107- public function provider_set_path ()
104+ public static function provider_set_path (): array
108105 {
109106 return [
110107 // Tests returns normal values
@@ -125,9 +122,7 @@ public function provider_set_path()
125122 ];
126123 }
127124
128- /**
129- * @dataProvider provider_set_path
130- */
125+ #[DataProvider('provider_set_path ' )]
131126 public function test_set_path ($ expected , $ array , ...$ args )
132127 {
133128 AssociativeArrayUtils::setPath ($ array , ...$ args );
@@ -136,7 +131,7 @@ public function test_set_path($expected, $array, ...$args)
136131 }
137132
138133
139- public function provider_merge ()
134+ public static function provider_merge (): array
140135 {
141136 return [
142137 // Test how it merges arrays and sub arrays with assoc keys
@@ -266,9 +261,7 @@ public function provider_merge()
266261 ];
267262 }
268263
269- /**
270- * @dataProvider provider_merge
271- */
264+ #[DataProvider('provider_merge ' )]
272265 public function test_deep_merge ($ expected , ...$ args )
273266 {
274267 $ this ->assertSame (
0 commit comments