Passed
Push — master ( af3dcf...3709c1 )
by Petr
02:16
created

TreeTest::testGetFiles()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 12
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 15
rs 9.8666
1
<?php
2
3
namespace EntriesSourceTests;
4
5
6
use kalanis\kw_menu\EntriesSource;
7
use kalanis\kw_menu\MenuException;
8
use kalanis\kw_paths\PathsException;
9
use kalanis\kw_tree as XTree;
10
11
12
class TreeTest extends \CommonTestClass
13
{
14
    /**
15
     * @throws MenuException
16
     * @throws PathsException
17
     */
18
    public function testGetFiles(): void
19
    {
20
        $lib = $this->getLib();
21
        $iter = $lib->getFiles([]);
22
        $files = iterator_to_array($iter);
23
        $this->assertNotEmpty($files);
24
        $this->assertTrue(in_array('dummy4.htm', $files));
25
        $this->assertFalse(in_array('dummy5.htm', $files));
26
27
        $iter2 = $lib->getFiles(['dummy3']);
28
        $files2 = iterator_to_array($iter2);
29
        $this->assertFalse(in_array('dummy4.htm', $files2));
30
        $this->assertTrue(in_array('dummy5.htm', $files2));
31
    }
32
33
    protected function getLib(): EntriesSource\Tree
34
    {
35
        return new EntriesSource\Tree(new XTree\DataSources\Volume($this->getTargetPath()));
36
    }
37
}
38