You are here

public function FeedsHTTPCacheTest::testClearUsingWildcard in Feeds 7.2

@covers FeedsHTTPCache::clear().

Tests if cached files starting with a certain string can get cleaned up.

File

tests/FeedsHTTPCacheTest.test, line 467

Class

FeedsHTTPCacheTest
@coversDefaultClass FeedsHTTPCache @group feeds

Code

public function testClearUsingWildcard() {

  // Create a few cids, where the first few chars of cid1 and cid3 are the
  // same and cid2 has a completely different string.
  $cid1 = 'abc123';
  $cid2 = 'def456';
  $cid3 = 'abc789';
  $this
    ->createCacheRecordUsingApi($cid1);
  $this
    ->createCacheRecordUsingApi($cid2);
  $this
    ->createCacheRecordUsingApi($cid3);

  // Clear all cache entries that start with 'abc'.
  $this->cache
    ->clear('abc', TRUE);

  // Assert that all records starting with 'abc' are gone.
  $this
    ->assertNoCacheItemExists($cid1);
  $this
    ->assertCacheItemExists($cid2);
  $this
    ->assertNoCacheItemExists($cid3);

  // Assert that all files in the cache dir starting with 'abc' are gone.
  $this
    ->assertNoCacheFileExists($cid1);
  $this
    ->assertCacheFileExists($cid2);
  $this
    ->assertNoCacheFileExists($cid3);
}