Skip to content
This repository was archived by the owner on Mar 1, 2023. It is now read-only.

Commit 6ac32e9

Browse files
committed
Write tests for expired entries
1 parent d66a4cc commit 6ac32e9

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

tests/CacheTest.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,36 @@ public function testRemoveItem()
5454

5555
$this->assertEquals(0, $count);
5656
}
57+
58+
public function testExpireEntry()
59+
{
60+
$uriCache = new UriCache();
61+
62+
$cacheItem = $uriCache->addCacheItem('someUriDest', 'someUri');
63+
64+
// Set the expiry time to the past.
65+
$cacheItem->setExpireTime(time() - 1);
66+
67+
// getCacheItem will return false if the item has expired.
68+
$returnedCacheItem = $uriCache->getCacheItem('someUriDest');
69+
70+
$this->assertEquals(false, $returnedCacheItem);
71+
}
72+
73+
public function testPruneEntries()
74+
{
75+
$uriCache = new UriCache();
76+
77+
$cacheItem = $uriCache->addCacheItem('someUriDest', 'someUri');
78+
79+
// Set the expiry time to the past.
80+
$cacheItem->setExpireTime(time() - 1);
81+
82+
$uriCache->pruneOldItems();
83+
84+
// Now we should have 0 items.
85+
$itemCount = $uriCache->getItemCount();
86+
87+
$this->assertEquals(0, $itemCount);
88+
}
5789
}

0 commit comments

Comments
 (0)