public function FeedsHTTPCacheTest::testClearExpired in Feeds 7.2
@covers FeedsHTTPCache::clear().
Tests if expired cached files can get cleaned up.
File
- tests/
FeedsHTTPCacheTest.test, line 347
Class
- FeedsHTTPCacheTest
- @coversDefaultClass FeedsHTTPCache @group feeds
Code
public function testClearExpired() {
// Create a cache entry that should not expire.
$cid_permanent = $this
->createCacheRecordUsingApi();
// Create a cache entry with an expire time in the past.
$cid_expire_past = static::randomName();
$this->cache
->set($cid_expire_past, $this
->createHttpResponse(), REQUEST_TIME - 60);
// Create a cache entry that expires exactly now.
$cid_expire_now = static::randomName();
$this->cache
->set($cid_expire_now, $this
->createHttpResponse(), REQUEST_TIME);
// Create a cache entry that expires in the future.
$cid_expire_future = static::randomName();
$this->cache
->set($cid_expire_future, $this
->createHttpResponse(), REQUEST_TIME + 60);
// Clear all expired cache entries.
$this->cache
->clear();
// Assert existence of cache entries.
$this
->assertCacheItemExists($cid_permanent);
$this
->assertNoCacheItemExists($cid_expire_past);
$this
->assertCacheItemExists($cid_expire_now);
$this
->assertCacheItemExists($cid_expire_future);
// Assert existence of cache files.
$this
->assertCacheFileExists($cid_permanent);
$this
->assertNoCacheFileExists($cid_expire_past);
$this
->assertCacheFileExists($cid_expire_now);
$this
->assertCacheFileExists($cid_expire_future);
}