You are here

function MediaInternetProviderTestCase::testMediaInternetCustomProviderWizardFields in D7 Media 7.4

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

Test the file upload wizard field step.

File

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

Class

MediaInternetProviderTestCase
Tests custom media provider APIs.

Code

function testMediaInternetCustomProviderWizardFields() {
  $filename = $this
    ->randomName();

  // Add a text field to the video file type.
  $field_name = drupal_strtolower($this
    ->randomName() . '_field_name');
  $field = array(
    'field_name' => $field_name,
    'type' => 'text',
  );
  field_create_field($field);
  $instance = array(
    'field_name' => $field_name,
    'entity_type' => 'file',
    'bundle' => 'video',
    'label' => $this
      ->randomName() . '_label',
  );
  field_create_instance($instance);

  // 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 4: Attached fields.
  $edit = array();
  $edit['filename'] = $filename;
  $edit[$field_name . '[' . LANGUAGE_NONE . '][0][value]'] = $this
    ->randomName();
  $this
    ->drupalPost(NULL, $edit, t('Save'));

  // 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',
    '%name' => $filename,
  )), t('Video file uploaded.'));
}