Skip to content
This repository was archived by the owner on Aug 14, 2022. It is now read-only.

Commit e4030f6

Browse files
committed
Updated to 1.1.6 version
1 parent 2cf776c commit e4030f6

File tree

1 file changed

+50
-18
lines changed

1 file changed

+50
-18
lines changed

tests/FileTest.php

+50-18
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,38 @@
1919
*/
2020
class FileTest extends TestCase
2121
{
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+
2254
/**
2355
* Test if a local file exists.
2456
*
@@ -27,7 +59,7 @@ class FileTest extends TestCase
2759
public function testIfLocalFileExists()
2860
{
2961
$this->assertTrue(
30-
File::exists(__FILE__)
62+
$this->File->exists(__FILE__)
3163
);
3264
}
3365

@@ -39,7 +71,7 @@ public function testIfLocalFileExists()
3971
public function testIfLocalFileDoesNotExists()
4072
{
4173
$this->assertFalse(
42-
File::exists(__DIR__ . '/test.txt')
74+
$this->File->exists(__DIR__ . '/test.txt')
4375
);
4476
}
4577

@@ -51,7 +83,7 @@ public function testIfLocalFileDoesNotExists()
5183
public function testIfExternalFileExists()
5284
{
5385
$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')
5587
);
5688
}
5789

@@ -63,7 +95,7 @@ public function testIfExternalFileExists()
6395
public function testIfExternalFileDoesNotExists()
6496
{
6597
$this->assertFalse(
66-
File::exists('https://raw.githubusercontent.com/unknown.json')
98+
$this->File->exists('https://raw.githubusercontent.com/unknown.json')
6799
);
68100
}
69101

@@ -77,7 +109,7 @@ public function testDeleteLocalFile()
77109
touch(__DIR__ . '/test.txt');
78110

79111
$this->assertTrue(
80-
File::delete(__DIR__ . '/test.txt')
112+
$this->File->delete(__DIR__ . '/test.txt')
81113
);
82114
}
83115

@@ -89,7 +121,7 @@ public function testDeleteLocalFile()
89121
public function testDeleteMissingLocalFile()
90122
{
91123
$this->assertFalse(
92-
File::delete(__DIR__ . '/test.txt')
124+
$this->File->delete(__DIR__ . '/test.txt')
93125
);
94126
}
95127

@@ -101,7 +133,7 @@ public function testDeleteMissingLocalFile()
101133
public function testCreateDir()
102134
{
103135
$this->assertTrue(
104-
File::createDir(__DIR__ . '/test/')
136+
$this->File->createDir(__DIR__ . '/test/')
105137
);
106138
}
107139

@@ -113,7 +145,7 @@ public function testCreateDir()
113145
public function testCreateDirError()
114146
{
115147
$this->assertFalse(
116-
File::createDir('')
148+
$this->File->createDir('')
117149
);
118150
}
119151

@@ -125,7 +157,7 @@ public function testCreateDirError()
125157
public function testDeleteEmptyDir()
126158
{
127159
$this->assertTrue(
128-
File::deleteEmptyDir(__DIR__ . '/test/')
160+
$this->File->deleteEmptyDir(__DIR__ . '/test/')
129161
);
130162
}
131163

@@ -137,7 +169,7 @@ public function testDeleteEmptyDir()
137169
public function testDeleteEmptyDirError()
138170
{
139171
$this->assertFalse(
140-
File::deleteEmptyDir(__DIR__ . '/test/')
172+
$this->File->deleteEmptyDir(__DIR__ . '/test/')
141173
);
142174
}
143175

@@ -148,12 +180,12 @@ public function testDeleteEmptyDirError()
148180
*/
149181
public function testCopyDirRecursively()
150182
{
151-
File::createDir(__DIR__ . '/test/test/test/');
183+
$this->File->createDir(__DIR__ . '/test/test/test/');
152184

153185
touch(__DIR__ . '/test/test/test/test.txt');
154186

155187
$this->assertTrue(
156-
File::copyDirRecursively(__DIR__ . '/test/', __DIR__ . '/copy/')
188+
$this->File->copyDirRecursively(__DIR__ . '/test/', __DIR__ . '/copy/')
157189
);
158190
}
159191

@@ -165,7 +197,7 @@ public function testCopyDirRecursively()
165197
public function testCopyMissingDirRecursively()
166198
{
167199
$this->assertFalse(
168-
File::deleteDirRecursively(__DIR__ . '/unknown/')
200+
$this->File->deleteDirRecursively(__DIR__ . '/unknown/')
169201
);
170202
}
171203

@@ -177,11 +209,11 @@ public function testCopyMissingDirRecursively()
177209
public function testDeleteDirRecursively()
178210
{
179211
$this->assertTrue(
180-
File::deleteDirRecursively(__DIR__ . '/test/')
212+
$this->File->deleteDirRecursively(__DIR__ . '/test/')
181213
);
182214

183215
$this->assertTrue(
184-
File::deleteDirRecursively(__DIR__ . '/copy/')
216+
$this->File->deleteDirRecursively(__DIR__ . '/copy/')
185217
);
186218
}
187219

@@ -193,7 +225,7 @@ public function testDeleteDirRecursively()
193225
public function testDeleteMissingDirRecursively()
194226
{
195227
$this->assertFalse(
196-
File::deleteDirRecursively(__DIR__ . '/test/')
228+
$this->File->deleteDirRecursively(__DIR__ . '/test/')
197229
);
198230
}
199231

@@ -206,7 +238,7 @@ public function testGetFilesFromDir()
206238
{
207239
$this->assertContains(
208240
'DirectoryIterator',
209-
get_class(File::getFilesFromDir(__DIR__))
241+
get_class($this->File->getFilesFromDir(__DIR__))
210242
);
211243
}
212244

@@ -218,7 +250,7 @@ public function testGetFilesFromDir()
218250
public function testGetFilesFromMissingDir()
219251
{
220252
$this->assertFalse(
221-
File::getFilesFromDir('')
253+
$this->File->getFilesFromDir('')
222254
);
223255
}
224256
}

0 commit comments

Comments
 (0)