You are here

function MediaInternetProviderTestCase::testMediaInternetCustomProviderWizardTypes in D7 Media 7.4

Same name and namespace in other branches
  1. 7.2 modules/media_internet/tests/media_internet.test \MediaInternetProviderTestCase::testMediaInternetCustomProviderWizardTypes()
  2. 7.3 modules/media_internet/tests/media_internet.test \MediaInternetProviderTestCase::testMediaInternetCustomProviderWizardTypes()

Test the file upload wizard type step.

File

modules/media_internet/tests/media_internet.test, line 223
Tests for media_internet.module.

Class

MediaInternetProviderTestCase
Tests custom media provider APIs.

Code

function testMediaInternetCustomProviderWizardTypes() {

  // Create multiple file types with the same mime types.
  $this
    ->createFileType(array(
    'type' => 'video1',
    'label' => 'Video 1',
    'mimetypes' => array(
      'video/mediainternettest',
    ),
  ));
  $this
    ->createFileType(array(
    'type' => 'video2',
    'label' => 'Video 2',
    'mimetypes' => array(
      'video/mediainternettest',
    ),
  ));

  // Step 1: Upload a basic video file.
  $edit = array();
  $edit['embed_code'] = 'http://www.example.com/video/123';
  $this
    ->drupalPost('file/add/web', $edit, t('Next'));

  // Step 2: File type selection.
  $edit = array();
  $edit['type'] = 'video2';
  $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 video file has been uploaded.
  $this
    ->assertRaw(t('!type %name was uploaded.', array(
    '!type' => 'Video 2',
    '%name' => $file->filename,
  )), t('Video 2 file uploaded.'));
}