1 cache.test CacheIsEmptyCase::testIsEmpty()

Test clearing using a cid.

File

core/modules/simpletest/tests/cache.test, line 315

Class

CacheIsEmptyCase
Test isEmpty() method.

Code

function testIsEmpty() {
  // Clear the cache bin.
  $cache = cache($this->default_bin);
  $cache->flush();
  $this->assertTrue($cache->isEmpty(), 'The cache bin is empty');
  // Add some data to the cache bin.
  $cache->set($this->default_cid, $this->default_value);
  $this->assertCacheExists(t('Cache was set.'), $this->default_value, $this->default_cid);
  $this->assertFalse($cache->isEmpty(), 'The cache bin is not empty');
  // Remove the cached data.
  $cache->delete($this->default_cid);
  $this->assertCacheRemoved(t('Cache was removed.'), $this->default_cid);
  $this->assertTrue($cache->isEmpty(), 'The cache bin is empty');
}