Passed
Pull Request — master (#31)
by Alexander
01:41
created

NullCacheTest::testSetKeyPrefix()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 4
rs 10
1
<?php
2
3
namespace Yiisoft\Cache\Tests;
4
5
use Yiisoft\Cache\NullCache;
6
7
class NullCacheTest extends TestCase
8
{
9
    private function getCache(): NullCache
10
    {
11
        return new NullCache();
12
    }
13
14
    public function testAdd(): void
15
    {
16
        $this->assertTrue($this->getCache()->add('key', 42));
17
    }
18
19
    public function testDeleteMultiple(): void
20
    {
21
        $this->assertTrue($this->getCache()->deleteMultiple(['a', 'b']));
22
    }
23
24
    public function testSet(): void
25
    {
26
        $this->assertTrue($this->getCache()->set('key', 42));
27
    }
28
29
    public function testGet(): void
30
    {
31
        $this->assertSame(42, $this->getCache()->get('key', 42));
32
    }
33
34
    public function testGetMultiple(): void
35
    {
36
        $this->assertSame(['a' => 42, 'b' => 42], $this->getCache()->getMultiple(['a', 'b'], 42));
37
    }
38
39
    public function testSetMultiple(): void
40
    {
41
        $this->assertTrue($this->getCache()->setMultiple(['a' => 42]));
42
    }
43
44
    public function testAddMultiple(): void
45
    {
46
        $this->assertTrue($this->getCache()->addMultiple(['a' => 42]));
47
    }
48
49
    public function testGetOrSet(): void
50
    {
51
        $this->assertSame(42, $this->getCache()->getOrSet('key', static function () {
52
            return 42;
53
        }));
54
    }
55
56
    public function testDelete(): void
57
    {
58
        $this->assertTrue($this->getCache()->delete('key'));
59
    }
60
61
    public function testClear(): void
62
    {
63
        $this->assertTrue($this->getCache()->clear());
64
    }
65
66
    public function testHas(): void
67
    {
68
        $this->assertFalse($this->getCache()->has('key'));
69
    }
70
71
    public function testEnableKeyNormalization(): void
72
    {
73
        $this->getCache()->enableKeyNormalization();
74
        $this->assertTrue(true);
75
    }
76
77
    public function testDisableKeyNormalization(): void
78
    {
79
        $this->getCache()->disableKeyNormalization();
80
        $this->assertTrue(true);
81
    }
82
83
    public function testSetKeyPrefix(): void
84
    {
85
        $this->getCache()->setKeyPrefix('prefix');
86
        $this->assertTrue(true);
87
    }
88
}
89