19
19
*/
20
20
class FileTest extends TestCase
21
21
{
22
+ /**
23
+ * File instance.
24
+ *
25
+ * @since 1.1.5
26
+ *
27
+ * @var object
28
+ */
29
+ protected $ File ;
30
+
31
+ /**
32
+ * Set up.
33
+ *
34
+ * @since 1.1.5
35
+ */
36
+ public function setUp ()
37
+ {
38
+ parent ::setUp ();
39
+
40
+ $ this ->File = new File ;
41
+ }
42
+
43
+ /**
44
+ * Check if it is an instance of File.
45
+ *
46
+ * @since 1.1.5
47
+ */
48
+ public function testIsInstanceOfFile ()
49
+ {
50
+ $ actual = $ this ->File ;
51
+ $ this ->assertInstanceOf ('Josantonius\File\File ' , $ actual );
52
+ }
53
+
22
54
/**
23
55
* Test if a local file exists.
24
56
*
@@ -27,7 +59,7 @@ class FileTest extends TestCase
27
59
public function testIfLocalFileExists ()
28
60
{
29
61
$ this ->assertTrue (
30
- File:: exists (__FILE__ )
62
+ $ this -> File -> exists (__FILE__ )
31
63
);
32
64
}
33
65
@@ -39,7 +71,7 @@ public function testIfLocalFileExists()
39
71
public function testIfLocalFileDoesNotExists ()
40
72
{
41
73
$ this ->assertFalse (
42
- File:: exists (__DIR__ . '/test.txt ' )
74
+ $ this -> File -> exists (__DIR__ . '/test.txt ' )
43
75
);
44
76
}
45
77
@@ -51,7 +83,7 @@ public function testIfLocalFileDoesNotExists()
51
83
public function testIfExternalFileExists ()
52
84
{
53
85
$ this ->assertTrue (
54
- File:: exists ('https://raw.githubusercontent.com/Josantonius/PHP-File/master/composer.json ' )
86
+ $ this -> File -> exists ('https://raw.githubusercontent.com/Josantonius/PHP-File/master/composer.json ' )
55
87
);
56
88
}
57
89
@@ -63,7 +95,7 @@ public function testIfExternalFileExists()
63
95
public function testIfExternalFileDoesNotExists ()
64
96
{
65
97
$ this ->assertFalse (
66
- File:: exists ('https://raw.githubusercontent.com/unknown.json ' )
98
+ $ this -> File -> exists ('https://raw.githubusercontent.com/unknown.json ' )
67
99
);
68
100
}
69
101
@@ -77,7 +109,7 @@ public function testDeleteLocalFile()
77
109
touch (__DIR__ . '/test.txt ' );
78
110
79
111
$ this ->assertTrue (
80
- File:: delete (__DIR__ . '/test.txt ' )
112
+ $ this -> File -> delete (__DIR__ . '/test.txt ' )
81
113
);
82
114
}
83
115
@@ -89,7 +121,7 @@ public function testDeleteLocalFile()
89
121
public function testDeleteMissingLocalFile ()
90
122
{
91
123
$ this ->assertFalse (
92
- File:: delete (__DIR__ . '/test.txt ' )
124
+ $ this -> File -> delete (__DIR__ . '/test.txt ' )
93
125
);
94
126
}
95
127
@@ -101,7 +133,7 @@ public function testDeleteMissingLocalFile()
101
133
public function testCreateDir ()
102
134
{
103
135
$ this ->assertTrue (
104
- File:: createDir (__DIR__ . '/test/ ' )
136
+ $ this -> File -> createDir (__DIR__ . '/test/ ' )
105
137
);
106
138
}
107
139
@@ -113,7 +145,7 @@ public function testCreateDir()
113
145
public function testCreateDirError ()
114
146
{
115
147
$ this ->assertFalse (
116
- File:: createDir ('' )
148
+ $ this -> File -> createDir ('' )
117
149
);
118
150
}
119
151
@@ -125,7 +157,7 @@ public function testCreateDirError()
125
157
public function testDeleteEmptyDir ()
126
158
{
127
159
$ this ->assertTrue (
128
- File:: deleteEmptyDir (__DIR__ . '/test/ ' )
160
+ $ this -> File -> deleteEmptyDir (__DIR__ . '/test/ ' )
129
161
);
130
162
}
131
163
@@ -137,7 +169,7 @@ public function testDeleteEmptyDir()
137
169
public function testDeleteEmptyDirError ()
138
170
{
139
171
$ this ->assertFalse (
140
- File:: deleteEmptyDir (__DIR__ . '/test/ ' )
172
+ $ this -> File -> deleteEmptyDir (__DIR__ . '/test/ ' )
141
173
);
142
174
}
143
175
@@ -148,12 +180,12 @@ public function testDeleteEmptyDirError()
148
180
*/
149
181
public function testCopyDirRecursively ()
150
182
{
151
- File:: createDir (__DIR__ . '/test/test/test/ ' );
183
+ $ this -> File -> createDir (__DIR__ . '/test/test/test/ ' );
152
184
153
185
touch (__DIR__ . '/test/test/test/test.txt ' );
154
186
155
187
$ this ->assertTrue (
156
- File:: copyDirRecursively (__DIR__ . '/test/ ' , __DIR__ . '/copy/ ' )
188
+ $ this -> File -> copyDirRecursively (__DIR__ . '/test/ ' , __DIR__ . '/copy/ ' )
157
189
);
158
190
}
159
191
@@ -165,7 +197,7 @@ public function testCopyDirRecursively()
165
197
public function testCopyMissingDirRecursively ()
166
198
{
167
199
$ this ->assertFalse (
168
- File:: deleteDirRecursively (__DIR__ . '/unknown/ ' )
200
+ $ this -> File -> deleteDirRecursively (__DIR__ . '/unknown/ ' )
169
201
);
170
202
}
171
203
@@ -177,11 +209,11 @@ public function testCopyMissingDirRecursively()
177
209
public function testDeleteDirRecursively ()
178
210
{
179
211
$ this ->assertTrue (
180
- File:: deleteDirRecursively (__DIR__ . '/test/ ' )
212
+ $ this -> File -> deleteDirRecursively (__DIR__ . '/test/ ' )
181
213
);
182
214
183
215
$ this ->assertTrue (
184
- File:: deleteDirRecursively (__DIR__ . '/copy/ ' )
216
+ $ this -> File -> deleteDirRecursively (__DIR__ . '/copy/ ' )
185
217
);
186
218
}
187
219
@@ -193,7 +225,7 @@ public function testDeleteDirRecursively()
193
225
public function testDeleteMissingDirRecursively ()
194
226
{
195
227
$ this ->assertFalse (
196
- File:: deleteDirRecursively (__DIR__ . '/test/ ' )
228
+ $ this -> File -> deleteDirRecursively (__DIR__ . '/test/ ' )
197
229
);
198
230
}
199
231
@@ -206,7 +238,7 @@ public function testGetFilesFromDir()
206
238
{
207
239
$ this ->assertContains (
208
240
'DirectoryIterator ' ,
209
- get_class (File:: getFilesFromDir (__DIR__ ))
241
+ get_class ($ this -> File -> getFilesFromDir (__DIR__ ))
210
242
);
211
243
}
212
244
@@ -218,7 +250,7 @@ public function testGetFilesFromDir()
218
250
public function testGetFilesFromMissingDir ()
219
251
{
220
252
$ this ->assertFalse (
221
- File:: getFilesFromDir ('' )
253
+ $ this -> File -> getFilesFromDir ('' )
222
254
);
223
255
}
224
256
}
0 commit comments