Test Failed
Push — master ( f9dc8e...64f7bc )
by Petr
08:10
created

DirDescTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 15
dl 0
loc 35
rs 10
c 1
b 0
f 0
wmc 2
1
<?php
2
3
namespace SourcesTests;
4
5
6
use CommonTestClass;
7
use kalanis\kw_files\Access\Factory;
8
use kalanis\kw_files\Extended\Config;
9
use kalanis\kw_files\FilesException;
10
use kalanis\kw_images\Sources\DirDesc;
11
use kalanis\kw_paths\PathsException;
12
use kalanis\kw_storage\Storage\Key;
13
use kalanis\kw_storage\Storage\Target;
14
15
16
class DirDescTest extends CommonTestClass
17
{
18
    /**
19
     * @throws FilesException
20
     * @throws PathsException
21
     */
22
    public function testProcessing(): void
23
    {
24
        $lib = $this->getLib();
25
        $this->assertFalse($lib->canUse(['testtree']));
26
        $this->assertFalse($lib->isHere(['testtree']));
27
        $this->assertEmpty($lib->get(['testtree']));
28
29
        $lib->set(['testtree'], static::TEST_STRING);
30
        $this->assertTrue($lib->isHere(['testtree']));
31
        $this->assertEquals(static::TEST_STRING, $lib->get(['testtree']));
32
33
        $lib->remove(['testtree']);
34
        $this->assertFalse($lib->isHere(['testtree']));
35
        $this->assertEmpty($lib->get(['testtree']));
36
37
        $this->expectException(FilesException::class);
38
        $lib->get(['testtree'], true);
39
    }
40
41
    /**
42
     * @param array<string, string|int> $params
43
     * @throws FilesException
44
     * @throws PathsException
45
     * @return DirDesc
46
     */
47
    protected function getLib(array $params = [])
48
    {
49
        $storage = new \kalanis\kw_storage\Storage\Storage(new Key\DefaultKey(), new Target\Memory());
50
        return new DirDesc((new Factory())->getClass($storage), (new Config())->setData($params));
51
    }
52
}
53