-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
128 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,59 @@ | ||
<?php namespace Dtkahl\SimpleConfig; | ||
<?php namespace Dtkahl\FileCache; | ||
|
||
class FileCacheTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
|
||
public function test() | ||
{ | ||
var_dump(time()); | ||
$cache = new Cache(__DIR__."/test_path/"); | ||
|
||
// get if not set | ||
$this->assertNull($cache->get("foo")); | ||
$this->assertEquals("default", $cache->get("foo", "default")); | ||
|
||
// test has = false | ||
$this->assertFalse($cache->has("foo")); | ||
|
||
// set & get if set | ||
$cache->set("foo", "bar"); | ||
$this->assertEquals("bar", $cache->get("foo")); | ||
|
||
// test has = true | ||
$this->assertTrue($cache->has("foo")); | ||
|
||
//test if cache has been written | ||
$cache->writeCache()->flush(true); | ||
$this->assertEquals("bar", $cache->get("foo")); | ||
|
||
// test remove | ||
$cache->forget("foo"); | ||
$this->assertNull($cache->get("foo")); | ||
|
||
// test remember | ||
$cache->remember("foo2", function () { | ||
return "bar2"; | ||
}); | ||
$cache->remember("foo2", function () { | ||
return "this will never be set"; | ||
}); | ||
$this->assertEquals("bar2", $cache->get("foo2")); | ||
|
||
// test timeout | ||
$cache->set("foo3", "bar3", 1); | ||
sleep(2); | ||
$this->assertNull($cache->get("foo3")); | ||
|
||
// test refresh | ||
$cache->set("foo4", "bar4", 4); | ||
sleep(2); | ||
$this->assertEquals("bar4", $cache->get("foo4")); | ||
sleep(2); | ||
$this->assertEquals("bar4", $cache->get("foo4")); | ||
sleep(5); | ||
$this->assertNull($cache->get("foo4")); | ||
|
||
// test flush | ||
$cache->flush(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
FileCacheTest will cache to this directory. | ||
|
||
This file is only present to commit this dir :P |