1 | <?php |
||
9 | class CacheTest extends \PHPUnit_Framework_TestCase |
||
10 | { |
||
11 | const FIXED_ID = '/api/users'; |
||
12 | const STRING_VALUE = 'MyStringValue'; |
||
13 | |||
14 | private $redis; |
||
15 | private $generator; |
||
16 | private $cache; |
||
17 | private $faker; |
||
18 | |||
19 | public function setUp() |
||
20 | { |
||
21 | parent::setUp(); |
||
22 | |||
23 | $factory = new RedisMockFactory(); |
||
24 | $this->redis = $factory->getAdapter('Predis\Client', true); |
||
25 | $this->generator = new RedisETagGenerator(); |
||
26 | $this->cache = new RedisETagCache($this->generator, $this->redis); |
||
27 | $this->faker = Faker\Factory::create(); |
||
28 | } |
||
29 | |||
30 | public function testETagCreateWithStringValueShouldReturnValidEtag() |
||
31 | { |
||
32 | $etag = $this->generator->create(self::STRING_VALUE); |
||
33 | |||
34 | $this->assertEquals(md5(self::STRING_VALUE), $etag); |
||
35 | } |
||
36 | |||
37 | public function testETagCreateWithEmptyValueShouldReturnNull() |
||
38 | { |
||
39 | $etag = $this->generator->create(''); |
||
40 | |||
41 | $this->assertEquals(null, $etag); |
||
42 | } |
||
43 | |||
44 | public function testCacheSetETagWithStringValueReturnTrue() |
||
50 | |||
51 | public function testCacheGetETagByFixedIdReturnValidEtag() |
||
57 | |||
58 | public function testCacheGetETagByNullIdShouldBeNull() |
||
64 | } |
||
65 |