1 file.test FileUploadWizardTestCase::testFileUploadWizardSchemes()

Test the file upload wizard scheme step.

File

core/modules/file/tests/file.test, line 2380
Tests for file.module.

Class

FileUploadWizardTestCase
Tests creating new file entities through the file upload wizard.

Code

function testFileUploadWizardSchemes() {
  $test_file = $this->getTestFile('text');

  // Enable the private file system.
  config_set('system.core', 'file_private_path', $this->private_files_directory);

  // Step 1: Upload a basic document file.
  $edit = array();
  $edit['files[upload]'] = backdrop_realpath($test_file->uri);
  $this->backdropPost('file/add', $edit, t('Next'));

  // Step 3: Scheme selection.
  $edit = array();
  $edit['scheme'] = 'private';
  $this->backdropPost(NULL, $edit, t('Next'));

  // Check that the file exists in the database.
  $fid = $this->getLastFileId();
  $file = file_load($fid);
  $this->assertTrue($file, t('File found in database.'));

  // Check that the document file has been uploaded.
  $this->assertRaw(t('@type %name was uploaded.', array('@type' => 'Document', '%name' => $file->filename)), t('Document file uploaded privately.'));
}