File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -943,4 +943,26 @@ public function testReindex(): void
943
943
$ doubled = static fn ($ item ) => $ item * 2 ;
944
944
self ::assertEquals ($ expectedOutput , Utils::reindex ($ input , $ doubled ));
945
945
}
946
+
947
+ /**
948
+ * Test that reindexing an array works on arrays with key=>value
949
+ */
950
+ public function testReindexKeyValue (): void
951
+ {
952
+ $ input = ['a ' => 10 , 'b ' => 5 ];
953
+ $ expectedOutput = [101030 => 10 , 5515 => 5 ];
954
+ $ tripled = static fn ($ item ) => strval ($ item ) . strval ($ item ) . strval ($ item * 3 );
955
+ self ::assertEquals ($ expectedOutput , Utils::reindex ($ input , $ tripled ));
956
+ }
957
+
958
+ /**
959
+ * Test that reindexing an array works on arrays with key=>value and string values
960
+ */
961
+ public function testReindexKeyValueString (): void
962
+ {
963
+ $ input = ['a ' => 'A ' , 'b ' => 'B ' ];
964
+ $ expectedOutput = ['AA ' => 'A ' , 'BB ' => 'B ' ];
965
+ $ stringDouble = static fn ($ item ) => strval ($ item ) . strval ($ item );
966
+ self ::assertEquals ($ expectedOutput , Utils::reindex ($ input , $ stringDouble ));
967
+ }
946
968
}
You can’t perform that action at this time.
0 commit comments