From f019275be7d960060c682c69d462832fd53e02f2 Mon Sep 17 00:00:00 2001 From: David Rothstein Date: Mon, 5 Aug 2013 01:36:56 -0400 Subject: Issue #238250 by markpavlitski | Xano: Fixed cache_clear_all()('*', 'block', TRUE); will TRUNCATE the {block} table without additional checks. --- modules/simpletest/tests/cache.test | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'modules/simpletest/tests') diff --git a/modules/simpletest/tests/cache.test b/modules/simpletest/tests/cache.test index 997f37aef..b42de360b 100644 --- a/modules/simpletest/tests/cache.test +++ b/modules/simpletest/tests/cache.test @@ -340,6 +340,30 @@ class CacheClearCase extends CacheTestCase { } } + /** + * Test DrupalDatabaseCache::isValidBin(). + */ + function testIsValidBin() { + // Retrieve existing cache bins. + $valid_bins = array('cache', 'cache_filter', 'cache_page', 'cache_boostrap', 'cache_path'); + $valid_bins = array_merge(module_invoke_all('flush_caches'), $valid_bins); + foreach ($valid_bins as $id => $bin) { + $cache = _cache_get_object($bin); + if ($cache instanceof DrupalDatabaseCache) { + $this->assertTrue($cache->isValidBin(), format_string('Cache bin @bin is valid.', array('@bin' => $bin))); + } + } + + // Check for non-cache tables and invalid bins. + $invalid_bins = array('block', 'filter', 'missing_table', $this->randomName()); + foreach ($invalid_bins as $id => $bin) { + $cache = _cache_get_object($bin); + if ($cache instanceof DrupalDatabaseCache) { + $this->assertFalse($cache->isValidBin(), format_string('Cache bin @bin is not valid.', array('@bin' => $bin))); + } + } + } + /** * Test minimum cache lifetime. */ -- cgit v1.2.3