@@ -344,8 +344,7 @@ public function testSaveExpired()
344
344
$ item = $ this ->cache ->getItem ('key ' );
345
345
$ item ->set ('value ' );
346
346
$ item ->expiresAt (\DateTime::createFromFormat ('U ' , time ()));
347
- sleep (1 );
348
- $ this ->cache ->save ($ item );
347
+ $ this ->assertFalse ($ this ->cache ->save ($ item ), 'Cache should not save expired items ' );
349
348
$ item = $ this ->cache ->getItem ('key ' );
350
349
$ this ->assertFalse ($ item ->isHit (), 'Cache should not save expired items ' );
351
350
}
@@ -362,8 +361,6 @@ public function testSaveWithoutExpire()
362
361
$ item ->set ('data ' );
363
362
$ this ->cache ->save ($ item );
364
363
365
- sleep (1 );
366
-
367
364
// Use a new pool instance to ensure that we don't it any caches
368
365
$ pool = $ this ->createCachePool ();
369
366
$ item = $ pool ->getItem ('test_ttl_null ' );
@@ -412,8 +409,7 @@ public function testDeferredExpired()
412
409
$ item = $ this ->cache ->getItem ('key ' );
413
410
$ item ->set ('4711 ' );
414
411
$ item ->expiresAt (\DateTime::createFromFormat ('U ' , time ()));
415
- $ return = $ this ->cache ->saveDeferred ($ item );
416
- sleep (1 );
412
+ $ this ->assertFalse ($ this ->cache ->saveDeferred ($ item ));
417
413
418
414
$ this ->assertFalse ($ this ->cache ->hasItem ('key ' ), 'Cache should not have expired deferred item ' );
419
415
$ this ->cache ->commit ();
@@ -492,11 +488,10 @@ public function testExpiration()
492
488
493
489
$ item = $ this ->cache ->getItem ('key ' );
494
490
$ item ->set ('value ' );
495
- // Expire after 2 seconds
496
491
$ item ->expiresAfter (2 );
497
492
$ this ->cache ->save ($ item );
498
493
499
- sleep (4 );
494
+ sleep (2 );
500
495
$ item = $ this ->cache ->getItem ('key ' );
501
496
$ this ->assertFalse ($ item ->isHit ());
502
497
$ this ->assertNull ($ item ->get (), "Item's value must be null when isHit() is false. " );
0 commit comments