1 file.test FileSaveUploadTest::testExistingRename()

Test renaming when uploading over a file that already exists.

File

core/modules/simpletest/tests/file.test, line 940
This provides SimpleTests for the core file handling functionality. These include FileValidateTest and FileSaveTest.

Class

FileSaveUploadTest
Test the file_save_upload() function.

Code

function testExistingRename() {
  $edit = array(
    'file_test_replace' => FILE_EXISTS_RENAME,
    'files[file_test_upload]' => backdrop_realpath($this->image->uri)
  );
  $this->backdropPost('file-test/upload', $edit, t('Submit'));
  $this->assertResponse(200, 'Received a 200 response for posted test file.');
  $this->assertRaw(t('You WIN!'), 'Found the success message.');

  // Check that the correct hooks were called.
  $this->assertFileHooksCalled(array('validate', 'insert'));
}