| 7 file.test | FileUnmanagedMoveTest::testOverwriteSelf() |
| 8 file.test | FileUnmanagedMoveTest::testOverwriteSelf() |
Try to move a file onto itself.
File
- modules/
simpletest/ tests/ file.test, line 1394 - This provides SimpleTests for the core file handling functionality. These include FileValidateTest and FileSaveTest.
Code
function testOverwriteSelf() {
// Create a file for testing.
$file = $this->createFile();
// Move the file onto itself without renaming shouldn't make changes.
$new_filepath = file_unmanaged_move($file->uri, $file->uri, FILE_EXISTS_REPLACE);
$this->assertFalse($new_filepath, t('Moving onto itself without renaming fails.'));
$this->assertTrue(file_exists($file->uri), t('File exists after moving onto itself.'));
// Move the file onto itself with renaming will result in a new filename.
$new_filepath = file_unmanaged_move($file->uri, $file->uri, FILE_EXISTS_RENAME);
$this->assertTrue($new_filepath, t('Moving onto itself with renaming works.'));
$this->assertFalse(file_exists($file->uri), t('Original file has been removed.'));
$this->assertTrue(file_exists($new_filepath), t('File exists after moving onto itself.'));
}
Login or register to post comments