@@ -130,6 +130,13 @@ public function testSet()
130
130
$ result = $ this ->cache ->set ('key ' , 'value ' );
131
131
$ this ->assertTrue ($ result , 'set() must return true if success ' );
132
132
$ 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
+ }
133
140
134
141
$ result = $ this ->cache ->set ('key1 ' , 'value ' , 1 );
135
142
$ this ->assertTrue ($ result , 'set() must return true if success ' );
@@ -143,7 +150,7 @@ public function testSet()
143
150
$ this ->assertNull ($ this ->cache ->get ('key2 ' ), 'Value must expire after ttl. ' );
144
151
}
145
152
146
- public function testSetTtl ()
153
+ public function testSetExpiredTtl ()
147
154
{
148
155
if (isset ($ this ->skippedTests [__FUNCTION__ ])) {
149
156
$ this ->markTestSkipped ($ this ->skippedTests [__FUNCTION__ ]);
@@ -207,6 +214,17 @@ public function testSetMultiple()
207
214
$ this ->assertEquals ('value0 ' , $ this ->cache ->get ('key0 ' ));
208
215
$ this ->assertEquals ('value1 ' , $ this ->cache ->get ('key1 ' ));
209
216
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
+
210
228
$ this ->cache ->setMultiple (['key2 ' => 'value2 ' , 'key3 ' => 'value3 ' ], 1 );
211
229
$ this ->assertEquals ('value2 ' , $ this ->cache ->get ('key2 ' ));
212
230
$ this ->assertEquals ('value3 ' , $ this ->cache ->get ('key3 ' ));
@@ -220,7 +238,7 @@ public function testSetMultiple()
220
238
$ this ->assertNull ($ this ->cache ->get ('key4 ' ), 'Value must expire after ttl. ' );
221
239
}
222
240
223
- public function testSetMultipleTtl ()
241
+ public function testSetMultipleExpiredTtl ()
224
242
{
225
243
if (isset ($ this ->skippedTests [__FUNCTION__ ])) {
226
244
$ this ->markTestSkipped ($ this ->skippedTests [__FUNCTION__ ]);
@@ -363,9 +381,6 @@ public function testGetMultipleInvalidKeys($key)
363
381
}
364
382
365
383
$ result = $ this ->cache ->getMultiple (['key1 ' , $ key , 'key2 ' ]);
366
- foreach ($ result as $ r ) {
367
- // We want to make sure we iterate over the results
368
- }
369
384
}
370
385
371
386
/**
@@ -378,9 +393,6 @@ public function testGetMultipleNoIterable()
378
393
}
379
394
380
395
$ result = $ this ->cache ->getMultiple ('key ' );
381
- foreach ($ result as $ r ) {
382
- // We want to make sure we iterate over the results
383
- }
384
396
}
385
397
386
398
/**
@@ -406,11 +418,16 @@ public function testSetMultipleInvalidKeys($key)
406
418
$ this ->markTestSkipped ($ this ->skippedTests [__FUNCTION__ ]);
407
419
}
408
420
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 ' );
411
423
}
412
424
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 ());
414
431
}
415
432
416
433
/**
0 commit comments