You are here

function MediaInternetProviderTestCase::testMediaInternetCustomProviderWizardBasic in D7 Media 7.4

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

Test the basic file upload wizard functionality.

File

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

Class

MediaInternetProviderTestCase
Tests custom media provider APIs.

Code

function testMediaInternetCustomProviderWizardBasic() {
  $this
    ->drupalGet('file/add/web');
  $this
    ->assertResponse(200);

  // Check that the provider is listed as supported.
  $this
    ->assertRaw(t('Supported internet media providers: !providers.', array(
    '!providers' => '<strong>' . 'Media Internet Test' . '</strong>',
  )), t('The example media provider is enabled.'));

  // Enable media_internet_test.module's
  // hook_media_browser_plugin_info_alter_alter() implementation and ensure it
  // is working as designed.
  variable_set('media_internet_test_media_internet_providers_alter', TRUE);
  $this
    ->drupalGet('file/add/web');
  $this
    ->assertRaw(t('Supported internet media providers: !providers.', array(
    '!providers' => '<strong>' . 'Altered provider title' . '</strong>',
  )), t('The example media provider was successfully altered.'));

  // 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'));

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