diff --git a/cake/libs/cache/xcache.php b/cake/libs/cache/xcache.php index f684c8bb418..1ed9b0b5a6c 100644 --- a/cake/libs/cache/xcache.php +++ b/cake/libs/cache/xcache.php @@ -107,12 +107,12 @@ function delete($key) { */ function clear() { $this->__auth(); - for ($i = 0, $max = xcache_count(XC_TYPE_VAR); $i < $max; $i++) { + $max = xcache_count(XC_TYPE_VAR); + for ($i = 0; $i < $max; $i++) { xcache_clear_cache(XC_TYPE_VAR, $i); } - $result = xcache_count(XC_TYPE_VAR) == 0; $this->__auth(true); - return $result; + return true; } /** * Populates and reverses $_SERVER authentication values diff --git a/cake/tests/cases/libs/cache/xcache.test.php b/cake/tests/cases/libs/cache/xcache.test.php index 3f1c7375582..15d535b68ca 100644 --- a/cake/tests/cases/libs/cache/xcache.test.php +++ b/cake/tests/cases/libs/cache/xcache.test.php @@ -139,6 +139,23 @@ function testDeleteCache() { $result = Cache::delete('delete_test'); $this->assertTrue($result); } +/** + * testClearCache method + * + * @access public + * @return void + */ + function testClearCache() { + $data = 'this is a test of the emergency broadcasting system'; + $result = Cache::write('clear_test_1', $data); + $this->assertTrue($result); + + $result = Cache::write('clear_test_2', $data); + $this->assertTrue($result); + + $result = Cache::clear(); + $this->assertTrue($result); + } /** * tearDown method *