Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a91e200

Browse filesBrowse files
committed
[Filesystem] Added unit tests for touch method.
1 parent 7e297db commit a91e200
Copy full SHA for a91e200

File tree

Expand file treeCollapse file tree

1 file changed

+55
-0
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+55
-0
lines changed

‎src/Symfony/Component/Filesystem/Tests/FilesystemTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Filesystem/Tests/FilesystemTest.php
+55Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,4 +193,59 @@ public function testMkdirCreatesDirectoriesEvenIfItFailsToCreateOneOfThem()
193193
unlink($basePath.'2');
194194
rmdir($basePath.'3');
195195
}
196+
197+
public function testTouchCreatesEmptyFile()
198+
{
199+
$basePath = sys_get_temp_dir().DIRECTORY_SEPARATOR.time();
200+
$file = $basePath.'1';
201+
202+
$filesystem = new Filesystem();
203+
$filesystem->touch($file);
204+
205+
$this->assertFileExists($basePath.'1');
206+
207+
unlink($basePath.'1');
208+
}
209+
210+
public function testTouchCreatesEmptyFilesFromArray()
211+
{
212+
$basePath = sys_get_temp_dir().DIRECTORY_SEPARATOR.time();
213+
$files = array(
214+
$basePath.'1', $basePath.'2', $basePath.'3'
215+
);
216+
mkdir($basePath);
217+
218+
$filesystem = new Filesystem();
219+
$filesystem->touch($files);
220+
221+
$this->assertFileExists($basePath.'1');
222+
$this->assertFileExists($basePath.'2');
223+
$this->assertFileExists($basePath.'3');
224+
225+
unlink($basePath.'1');
226+
unlink($basePath.'2');
227+
unlink($basePath.'3');
228+
rmdir($basePath);
229+
}
230+
231+
public function testTouchCreatesEmptyFilesFromTraversableObject()
232+
{
233+
$basePath = sys_get_temp_dir().DIRECTORY_SEPARATOR.time();
234+
$files = new \ArrayObject(array(
235+
$basePath.'1', $basePath.'2', $basePath.'3'
236+
));
237+
mkdir($basePath);
238+
239+
$filesystem = new Filesystem();
240+
$filesystem->touch($files);
241+
242+
$this->assertFileExists($basePath.'1');
243+
$this->assertFileExists($basePath.'2');
244+
$this->assertFileExists($basePath.'3');
245+
246+
unlink($basePath.'1');
247+
unlink($basePath.'2');
248+
unlink($basePath.'3');
249+
rmdir($basePath);
250+
}
196251
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.