Passed
Push — master ( 79545d...728467 )
by Petr
02:28
created

NodeTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 28
c 1
b 0
f 0
dl 0
loc 47
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testThrough() 0 27 1
A testRoot() 0 8 1
1
<?php
2
3
namespace StorageBasicTests;
4
5
6
use kalanis\kw_files\FilesException;
7
use kalanis\kw_paths\PathsException;
8
9
10
class NodeTest extends AStorageTest
11
{
12
    /**
13
     * @throws FilesException
14
     * @throws PathsException
15
     */
16
    public function testThrough(): void
17
    {
18
        $lib = $this->getNodeLib();
19
        $this->assertFalse($lib->exists(['unknown']));
20
        $this->assertTrue($lib->exists(['dummy2.txt']));
21
        $this->assertTrue($lib->exists(['sub']));
22
        $this->assertTrue($lib->exists(['sub', 'dummy3.txt']));
23
24
        $this->assertFalse($lib->isDir(['unknown']));
25
        $this->assertTrue($lib->isReadable(['unknown'])); // because cannot check real status on flat k-v storage
26
        $this->assertTrue($lib->isWritable(['unknown']));
27
        $this->assertFalse($lib->isDir(['dummy2.txt']));
28
        $this->assertTrue($lib->isDir(['sub']));
29
        $this->assertTrue($lib->isReadable(['sub']));
30
        $this->assertTrue($lib->isWritable(['sub']));
31
32
        $this->assertFalse($lib->isFile(['unknown']));
33
        $this->assertTrue($lib->isFile(['dummy2.txt']));
34
        $this->assertFalse($lib->isFile(['sub']));
35
36
        $this->assertNull($lib->size(['unknown']));
37
        $this->assertEquals(36, $lib->size(['dummy2.txt']));
38
        $this->assertEquals(36, $lib->size(['other1.txt']));
39
        $this->assertEquals(6, $lib->size(['sub']));
40
41
        $this->assertNull($lib->created(['unknown']));
42
        $this->assertNull($lib->created(['sub'])); // no data here
43
    }
44
45
    /**
46
     * @throws FilesException
47
     * @throws PathsException
48
     */
49
    public function testRoot(): void
50
    {
51
        $lib = $this->getNodeLib();
52
        $this->assertTrue($lib->exists([]));
53
        $this->assertTrue($lib->isDir([]));
54
        $this->assertFalse($lib->isFile([]));
55
        $this->assertNull($lib->size([]));
56
        $this->assertNull($lib->created([]));
57
    }
58
}
59