You are here

function SaveUploadTest::testExistingError in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/modules/file/src/Tests/SaveUploadTest.php \Drupal\file\Tests\SaveUploadTest::testExistingError()

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

File

core/modules/file/src/Tests/SaveUploadTest.php, line 317
Contains \Drupal\file\Tests\SaveUploadTest.

Class

SaveUploadTest
Tests the file_save_upload() function.

Namespace

Drupal\file\Tests

Code

function testExistingError() {
  $edit = array(
    'file_test_replace' => FILE_EXISTS_ERROR,
    'files[file_test_upload]' => drupal_realpath($this->image
      ->getFileUri()),
  );
  $this
    ->drupalPostForm('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());
}