@@ -272,19 +272,27 @@ public function testGetMultiple()
272
272
}
273
273
274
274
$ result = $ this ->cache ->getMultiple (['key0 ' , 'key1 ' ]);
275
- foreach ($ result as $ r ) {
275
+ $ keys = [];
276
+ foreach ($ result as $ i => $ r ) {
277
+ $ keys [] = $ i ;
276
278
$ this ->assertNull ($ r );
277
279
}
280
+ sort ($ keys );
281
+ $ this ->assertSame (['key0 ' , 'key1 ' ], $ keys );
278
282
279
283
$ this ->cache ->set ('key3 ' , 'value ' );
280
284
$ result = $ this ->cache ->getMultiple (['key2 ' , 'key3 ' , 'key4 ' ], 'foo ' );
285
+ $ keys = [];
281
286
foreach ($ result as $ key => $ r ) {
287
+ $ keys [] = $ key ;
282
288
if ($ key === 'key3 ' ) {
283
289
$ this ->assertEquals ('value ' , $ r );
284
290
} else {
285
291
$ this ->assertEquals ('foo ' , $ r );
286
292
}
287
293
}
294
+ sort ($ keys );
295
+ $ this ->assertSame (['key2 ' , 'key3 ' , 'key4 ' ], $ keys );
288
296
}
289
297
290
298
public function testGetMultipleWithGenerator ()
@@ -294,13 +302,15 @@ public function testGetMultipleWithGenerator()
294
302
}
295
303
296
304
$ gen = function () {
297
- yield 'key0 ' ;
298
- yield 'key1 ' ;
305
+ yield 1 => 'key0 ' ;
306
+ yield 1 => 'key1 ' ;
299
307
};
300
308
301
309
$ this ->cache ->set ('key0 ' , 'value0 ' );
302
310
$ result = $ this ->cache ->getMultiple ($ gen ());
311
+ $ keys = [];
303
312
foreach ($ result as $ key => $ r ) {
313
+ $ keys [] = $ key ;
304
314
if ($ key === 'key0 ' ) {
305
315
$ this ->assertEquals ('value0 ' , $ r );
306
316
} elseif ($ key === 'key1 ' ) {
@@ -309,6 +319,8 @@ public function testGetMultipleWithGenerator()
309
319
$ this ->assertFalse (true , 'This should not happend ' );
310
320
}
311
321
}
322
+ sort ($ keys );
323
+ $ this ->assertSame (['key0 ' , 'key1 ' ], $ keys );
312
324
$ this ->assertEquals ('value0 ' , $ this ->cache ->get ('key0 ' ));
313
325
$ this ->assertNull ($ this ->cache ->get ('key1 ' ));
314
326
}
@@ -336,8 +348,8 @@ public function testDeleteMultipleGenerator()
336
348
}
337
349
338
350
$ gen = function () {
339
- yield 'key0 ' ;
340
- yield 'key1 ' ;
351
+ yield 1 => 'key0 ' ;
352
+ yield 1 => 'key1 ' ;
341
353
};
342
354
$ this ->cache ->set ('key0 ' , 'value0 ' );
343
355
$ this ->assertTrue ($ this ->cache ->deleteMultiple ($ gen ()), 'Deleting a generator should return true ' );
@@ -632,10 +644,13 @@ public function testSetMultipleValidKeys($key)
632
644
633
645
$ this ->cache ->setMultiple ([$ key => 'foobar ' ]);
634
646
$ result = $ this ->cache ->getMultiple ([$ key ]);
647
+ $ keys = [];
635
648
foreach ($ result as $ i => $ r ) {
649
+ $ keys [] = $ i ;
636
650
$ this ->assertEquals ($ key , $ i );
637
651
$ this ->assertEquals ('foobar ' , $ r );
638
652
}
653
+ $ this ->assertSame ([$ key ], $ keys );
639
654
}
640
655
641
656
/**
@@ -662,9 +677,12 @@ public function testSetMultipleValidData($data)
662
677
663
678
$ this ->cache ->setMultiple (['key ' => $ data ]);
664
679
$ result = $ this ->cache ->getMultiple (['key ' ]);
665
- foreach ($ result as $ r ) {
680
+ $ keys = [];
681
+ foreach ($ result as $ i => $ r ) {
682
+ $ keys [] = $ i ;
666
683
$ this ->assertEquals ($ data , $ r );
667
684
}
685
+ $ this ->assertSame (['key ' ], $ keys );
668
686
}
669
687
670
688
public function testObjectAsDefaultValue ()
0 commit comments