@@ -212,6 +212,56 @@ public function test_indirect_array_modification()
212212 $ this ->assertSame (['indirect ' => ['modification ' => ['BC ' => 'break ' ]]], $ args ->toArray ());
213213 }
214214
215+ /**
216+ * @dataProvider pain
217+ */
218+ public function test_some_implicit_conversion_pain ($ store )
219+ {
220+ // Here comes the fun...
221+ $ this ->assertTrue ($ store ->has (3.14 ), 'Key exists? Lets see... ' );
222+ $ this ->assertNotSame ('oh no ' , $ store ->get (3.14 ), 'Wait what? (test is false positive btw) ' );
223+ $ this ->assertSame (null , $ store ->get (3.14 ), 'I expected something else ' );
224+ $ this ->assertSame ('oh no ' , $ store ->get (3 ), 'The amazing implicit conversion of 3.14 and the override of the existing key 3 ' );
225+ $ this ->assertSame ('yes ' , $ store ->get ('3.140 ' ), 'Run PHP, run! ' );
226+
227+ // Here comes more amazingness with PHPUnit...
228+ $ store = $ store ->toArray ();
229+
230+ $ this ->assertArrayHasKey ('1 ' , $ store );
231+ $ this ->assertArrayHasKey (1 , $ store , 'Because of course ' );
232+
233+ $ this ->assertArrayHasKey (2 , $ store );
234+ $ this ->assertArrayHasKey ('2 ' , $ store , 'Why not? ' );
235+
236+ $ this ->assertArrayHasKey ('3 ' , $ store );
237+ $ this ->assertArrayHasKey (3 , $ store , 'We already tested this, just to confirm the sanity ' );
238+ }
239+
240+ public function pain ()
241+ {
242+ $ data = [
243+ 0 => 0 ,
244+ '1 ' => 1 ,
245+ 2 => 2 ,
246+ '3 ' => 3 ,
247+
248+ 3.14 => 'oh no ' ,
249+ '3.140 ' => 'yes ' ,
250+ ];
251+
252+ // using set()
253+ $ store = new Arguments ;
254+ foreach ($ data as $ index => $ value ) {
255+ $ store ->set ($ index , $ value );
256+ }
257+
258+ return [
259+ [new Arguments ($ data )],
260+ [(new Arguments )->import ($ data )],
261+ [$ store ],
262+ ];
263+ }
264+
215265 protected function setUp (): void
216266 {
217267 $ this ->SUT = new Arguments ([
0 commit comments