From e1ad90ba40b74ec103b9113e49b9792b2b422d22 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Sun, 13 Sep 2009 17:49:51 +0000 Subject: - Patch #575360 by dropcube: added API function to check if a cache bin is empty. --- modules/simpletest/tests/cache.test | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'modules') diff --git a/modules/simpletest/tests/cache.test b/modules/simpletest/tests/cache.test index 8de74b04e..0fc9fe298 100644 --- a/modules/simpletest/tests/cache.test +++ b/modules/simpletest/tests/cache.test @@ -312,3 +312,40 @@ class CacheClearCase extends CacheTestCase { t('All cache entries removed when the array exceeded the cache clear threshold.')); } } + +/** + * Test cache_is_empty() function. + */ +class CacheIsEmptyCase extends CacheTestCase { + public static function getInfo() { + return array( + 'name' => 'Cache emptiness test', + 'description' => 'Check if a cache bin is empty after performing clear operations.', + 'group' => 'Cache' + ); + } + + function setUp() { + $this->default_bin = 'cache_page'; + $this->default_value = $this->randomName(10); + + parent::setUp(); + } + + /** + * Test clearing using a cid. + */ + function testIsEmpty() { + // Clear the cache bin. + cache_clear_all('*', $this->default_bin); + $this->assertTrue(cache_is_empty($this->default_bin), t('The cache bin is empty')); + // Add some data to the cache bin. + cache_set($this->default_cid, $this->default_value, $this->default_bin); + $this->assertCacheExists(t('Cache was set.'), $this->default_value, $this->default_cid); + $this->assertFalse(cache_is_empty($this->default_bin), t('The cache bin is not empty')); + // Remove the cached data. + cache_clear_all($this->default_cid, $this->default_bin); + $this->assertCacheRemoved(t('Cache was removed.'), $this->default_cid); + $this->assertTrue(cache_is_empty($this->default_bin), t('The cache bin is empty')); + } +} -- cgit v1.2.3