-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCacheTest.php
More file actions
40 lines (34 loc) · 1.29 KB
/
CacheTest.php
File metadata and controls
40 lines (34 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
namespace Test\PHP\Cache\Core;
use PHP\Cache\Core\Cache;
class CacheTest extends \PHPUnit_Framework_TestCase
{
public function testCacheMethod()
{
$initialValue = $this->dummyMethod();
$this->assertNotEquals($initialValue, $this->dummyMethod("b"), 'Valor retornado foi idêntico');
$this->assertEquals($initialValue, $this->dummyMethod(), 'Valor retornado não foi idêntico');
$this->assertEquals($initialValue, $this->dummyMethod(), 'Valor retornado não foi idêntico');
}
public function testCacheClass()
{
$class = new DummyClass();
$initialValue = $class->dummyMethod();
$this->assertNotEquals($initialValue, $class->dummyMethod("b"), 'Valor retornado foi idêntico');
$this->assertEquals($initialValue, $class->dummyMethod(), 'Valor retornado não foi idêntico');
$this->assertEquals($initialValue, $class->dummyMethod(), 'Valor retornado não foi idêntico');
}
private function dummyMethod($a = "a", $b = "b")
{
return Cache::create(function () use ($a, $b) {
$curDate = date("Y-m-d H:i:s");
sleep(1);
return $curDate;
})
->once()
->statefull()
->scope(false)
->ttl(10)
->get();
}
}