1 | <?php |
||
21 | class FilesystemTest extends TestCaseAbstract |
||
22 | { |
||
23 | /** |
||
24 | * setUp |
||
25 | * |
||
26 | * @since 3.2.0 |
||
27 | */ |
||
28 | |||
29 | public function setUp() : void |
||
30 | { |
||
31 | Stream::setup('root', 0777, $this->getJSON('tests' . DIRECTORY_SEPARATOR. 'unit-provider' . DIRECTORY_SEPARATOR. 'Filesystem' . DIRECTORY_SEPARATOR. 'FilesystemTest_setUp.json')); |
||
32 | } |
||
33 | |||
34 | /** |
||
35 | * testGetIterator |
||
36 | * |
||
37 | * @since 3.2.0 |
||
38 | * |
||
39 | * @param string $root |
||
40 | * @param bool $recursive |
||
41 | * @param array $filterArray |
||
42 | * @param array $expectArray |
||
43 | * |
||
44 | * @dataProvider providerAutoloader |
||
45 | */ |
||
46 | |||
47 | public function testGetIterator(string $root = null, bool $recursive = false, array $filterArray = [], array $expectArray = []) : void |
||
48 | { |
||
49 | /* setup */ |
||
50 | |||
51 | $filesystem = new Filesystem\Filesystem(); |
||
52 | $filesystem->init(Stream::url($root), $recursive, $filterArray); |
||
53 | |||
54 | /* actual */ |
||
55 | |||
56 | $actualIterator = $filesystem->getIterator(); |
||
57 | |||
58 | /* process iterator */ |
||
59 | |||
60 | if (iterator_count($actualIterator)) |
||
61 | { |
||
62 | foreach ($actualIterator as $key => $item) |
||
63 | { |
||
64 | $file = $item->getFileName(); |
||
65 | $path = $item->getPathName(); |
||
66 | $this->assertEquals($expectArray[$file], $this->normalizeSeparator($path)); |
||
67 | } |
||
68 | } |
||
69 | else |
||
70 | { |
||
71 | $this->assertIsObject($actualIterator); |
||
72 | } |
||
73 | } |
||
74 | |||
75 | /** |
||
76 | * testGetArray |
||
77 | * |
||
78 | * @since 3.2.0 |
||
79 | * |
||
80 | * @param string $root |
||
81 | * @param bool $recursive |
||
82 | * @param array $filterArray |
||
83 | * @param array $expectArray |
||
84 | * |
||
85 | * @dataProvider providerAutoloader |
||
86 | */ |
||
87 | |||
88 | public function testGetArray(string $root = null, bool $recursive = false, array $filterArray = [], array $expectArray = []) : void |
||
89 | { |
||
90 | /* setup */ |
||
91 | |||
92 | $filesystem = new Filesystem\Filesystem(); |
||
93 | $filesystem->init(Stream::url($root), $recursive, $filterArray); |
||
94 | |||
95 | /* actual */ |
||
96 | |||
97 | $actualArray = $filesystem->getArray(); |
||
98 | |||
99 | /* compare */ |
||
100 | |||
101 | $this->assertEquals($expectArray, $actualArray); |
||
102 | } |
||
103 | |||
104 | /** |
||
105 | * testGetSortArray |
||
106 | * |
||
107 | * @since 3.2.0 |
||
108 | * |
||
109 | * @param string $root |
||
110 | * @param bool $recursive |
||
111 | * @param array $filterArray |
||
112 | * @param array $expectArray |
||
113 | * |
||
114 | * @dataProvider providerAutoloader |
||
115 | */ |
||
116 | |||
117 | public function testGetSortArray(string $root = null, bool $recursive = false, array $filterArray = [], array $expectArray = []) : void |
||
132 | } |
||
133 |