ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
FilesystemTest.php
Go to the documentation of this file.
1<?php
2
3/*
4 * This file is part of Component Installer.
5 *
6 * (c) Rob Loach (http://robloach.net)
7 *
8 * For the full copyright and license information, please view the LICENSE.md
9 * file that was distributed with this source code.
10 */
11
13
15
20{
29 public function testRecursiveGlobFiles($expected, $pattern, $flags = 0)
30 {
31 $fs = new Filesystem();
32 $result = $fs->recursiveGlobFiles($pattern, $flags);
33
34 // Sort the arrays so that the indexes don't matter.
35 sort($expected);
36 sort($result);
37
38 $this->assertEquals($expected, $result);
39 }
40
42 {
43 $tests[] = array(
44 array(
45 'tests/ComponentInstaller/Test/Resources/img.jpg',
46 'tests/ComponentInstaller/Test/Resources/img2.jpg',
47 'tests/ComponentInstaller/Test/Resources/test.css',
48 'tests/ComponentInstaller/Test/Resources/test.js',
49 'tests/ComponentInstaller/Test/Resources/test2.css',
50 'tests/ComponentInstaller/Test/Resources/test2.js',
51 ),
52 'tests/ComponentInstaller/Test/Resources/*',
53 );
54
55 $tests[] = array(
56 array(
57 'tests/ComponentInstaller/Test/Resources/test.css',
58 'tests/ComponentInstaller/Test/Resources/test2.css',
59 ),
60 'tests/ComponentInstaller/Test/Resources/*.css',
61 );
62
63 $tests[] = array(
64 array(
65 'tests/ComponentInstaller/Test/Resources/img.jpg',
66 'tests/ComponentInstaller/Test/Resources/img2.jpg',
67 ),
68 'tests/ComponentInstaller/Test/Resources/*.jpg',
69 );
70
71 $tests[] = array(
72 array(
73 'tests/ComponentInstaller/Test/Resources/img.jpg',
74 'tests/ComponentInstaller/Test/Resources/img2.jpg',
75 ),
76 'tests/ComponentInstaller/Test/Resources/*img*',
77 );
78
79 $tests[] = array(
80 array(
81 'tests/ComponentInstaller/Test/Resources/img.jpg',
82 ),
83 'tests/ComponentInstaller/Test/Resources/img.jpg',
84 );
85
86 $tests[] = array(
87 array(
88 'tests/ComponentInstaller/Test/Resources/img.jpg',
89 'tests/ComponentInstaller/Test/Resources/img2.jpg',
90 'tests/ComponentInstaller/Test/Resources/subdir/img.jpg',
91 'tests/ComponentInstaller/Test/Resources/subdir/img3.jpg',
92 'tests/ComponentInstaller/Test/Resources/subdir/subdir2/img4.jpg',
93 ),
94 'tests/ComponentInstaller/Test/Resources/**img*.jpg',
95 );
96
97 return $tests;
98 }
99
108 public function testRecursiveGlob($expected, $pattern, $flags = 0)
109 {
110 $fs = new Filesystem();
111 $result = $fs->recursiveGlob($pattern, $flags);
112
113 // Sort the arrays so that the indexes don't matter.
114 sort($expected);
115 sort($result);
116 $this->assertEquals($expected, $result);
117 }
118
119 public function providerRecursiveGlob()
120 {
121 $tests[] = array(
122 array(
123 'tests/ComponentInstaller/Test/Resources/img.jpg',
124 'tests/ComponentInstaller/Test/Resources/img2.jpg',
125 'tests/ComponentInstaller/Test/Resources/test.css',
126 'tests/ComponentInstaller/Test/Resources/test.js',
127 'tests/ComponentInstaller/Test/Resources/test2.css',
128 'tests/ComponentInstaller/Test/Resources/test2.js',
129 'tests/ComponentInstaller/Test/Resources/subdir',
130 ),
131 'tests/ComponentInstaller/Test/Resources/*',
132 );
133
134 $tests[] = array(
135 array(
136 'tests/ComponentInstaller/Test/Resources/test.css',
137 'tests/ComponentInstaller/Test/Resources/test2.css',
138 ),
139 'tests/ComponentInstaller/Test/Resources/*.css',
140 );
141
142 $tests[] = array(
143 array(
144 'tests/ComponentInstaller/Test/Resources/img.jpg',
145 'tests/ComponentInstaller/Test/Resources/img2.jpg',
146 ),
147 'tests/ComponentInstaller/Test/Resources/*.jpg',
148 );
149
150 $tests[] = array(
151 array(
152 'tests/ComponentInstaller/Test/Resources/img.jpg',
153 ),
154 'tests/ComponentInstaller/Test/Resources/img.jpg',
155 );
156
157 $tests[] = array(
158 array(
159 'tests/ComponentInstaller/Test/Resources/subdir/img.jpg',
160 'tests/ComponentInstaller/Test/Resources/subdir/img3.jpg',
161 'tests/ComponentInstaller/Test/Resources/subdir/subdir2/img4.jpg',
162 'tests/ComponentInstaller/Test/Resources/subdir/subdir2',
163 ),
164 'tests/ComponentInstaller/Test/Resources/subdir/**',
165 );
166
167 return $tests;
168 }
169}
$result
An exception for terminatinating execution or to throw for unit testing.
testRecursiveGlob($expected, $pattern, $flags=0)
Tests the recursiveGlob function.
testRecursiveGlobFiles($expected, $pattern, $flags=0)
Tests the recursiveGlob function.
Provides basic file system operations.
Definition: Filesystem.php:20