1.20.x file.test FileSaveUploadTest::testErrors()

Test for failure when uploading over a file that already exists.

File

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

Class

FileSaveUploadTest
Test the file_save_upload() function.

Code

function testErrors() {
  $edit = array(
    'file_test_replace' => FILE_EXISTS_ERROR,
    '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('Epic upload FAIL!'), 'Found the failure message.');

  // Check that the no hooks were called while failing.
  $this->assertFileHooksCalled(array());

  // Reset the hook counters.
  file_test_reset();

  // Test for failures when not uploading a file.
  $this->backdropPost('file-test/upload', array(), t('Submit'));
  $this->assertNoRaw(t('Epic upload FAIL!'), 'Failure message not found.');
}