Browse Source

added test

Mirko Pagliai 10 years ago
parent
commit
e0f10f8648
1 changed files with 28 additions and 0 deletions
  1. 28 0
      tests/TestCase/Cache/CacheTest.php

+ 28 - 0
tests/TestCase/Cache/CacheTest.php

@@ -556,6 +556,34 @@ class CacheTest extends TestCase
         Cache::enable();
         Cache::clear(false, 'test_cache_disable_2');
     }
+    
+    /**
+     * test clearAll() method
+     *
+     * @return void
+     */
+    public function testClearAll()
+    {
+        Cache::config('configTest', [
+            'engine' => 'File',
+            'path' => TMP . 'tests'
+        ]);
+        Cache::config('anotherConfigTest', [
+            'engine' => 'File',
+            'path' => TMP . 'tests'
+        ]);
+        
+        Cache::write('key_1', 'hello', 'configTest');
+        Cache::write('key_2', 'hello again', 'anotherConfigTest');
+        
+        $this->assertSame(Cache::read('key_1', 'configTest'), 'hello');
+        $this->assertSame(Cache::read('key_2', 'anotherConfigTest'), 'hello again');
+        
+        Cache::clearAll();
+        
+        $this->assertFalse(Cache::read('key_1', 'configTest'));
+        $this->assertFalse(Cache::read('key_2', 'anotherConfigTest'));
+    }
 
     /**
      * Test toggling enabled state of cache.