Passed
Push — master ( 4d0668...60ad61 )
by Petr
07:54
created

BasicTest::testNotExists()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 6
rs 10
1
<?php
2
3
namespace StorageTests;
4
5
6
use kalanis\kw_cache\CacheException;
7
use kalanis\kw_cache\Storage;
8
9
10
class BasicTest extends AStorageTest
11
{
12
    /**
13
     * @throws CacheException
14
     */
15
    public function testRun(): void
16
    {
17
        $lib = new Storage\Basic($this->getStorage(new \MockStorage()));
18
        $lib->init('');
19
20
        $this->assertFalse($lib->exists());
21
        $this->assertEquals('', $lib->get());
22
        $this->assertTrue($lib->set(static::TESTING_CONTENT));
23
        $this->assertTrue($lib->exists());
24
        $this->assertEquals(static::TESTING_CONTENT, $lib->get());
25
        $lib->clear();
26
        $this->assertFalse($lib->exists());
27
    }
28
29
    /**
30
     * @throws CacheException
31
     */
32
    public function testNotExists(): void
33
    {
34
        $lib = new Storage\Basic($this->getStorage(new \MockKillingStorage3()));
35
        $lib->init('');
36
        $this->expectException(CacheException::class);
37
        $lib->exists();
38
    }
39
40
    /**
41
     * @throws CacheException
42
     */
43
    public function testNotSet(): void
44
    {
45
        $lib = new Storage\Basic($this->getStorage(new \MockKillingStorage2()));
46
        $lib->init('');
47
        $this->expectException(CacheException::class);
48
        $lib->set('lkjhgfdsa');
49
    }
50
51
    /**
52
     * @throws CacheException
53
     */
54
    public function testNotGet(): void
55
    {
56
        $lib = new Storage\Basic($this->getStorage(new \MockKillingStorage2()));
57
        $lib->init('');
58
        $this->expectException(CacheException::class);
59
        $lib->get();
60
    }
61
62
    /**
63
     * @throws CacheException
64
     */
65
    public function testNotClear(): void
66
    {
67
        $lib = new Storage\Basic($this->getStorage(new \MockKillingStorage2()));
68
        $lib->init('');
69
        $this->expectException(CacheException::class);
70
        $lib->clear();
71
    }
72
}
73