function FileEntityUploadWizardTestCase::testFileEntityUploadWizardTypes in File Entity (fieldable files) 7.2
Same name and namespace in other branches
- 7.3 file_entity.test \FileEntityUploadWizardTestCase::testFileEntityUploadWizardTypes()
Test the file upload wizard type step.
File
- ./
file_entity.test, line 463 - Test integration for the file_entity module.
Class
- FileEntityUploadWizardTestCase
- Tests creating new file entities through the file upload wizard.
Code
function testFileEntityUploadWizardTypes() {
$test_file = $this
->getTestFile('text');
// Create multiple file types with the same mime types.
$this
->createFileType(array(
'type' => 'document1',
'label' => 'Document 1',
'mimetypes' => array(
'text/plain',
),
));
$this
->createFileType(array(
'type' => 'document2',
'label' => 'Document 2',
'mimetypes' => array(
'text/plain',
),
));
// Step 1: Upload a basic document file.
$edit = array();
$edit['files[upload]'] = drupal_realpath($test_file->uri);
$this
->drupalPost('file/add', $edit, t('Next'));
// Step 2: File type selection.
$edit = array();
$edit['type'] = 'document2';
$this
->drupalPost(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 2',
'%name' => $file->filename,
)), t('Document 2 file uploaded.'));
}