|
2 | 2 | /** |
3 | 3 | * PHP library for file management. |
4 | 4 | * |
5 | | - * @author Josantonius - hello@josantonius.com |
6 | | - * @copyright Copyright (c) 2017 |
7 | | - * @license https://opensource.org/licenses/MIT - The MIT License (MIT) |
8 | | - * @link https://github.com/Josantonius/PHP-File |
9 | | - * @since 1.1.4 |
| 5 | + * @author Josantonius <hello@josantonius.com> |
| 6 | + * @copyright 2017 - 2018 (c) Josantonius - PHP-File |
| 7 | + * @license https://opensource.org/licenses/MIT - The MIT License (MIT) |
| 8 | + * @link https://github.com/Josantonius/PHP-File |
| 9 | + * @since 1.1.4 |
10 | 10 | */ |
11 | 11 | namespace Josantonius\File; |
12 | 12 |
|
13 | 13 | use PHPUnit\Framework\TestCase; |
14 | 14 |
|
15 | 15 | /** |
16 | 16 | * Tests class for File library. |
17 | | - * |
18 | | - * @since 1.1.4 |
19 | 17 | */ |
20 | 18 | class FileTest extends TestCase |
21 | 19 | { |
@@ -47,210 +45,209 @@ public function setUp() |
47 | 45 | */ |
48 | 46 | public function testIsInstanceOfFile() |
49 | 47 | { |
50 | | - $actual = $this->File; |
51 | | - $this->assertInstanceOf('Josantonius\File\File', $actual); |
| 48 | + $this->assertInstanceOf('Josantonius\File\File', $this->File); |
52 | 49 | } |
53 | 50 |
|
54 | 51 | /** |
55 | 52 | * Test if a local file exists. |
56 | | - * |
57 | | - * @since 1.1.4 |
58 | 53 | */ |
59 | 54 | public function testIfLocalFileExists() |
60 | 55 | { |
| 56 | + $file = $this->File; |
| 57 | + |
61 | 58 | $this->assertTrue( |
62 | | - $this->File->exists(__FILE__) |
| 59 | + $file::exists(__FILE__) |
63 | 60 | ); |
64 | 61 | } |
65 | 62 |
|
66 | 63 | /** |
67 | 64 | * Test if a local file doesn't exists. |
68 | | - * |
69 | | - * @since 1.1.4 |
70 | 65 | */ |
71 | 66 | public function testIfLocalFileDoesNotExists() |
72 | 67 | { |
| 68 | + $file = $this->File; |
| 69 | + |
73 | 70 | $this->assertFalse( |
74 | | - $this->File->exists(__DIR__ . '/test.txt') |
| 71 | + $file::exists(__DIR__ . '/test.txt') |
75 | 72 | ); |
76 | 73 | } |
77 | 74 |
|
78 | 75 | /** |
79 | 76 | * Test if a external file exists. |
80 | | - * |
81 | | - * @since 1.1.4 |
82 | 77 | */ |
83 | 78 | public function testIfExternalFileExists() |
84 | 79 | { |
| 80 | + $file = $this->File; |
| 81 | + |
85 | 82 | $this->assertTrue( |
86 | | - $this->File->exists('https://raw.githubusercontent.com/Josantonius/PHP-File/master/composer.json') |
| 83 | + $file::exists('https://raw.githubusercontent.com/Josantonius/PHP-File/master/composer.json') |
87 | 84 | ); |
88 | 85 | } |
89 | 86 |
|
90 | 87 | /** |
91 | 88 | * Test if a external file doesn't exists. |
92 | | - * |
93 | | - * @since 1.1.4 |
94 | 89 | */ |
95 | 90 | public function testIfExternalFileDoesNotExists() |
96 | 91 | { |
| 92 | + $file = $this->File; |
| 93 | + |
97 | 94 | $this->assertFalse( |
98 | | - $this->File->exists('https://raw.githubusercontent.com/unknown.json') |
| 95 | + $file::exists('https://raw.githubusercontent.com/unknown.json') |
99 | 96 | ); |
100 | 97 | } |
101 | 98 |
|
102 | 99 | /** |
103 | 100 | * Test delete a local file. |
104 | | - * |
105 | | - * @since 1.1.4 |
106 | 101 | */ |
107 | 102 | public function testDeleteLocalFile() |
108 | 103 | { |
| 104 | + $file = $this->File; |
| 105 | + |
109 | 106 | touch(__DIR__ . '/test.txt'); |
110 | 107 |
|
111 | 108 | $this->assertTrue( |
112 | | - $this->File->delete(__DIR__ . '/test.txt') |
| 109 | + $file::delete(__DIR__ . '/test.txt') |
113 | 110 | ); |
114 | 111 | } |
115 | 112 |
|
116 | 113 | /** |
117 | 114 | * Test delete missing local file. |
118 | | - * |
119 | | - * @since 1.1.4 |
120 | 115 | */ |
121 | 116 | public function testDeleteMissingLocalFile() |
122 | 117 | { |
| 118 | + $file = $this->File; |
| 119 | + |
123 | 120 | $this->assertFalse( |
124 | | - $this->File->delete(__DIR__ . '/test.txt') |
| 121 | + $file::delete(__DIR__ . '/test.txt') |
125 | 122 | ); |
126 | 123 | } |
127 | 124 |
|
128 | 125 | /** |
129 | 126 | * Test create directory. |
130 | | - * |
131 | | - * @since 1.1.4 |
132 | 127 | */ |
133 | 128 | public function testCreateDir() |
134 | 129 | { |
| 130 | + $file = $this->File; |
| 131 | + |
135 | 132 | $this->assertTrue( |
136 | | - $this->File->createDir(__DIR__ . '/test/') |
| 133 | + $file::createDir(__DIR__ . '/test/') |
137 | 134 | ); |
138 | 135 | } |
139 | 136 |
|
140 | 137 | /** |
141 | 138 | * Test error to create directory. |
142 | | - * |
143 | | - * @since 1.1.4 |
144 | 139 | */ |
145 | 140 | public function testCreateDirError() |
146 | 141 | { |
| 142 | + $file = $this->File; |
| 143 | + |
147 | 144 | $this->assertFalse( |
148 | | - $this->File->createDir('') |
| 145 | + $file::createDir('') |
149 | 146 | ); |
150 | 147 | } |
151 | 148 |
|
152 | 149 | /** |
153 | 150 | * Test delete empty directory. |
154 | | - * |
155 | | - * @since 1.1.4 |
156 | 151 | */ |
157 | 152 | public function testDeleteEmptyDir() |
158 | 153 | { |
| 154 | + $file = $this->File; |
| 155 | + |
159 | 156 | $this->assertTrue( |
160 | | - $this->File->deleteEmptyDir(__DIR__ . '/test/') |
| 157 | + $file::deleteEmptyDir(__DIR__ . '/test/') |
161 | 158 | ); |
162 | 159 | } |
163 | 160 |
|
164 | 161 | /** |
165 | 162 | * Test error to delete empty directory. |
166 | | - * |
167 | | - * @since 1.1.4 |
168 | 163 | */ |
169 | 164 | public function testDeleteEmptyDirError() |
170 | 165 | { |
| 166 | + $file = $this->File; |
| 167 | + |
171 | 168 | $this->assertFalse( |
172 | | - $this->File->deleteEmptyDir(__DIR__ . '/test/') |
| 169 | + $file::deleteEmptyDir(__DIR__ . '/test/') |
173 | 170 | ); |
174 | 171 | } |
175 | 172 |
|
176 | 173 | /** |
177 | 174 | * Test copy directory recursively. |
178 | | - * |
179 | | - * @since 1.1.4 |
180 | 175 | */ |
181 | 176 | public function testCopyDirRecursively() |
182 | 177 | { |
183 | | - $this->File->createDir(__DIR__ . '/test/test/test/'); |
| 178 | + $file = $this->File; |
| 179 | + |
| 180 | + $file::createDir(__DIR__ . '/test/test/test/'); |
184 | 181 |
|
185 | 182 | touch(__DIR__ . '/test/test/test/test.txt'); |
186 | 183 |
|
187 | 184 | $this->assertTrue( |
188 | | - $this->File->copyDirRecursively(__DIR__ . '/test/', __DIR__ . '/copy/') |
| 185 | + $file::copyDirRecursively(__DIR__ . '/test/', __DIR__ . '/copy/') |
189 | 186 | ); |
190 | 187 | } |
191 | 188 |
|
192 | 189 | /** |
193 | 190 | * Test copy missing directory recursively. |
194 | | - * |
195 | | - * @since 1.1.4 |
196 | 191 | */ |
197 | 192 | public function testCopyMissingDirRecursively() |
198 | 193 | { |
| 194 | + $file = $this->File; |
| 195 | + |
199 | 196 | $this->assertFalse( |
200 | | - $this->File->deleteDirRecursively(__DIR__ . '/unknown/') |
| 197 | + $file::deleteDirRecursively(__DIR__ . '/unknown/') |
201 | 198 | ); |
202 | 199 | } |
203 | 200 |
|
204 | 201 | /** |
205 | 202 | * Test delete directory recursively. |
206 | | - * |
207 | | - * @since 1.1.4 |
208 | 203 | */ |
209 | 204 | public function testDeleteDirRecursively() |
210 | 205 | { |
| 206 | + $file = $this->File; |
| 207 | + |
211 | 208 | $this->assertTrue( |
212 | | - $this->File->deleteDirRecursively(__DIR__ . '/test/') |
| 209 | + $file::deleteDirRecursively(__DIR__ . '/test/') |
213 | 210 | ); |
214 | 211 |
|
215 | 212 | $this->assertTrue( |
216 | | - $this->File->deleteDirRecursively(__DIR__ . '/copy/') |
| 213 | + $file::deleteDirRecursively(__DIR__ . '/copy/') |
217 | 214 | ); |
218 | 215 | } |
219 | 216 |
|
220 | 217 | /** |
221 | 218 | * Test delete missing directory recursively. |
222 | | - * |
223 | | - * @since 1.1.4 |
224 | 219 | */ |
225 | 220 | public function testDeleteMissingDirRecursively() |
226 | 221 | { |
| 222 | + $file = $this->File; |
| 223 | + |
227 | 224 | $this->assertFalse( |
228 | | - $this->File->deleteDirRecursively(__DIR__ . '/test/') |
| 225 | + $file::deleteDirRecursively(__DIR__ . '/test/') |
229 | 226 | ); |
230 | 227 | } |
231 | 228 |
|
232 | 229 | /** |
233 | 230 | * Test get files from directory. |
234 | | - * |
235 | | - * @since 1.1.4 |
236 | 231 | */ |
237 | 232 | public function testGetFilesFromDir() |
238 | 233 | { |
| 234 | + $file = $this->File; |
| 235 | + |
239 | 236 | $this->assertContains( |
240 | 237 | 'DirectoryIterator', |
241 | | - get_class($this->File->getFilesFromDir(__DIR__)) |
| 238 | + get_class($file::getFilesFromDir(__DIR__)) |
242 | 239 | ); |
243 | 240 | } |
244 | 241 |
|
245 | 242 | /** |
246 | 243 | * Test get files from missing directory. |
247 | | - * |
248 | | - * @since 1.1.4 |
249 | 244 | */ |
250 | 245 | public function testGetFilesFromMissingDir() |
251 | 246 | { |
| 247 | + $file = $this->File; |
| 248 | + |
252 | 249 | $this->assertFalse( |
253 | | - $this->File->getFilesFromDir('') |
| 250 | + $file::getFilesFromDir('') |
254 | 251 | ); |
255 | 252 | } |
256 | 253 | } |
0 commit comments