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

NullCacheTest   A

Complexity

Total Complexity 15

Size/Duplication

Total Lines 80
Duplicated Lines 0 %

Importance

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

15 Methods

Rating   Name   Duplication   Size   Complexity  
A testDeleteMultiple() 0 3 1
A testSetMultiple() 0 3 1
A testGetMultiple() 0 3 1
A testGet() 0 3 1
A getCache() 0 3 1
A testAddMultiple() 0 3 1
A testClear() 0 3 1
A testDelete() 0 3 1
A testHas() 0 3 1
A testEnableKeyNormalization() 0 4 1
A testSet() 0 3 1
A testGetOrSet() 0 4 1
A testAdd() 0 3 1
A testDisableKeyNormalization() 0 4 1
A testSetKeyPrefix() 0 4 1
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