File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed
src/Symfony/Component/Filesystem/Tests Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -342,6 +342,32 @@ public function testChmodChangesModeOfTraversableFileObject()
342
342
$ this ->assertEquals (753 , $ this ->getFilePermisions ($ directory ));
343
343
}
344
344
345
+ public function testRename ()
346
+ {
347
+ $ file = $ this ->workspace .DIRECTORY_SEPARATOR .'file ' ;
348
+ $ newPath = $ this ->workspace .DIRECTORY_SEPARATOR .'new_file ' ;
349
+ touch ($ file );
350
+
351
+ $ this ->filesystem ->rename ($ file , $ newPath );
352
+
353
+ $ this ->assertFileNotExists ($ file );
354
+ $ this ->assertFileExists ($ newPath );
355
+ }
356
+
357
+ /**
358
+ * @expectedException \RuntimeException
359
+ */
360
+ public function testRenameThrowsExceptionIfTargetAlreadyExists ()
361
+ {
362
+ $ file = $ this ->workspace .DIRECTORY_SEPARATOR .'file ' ;
363
+ $ newPath = $ this ->workspace .DIRECTORY_SEPARATOR .'new_file ' ;
364
+
365
+ touch ($ file );
366
+ touch ($ newPath );
367
+
368
+ $ this ->filesystem ->rename ($ file , $ newPath );
369
+ }
370
+
345
371
/**
346
372
* Returns file permissions as three digits (i.e. 755)
347
373
*
You can’t perform that action at this time.
0 commit comments