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

StaticTest::testRun()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 10
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 15
rs 9.9332
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