|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace TraitsTests; |
|
4
|
|
|
|
|
5
|
|
|
|
|
6
|
|
|
use kalanis\kw_files\Interfaces\ITypes; |
|
7
|
|
|
use kalanis\kw_files\Node; |
|
8
|
|
|
use kalanis\kw_tree\Traits\TFilesDirs; |
|
9
|
|
|
|
|
10
|
|
|
|
|
11
|
|
|
class FilesDirsTest extends \CommonTestClass |
|
12
|
|
|
{ |
|
13
|
|
|
/** |
|
14
|
|
|
* @param Node $node |
|
15
|
|
|
* @param bool $is |
|
16
|
|
|
* @dataProvider callbackProvider |
|
17
|
|
|
*/ |
|
18
|
|
|
public function testBasic(Node $node, bool $is): void |
|
19
|
|
|
{ |
|
20
|
|
|
$lib = new XFilesDirs(); |
|
21
|
|
|
$this->assertEquals($is, $lib->justDirsCallback($node)); |
|
22
|
|
|
} |
|
23
|
|
|
|
|
24
|
|
|
public function callbackProvider(): array |
|
25
|
|
|
{ |
|
26
|
|
|
return [ |
|
27
|
|
|
[(new Node())->setData([], 0, ITypes::TYPE_DIR), true], |
|
28
|
|
|
[(new Node())->setData([], 0, ITypes::TYPE_FILE), false], |
|
29
|
|
|
[(new Node())->setData([], 0, ITypes::TYPE_LINK), false], |
|
30
|
|
|
[(new Node())->setData([], 0, ITypes::TYPE_BLOCK), false], |
|
31
|
|
|
[(new Node())->setData([], 0, ITypes::TYPE_FIFO), false], |
|
32
|
|
|
[(new Node())->setData([], 0, ITypes::TYPE_CHAR), false], |
|
33
|
|
|
[(new Node())->setData([], 0, ITypes::TYPE_SOCKET), false], |
|
34
|
|
|
[(new Node())->setData([], 0, ITypes::TYPE_UNKNOWN), false], |
|
35
|
|
|
]; |
|
36
|
|
|
} |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
|
|
40
|
|
|
class XFilesDirs |
|
41
|
|
|
{ |
|
42
|
|
|
use TFilesDirs; |
|
43
|
|
|
} |
|
44
|
|
|
|