diff --git a/phpunit.xml b/phpunit.xml
index 0ed2e986..6d4c4976 100644
--- a/phpunit.xml
+++ b/phpunit.xml
@@ -29,7 +29,7 @@
./webfiori/framework/router/Router.php
./webfiori/framework/cache/AbstractCacheStore.php
- ./webfiori/framework/cache/FileCacheStore.php
+ ./webfiori/framework/cache/FileStorage.php
./webfiori/framework/cache/Cache.php
./webfiori/framework/session/Session.php
diff --git a/tests/webfiori/framework/test/cache/CacheTest.php b/tests/webfiori/framework/test/cache/CacheTest.php
index f65ef664..1ce12410 100644
--- a/tests/webfiori/framework/test/cache/CacheTest.php
+++ b/tests/webfiori/framework/test/cache/CacheTest.php
@@ -11,6 +11,7 @@ class CacheTest extends TestCase {
*/
public function test00() {
$key = 'first';
+ $this->assertTrue(Cache::isEnabled());
$data = Cache::get($key, function () {
return 'This is a test.';
});
@@ -84,4 +85,62 @@ public function test05() {
$this->assertFalse(Cache::has($key));
}
}
+ /**
+ * @test
+ */
+ public function test06() {
+ $key = 'bbuu';
+ $this->assertTrue(Cache::isEnabled());
+ Cache::setEnabled(false);
+ $data = Cache::get($key, function () {
+ return 'This is a test.';
+ });
+ $this->assertEquals('This is a test.', $data);
+ $this->assertNull(Cache::get($key));
+ $this->assertFalse(Cache::isEnabled());
+ }
+ /**
+ * @test
+ */
+ public function testSet00() {
+ $key = 'new_cool_key';
+ Cache::setEnabled(true);
+ $this->assertTrue(Cache::isEnabled());
+ $this->assertTrue(Cache::set($key, 'This is a test.', 60, false));
+ $this->assertEquals('This is a test.', Cache::get($key));
+ $item = Cache::getItem($key);
+ $this->assertEquals(60, $item->getTTL());
+
+ $this->assertFalse(Cache::set($key, 'This is a test.', 60, false));
+ $this->assertEquals('This is a test.', Cache::get($key));
+ $item = Cache::getItem($key);
+ $this->assertEquals(60, $item->getTTL());
+
+ $this->assertTrue(Cache::set($key, 'This is a test 2.', 660, true));
+ $this->assertEquals('This is a test 2.', Cache::get($key));
+ $item = Cache::getItem($key);
+ $this->assertEquals(660, $item->getTTL());
+ }
+ /**
+ * @test
+ */
+ public function testSetTTL00() {
+ $key = 'new_cool_key2';
+ Cache::setEnabled(true);
+ $this->assertTrue(Cache::isEnabled());
+ $this->assertTrue(Cache::set($key, 'This is a test.', 60, false));
+ $item = Cache::getItem($key);
+ $this->assertEquals(60, $item->getTTL());
+ Cache::setTTL($key, 700);
+
+ $item = Cache::getItem($key);
+ $this->assertEquals(700, $item->getTTL());
+ }
+ /**
+ * @test
+ */
+ public function testSetTTL01() {
+ $key = 'not exist cool';
+ $this->assertFalse(Cache::setTTL($key, 700));
+ }
}