You are here

public function TranscoderAbstractionFactoryZencoderTestCase::setUp in Video 7.2

Sets up a Drupal site for running functional and integration tests.

Generates a random database prefix and installs Drupal with the specified installation profile in DrupalWebTestCase::$profile into the prefixed database. Afterwards, installs any additional modules specified by the test.

After installation all caches are flushed and several configuration values are reset to the values of the parent site executing the test, since the default values may be incompatible with the environment in which tests are being executed.

Parameters

...: List of modules to enable for the duration of the test. This can be either a single array or a variable number of string arguments.

Overrides DrupalWebTestCase::setUp

See also

DrupalWebTestCase::prepareDatabasePrefix()

DrupalWebTestCase::changeDatabasePrefix()

DrupalWebTestCase::prepareEnvironment()

File

tests/TranscoderAbstractionFactoryZencoder.test, line 28
Tests for the TranscoderAbstractionFactoryZencoder class

Class

TranscoderAbstractionFactoryZencoderTestCase
Tests for TranscoderAbstractionFactoryZencoder

Code

public function setUp() {
  parent::setUp();
  module_enable(array(
    'video',
    'node',
  ), TRUE);
  if (!module_enable(array(
    'zencoderapi',
  ), TRUE)) {
    $this
      ->verbose('The Zencoder API module could not be enabled.');
  }
  field_info_cache_clear();
  $this
    ->resetAll();
  drupal_cron_run();

  // Test subject
  $this->transcoder = $transcoder = new TranscoderAbstractionFactoryZencoder();
  variable_set('video_convertor', 'TranscoderAbstractionFactoryZencoder');

  // Build test job
  db_insert('file_managed')
    ->fields(array(
    'fid' => 1,
    'filemime' => 'video/mp4',
    'uri' => 'public://videos/original/file.mp4',
    'filename' => 'file.mp4',
    'filesize' => 134,
    'status' => 1,
    'timestamp' => time(),
    'uid' => 1,
  ))
    ->execute();
  db_insert('file_managed')
    ->fields(array(
    'fid' => 2,
    'filemime' => 'video/mp4',
    'uri' => 'public://videos/converted/1/file.mp4',
    'filename' => 'file.mp4',
    'filesize' => 0,
    'status' => 1,
    'timestamp' => time(),
    'uid' => 1,
  ))
    ->execute();
  db_insert('file_managed')
    ->fields(array(
    'fid' => 3,
    'filemime' => 'video/flv',
    'uri' => 'public://videos/converted/1/file.flv',
    'filename' => 'file.flv',
    'filesize' => 0,
    'status' => 1,
    'timestamp' => time(),
    'uid' => 1,
  ))
    ->execute();
  video_jobs::create(1, '320x240', 1, 'node', 'videofield', LANGUAGE_NONE, 0);
  db_insert('video_output')
    ->fields(array(
    'vid' => 1,
    'original_fid' => 1,
    'output_fid' => 2,
    'job_id' => 1,
  ))
    ->execute();
  db_insert('video_output')
    ->fields(array(
    'vid' => 1,
    'original_fid' => 1,
    'output_fid' => 3,
    'job_id' => 2,
  ))
    ->execute();
  $dir = 'public://videos/converted/1';
  file_prepare_directory($dir, FILE_CREATE_DIRECTORY);

  // Build test entity type
  field_create_field(array(
    'field_name' => 'videofield',
    'type' => 'video',
  ));
  field_create_instance(array(
    'field_name' => 'videofield',
    'entity_type' => 'node',
    'bundle' => 'page',
  ));

  // Build test entity
  $this->user = $user = $this
    ->drupalCreateUser();
  $node = new stdClass();
  $node->uid = $user->uid;
  $node->type = 'page';
  $node->title = 'Test node';
  $node->videofield['und'][0] = array(
    'fid' => 1,
  );
  node_save($node);
  $this->node = node_load($node->nid);
}