Skip to content

Commit 16b0afb

Browse files
committed
Merge pull request #42 from php-cache/aequasi-patch-1
Recreating #39
2 parents 742983b + cdc4488 commit 16b0afb

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

src/CachePoolTest.php

+3-8
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)