@@ -130,6 +130,13 @@ public function testSet()
130130 $ result = $ this ->cache ->set ('key ' , 'value ' );
131131 $ this ->assertTrue ($ result , 'set() must return true if success ' );
132132 $ this ->assertEquals ('value ' , $ this ->cache ->get ('key ' ));
133+ }
134+
135+ public function testSetTtl ()
136+ {
137+ if (isset ($ this ->skippedTests [__FUNCTION__ ])) {
138+ $ this ->markTestSkipped ($ this ->skippedTests [__FUNCTION__ ]);
139+ }
133140
134141 $ result = $ this ->cache ->set ('key1 ' , 'value ' , 1 );
135142 $ this ->assertTrue ($ result , 'set() must return true if success ' );
@@ -143,7 +150,7 @@ public function testSet()
143150 $ this ->assertNull ($ this ->cache ->get ('key2 ' ), 'Value must expire after ttl. ' );
144151 }
145152
146- public function testSetTtl ()
153+ public function testSetExpiredTtl ()
147154 {
148155 if (isset ($ this ->skippedTests [__FUNCTION__ ])) {
149156 $ this ->markTestSkipped ($ this ->skippedTests [__FUNCTION__ ]);
@@ -207,6 +214,17 @@ public function testSetMultiple()
207214 $ this ->assertEquals ('value0 ' , $ this ->cache ->get ('key0 ' ));
208215 $ this ->assertEquals ('value1 ' , $ this ->cache ->get ('key1 ' ));
209216
217+ $ result = $ this ->cache ->setMultiple (['0 ' => 'value0 ' ]);
218+ $ this ->assertTrue ($ result , 'setMultiple() must return true if success ' );
219+ $ this ->assertEquals ('value0 ' , $ this ->cache ->get ('0 ' ));
220+ }
221+
222+ public function testSetMultipleTtl ()
223+ {
224+ if (isset ($ this ->skippedTests [__FUNCTION__ ])) {
225+ $ this ->markTestSkipped ($ this ->skippedTests [__FUNCTION__ ]);
226+ }
227+
210228 $ this ->cache ->setMultiple (['key2 ' => 'value2 ' , 'key3 ' => 'value3 ' ], 1 );
211229 $ this ->assertEquals ('value2 ' , $ this ->cache ->get ('key2 ' ));
212230 $ this ->assertEquals ('value3 ' , $ this ->cache ->get ('key3 ' ));
@@ -220,7 +238,7 @@ public function testSetMultiple()
220238 $ this ->assertNull ($ this ->cache ->get ('key4 ' ), 'Value must expire after ttl. ' );
221239 }
222240
223- public function testSetMultipleTtl ()
241+ public function testSetMultipleExpiredTtl ()
224242 {
225243 if (isset ($ this ->skippedTests [__FUNCTION__ ])) {
226244 $ this ->markTestSkipped ($ this ->skippedTests [__FUNCTION__ ]);
@@ -363,9 +381,6 @@ public function testGetMultipleInvalidKeys($key)
363381 }
364382
365383 $ result = $ this ->cache ->getMultiple (['key1 ' , $ key , 'key2 ' ]);
366- foreach ($ result as $ r ) {
367- // We want to make sure we iterate over the results
368- }
369384 }
370385
371386 /**
@@ -378,9 +393,6 @@ public function testGetMultipleNoIterable()
378393 }
379394
380395 $ result = $ this ->cache ->getMultiple ('key ' );
381- foreach ($ result as $ r ) {
382- // We want to make sure we iterate over the results
383- }
384396 }
385397
386398 /**
@@ -406,11 +418,16 @@ public function testSetMultipleInvalidKeys($key)
406418 $ this ->markTestSkipped ($ this ->skippedTests [__FUNCTION__ ]);
407419 }
408420
409- if (is_array ( $ key ) || is_object ($ key )) {
410- $ this ->markTestSkipped ('We cannot use objects or arrays as keys. Skipping test. ' );
421+ if (is_int ($ key )) {
422+ $ this ->markTestSkipped ('As keys, strings are always casted to ints so they should be accepted ' );
411423 }
412424
413- $ this ->cache ->setMultiple (['key1 ' => 'foo ' , $ key => 'bar ' , 'key2 ' => 'baz ' ]);
425+ $ values = function () use ($ key ) {
426+ yield 'key1 ' => 'foo ' ;
427+ yield $ key => 'bar ' ;
428+ yield 'key2 ' => 'baz ' ;
429+ };
430+ $ this ->cache ->setMultiple ($ values ());
414431 }
415432
416433 /**
0 commit comments