Passed
Push — master ( 1b1dbd...2b0006 )
by Petr
10:06
created

StorageTest::tearDown()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 5
c 1
b 0
f 0
nc 4
nop 0
dl 0
loc 9
rs 10
1
<?php
2
3
namespace StorageTests;
4
5
6
use CommonTestClass;
7
use kalanis\kw_storage\Storage\Target;
8
9
10
class StorageTest extends CommonTestClass
11
{
12
    public function tearDown(): void
13
    {
14
        if (is_file($this->mockTestFile())) {
15
            unlink($this->mockTestFile());
16
        }
17
        if (is_dir($this->mockTestFile())) {
18
            rmdir($this->mockTestFile());
19
        }
20
        parent::tearDown();
21
    }
22
23
    public function testFactory(): void
24
    {
25
        $factory = new Target\Factory();
26
        $this->assertInstanceOf('\TargetMock', $factory->getStorage(new \TargetMock()));
27
        $this->assertEmpty($factory->getStorage([]));
28
        $this->assertInstanceOf('\kalanis\kw_storage\Storage\Target\Volume', $factory->getStorage(['storage' => 'volume']));
29
        $this->assertEmpty($factory->getStorage(['storage' => 'none']));
30
        $this->assertInstanceOf('\kalanis\kw_storage\Storage\Target\Volume', $factory->getStorage('volume'));
31
        $this->assertEmpty($factory->getStorage('none'));
0 ignored issues
show
Bug introduced by
Are you sure the usage of $factory->getStorage('none') targeting kalanis\kw_storage\Stora...t\Factory::getStorage() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
32
        $this->assertEmpty($factory->getStorage('what'));
0 ignored issues
show
Bug introduced by
Are you sure the usage of $factory->getStorage('what') targeting kalanis\kw_storage\Stora...t\Factory::getStorage() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
33
        $this->assertEmpty($factory->getStorage(null));
34
    }
35
}
36