Completed
Push — master ( 28797f...652832 )
by Alexander
01:44
created

DependencyTest::testGenerateReusableHash()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 9
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
namespace Yiisoft\Cache\Tests\Dependency;
3
4
use Yiisoft\Cache\Dependency\Dependency;
5
use Yiisoft\Cache\NullCache;
6
7
/**
8
 * Dependency (abstract) tests.
9
 * @group caching
10
 */
11
class DependencyTest extends TestCase
0 ignored issues
show
Bug introduced by
The type Yiisoft\Cache\Tests\Dependency\TestCase was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
12
{
13
    public function testResetReusableData(): void
14
    {
15
        $value = ['dummy'];
16
        $dependency = new MockDependency();
0 ignored issues
show
Bug introduced by
The type Yiisoft\Cache\Tests\Dependency\MockDependency was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
17
        $this->setInaccessibleProperty($dependency, 'reusableData', $value, false);
18
        $this->assertEquals($value, $this->getInaccessibleProperty($dependency, 'reusableData'));
19
20
        $dependency->resetReusableData();
21
22
        $this->assertEquals([], $this->getInaccessibleProperty($dependency, 'reusableData'));
23
    }
24
25
    public function testGenerateReusableHash(): void
26
    {
27
        $dependency = $this->getMockForAbstractClass(Dependency::class);
28
        $this->setInaccessibleProperty($dependency, 'data', 'dummy');
29
30
        $result = $this->invokeMethod($dependency, 'generateReusableHash');
31
32
        $this->assertEquals(5, strlen($this->getInaccessibleProperty($dependency, 'data')));
33
        $this->assertEquals(40, strlen($result));
34
    }
35
36
    public function testIsChanged(): void
37
    {
38
        /* @var $dependency Dependency */
39
40
        $dependency = $this->getMockForAbstractClass(Dependency::class);
41
        $cache = new NullCache();
42
43
        $result = $dependency->isChanged($cache);
44
        $this->assertFalse($result);
45
46
        $this->setInaccessibleProperty($dependency, 'data', 'changed');
47
        $result = $dependency->isChanged($cache);
48
        $this->assertTrue($result);
49
    }
50
}
51