Passed
Push — master ( 380356...2e1f1e )
by Petr
10:45
created

StaticTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 15
c 1
b 0
f 0
dl 0
loc 31
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testFailExists() 0 6 1
A testRun() 0 15 1
1
<?php
2
3
namespace BasicTests;
4
5
6
use kalanis\kw_cache\Simple;
7
use kalanis\kw_cache\StaticCache;
8
use kalanis\kw_cache\CacheException;
9
10
11
class StaticTest extends \CommonTestClass
12
{
13
    /**
14
     * @throws CacheException
15
     */
16
    public function testRun(): void
17
    {
18
        StaticCache::setCache(new Simple\Memory());
19
        $this->assertNotEmpty(StaticCache::getCache());
20
        StaticCache::init('');
21
22
        $this->assertFalse(StaticCache::exists());
23
        $this->assertEquals('', StaticCache::get());
24
        // simple write
25
        $this->assertTrue(StaticCache::set(static::TESTING_CONTENT));
26
        $this->assertTrue(StaticCache::exists());
27
        $this->assertEquals(static::TESTING_CONTENT, StaticCache::get());
28
        // clear all
29
        StaticCache::clear();
30
        $this->assertFalse(StaticCache::exists());
31
    }
32
33
    /**
34
     * @throws CacheException
35
     */
36
    public function testFailExists(): void
37
    {
38
        StaticCache::setCache(null);
39
        $this->assertEmpty(StaticCache::getCache());
40
        $this->expectException(CacheException::class);
41
        StaticCache::init('');
42
    }
43
}
44