@@ -344,8 +344,7 @@ public function testSaveExpired()
344344 $ item = $ this ->cache ->getItem ('key ' );
345345 $ item ->set ('value ' );
346346 $ 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 ' );
349348 $ item = $ this ->cache ->getItem ('key ' );
350349 $ this ->assertFalse ($ item ->isHit (), 'Cache should not save expired items ' );
351350 }
@@ -362,8 +361,6 @@ public function testSaveWithoutExpire()
362361 $ item ->set ('data ' );
363362 $ this ->cache ->save ($ item );
364363
365- sleep (1 );
366-
367364 // Use a new pool instance to ensure that we don't it any caches
368365 $ pool = $ this ->createCachePool ();
369366 $ item = $ pool ->getItem ('test_ttl_null ' );
@@ -412,8 +409,7 @@ public function testDeferredExpired()
412409 $ item = $ this ->cache ->getItem ('key ' );
413410 $ item ->set ('4711 ' );
414411 $ item ->expiresAt (\DateTime::createFromFormat ('U ' , time ()));
415- $ return = $ this ->cache ->saveDeferred ($ item );
416- sleep (1 );
412+ $ this ->assertFalse ($ this ->cache ->saveDeferred ($ item ));
417413
418414 $ this ->assertFalse ($ this ->cache ->hasItem ('key ' ), 'Cache should not have expired deferred item ' );
419415 $ this ->cache ->commit ();
@@ -492,11 +488,10 @@ public function testExpiration()
492488
493489 $ item = $ this ->cache ->getItem ('key ' );
494490 $ item ->set ('value ' );
495- // Expire after 2 seconds
496491 $ item ->expiresAfter (2 );
497492 $ this ->cache ->save ($ item );
498493
499- sleep (4 );
494+ sleep (2 );
500495 $ item = $ this ->cache ->getItem ('key ' );
501496 $ this ->assertFalse ($ item ->isHit ());
502497 $ this ->assertNull ($ item ->get (), "Item's value must be null when isHit() is false. " );
0 commit comments