@@ -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