You are here

class VideoFieldTestCase in Video 7.2

Tests for the the Video field type

@todo Test node revisions

Hierarchy

Expanded class hierarchy of VideoFieldTestCase

File

tests/VideoField.test, line 12
Tests for the the Video field type

View source
class VideoFieldTestCase extends DrupalWebTestCase {
  private $user;
  public static function getInfo() {
    return array(
      'name' => 'Video Field tests',
      'description' => 'Tests for the the Video field type',
      'group' => 'Video',
    );
  }
  function setUp() {
    parent::setUp(array(
      'video',
      'node',
      'locale',
    ));

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

    // Test items
    $this->user = $this
      ->drupalCreateUser();
  }

  /**
   * Tests basic behavior for saving a new video and adding it to a node.
   */
  public function testSaveVideoFieldItem() {

    // Build test data
    $file = $this
      ->createFile();
    $node = new stdClass();
    $node->uid = $this->user->uid;
    $node->type = 'page';
    $node->title = 'Test node';
    $node->videofield['und'][0] = array(
      'fid' => $file->fid,
      'dimensions' => '100x60',
    );
    node_save($node);
    $node = node_load($node->nid);

    // Check file status set to permanent
    $file = file_load($file->fid);
    $this
      ->assertEqual(FILE_STATUS_PERMANENT, $file->status, 'The file should be permanent');
    $this
      ->assertTrue(file_exists($file->uri), 'The file should exist');

    // Check queue result
    $queues = $this
      ->getQueues($file->fid);
    $this
      ->assertEqual(1, count($queues), 'One video_queue entry should be present');
    $queue = array_shift($queues);
    $this
      ->assertEqual($file->fid, $queue->fid, 'video_queue entry should have fid ' . $file->fid);
    $this
      ->assertEqual('node', $queue->entity_type, 'video_queue entry should entity_type node');
    $this
      ->assertEqual($node->nid, $queue->entity_id, 'video_queue entry should entity_id ' . $node->nid);
    $this
      ->assertEqual(VIDEO_RENDERING_PENDING, $queue->status, 'video_queue entry should have status ' . VIDEO_RENDERING_PENDING);
    $this
      ->assertEqual('100x60', $queue->dimensions, 'video_queue entry should have dimensions 100x60');
    $this
      ->assertNull($queue->duration, 'video_queue entry should have empty duration');
    $this
      ->assertEqual(0, $queue->started, 'video_queue entry should have started 0');
    $this
      ->assertEqual(0, $queue->completed, 'video_queue entry should have completed 0');
    $this
      ->assertEqual('videofield', $queue->data['field_name'], 'video_queue entry should have field_name videofield');
    $this
      ->assertEqual('und', $queue->data['langcode'], 'video_queue entry should have langcode und');
    $this
      ->assertEqual(0, $queue->data['delta'], 'video_queue entry should have delta 0');

    // No converted files and thumbnails at this point
    $this
      ->assertEqual(0, count($this
      ->getConvertedFiles($file->fid)), 'There should be no converted files immediately after saving');
    $this
      ->assertEqual(0, count($this
      ->getThumbnailFiles($file->fid)), 'There should be no thumbnail files immediately after saving');

    // Transcode the video
    $this
      ->transcodeVideo($node, $queue->vid, $file->fid);

    // Test the transcoded video
    $queues = $this
      ->getQueues($file->fid);
    $this
      ->assertEqual(1, count($queues), 'One video_queue entry should be present');
    $queue = array_shift($queues);
    $this
      ->assertEqual(VIDEO_RENDERING_COMPLETE, $queue->status, 'video_queue entry should have status ' . VIDEO_RENDERING_COMPLETE);

    // One converted video
    $conv = $this
      ->getConvertedFiles($file->fid);
    $this
      ->assertEqual(1, count($conv), 'There should be one converted files after transcoding');

    // Five thumbnails files
    $tn = $this
      ->getThumbnailFiles($file->fid);
    $this
      ->assertEqual(5, count($tn), 'There should be five thumbnail files after transcoding');

    // One usage entry for the video
    $u = $this
      ->getFileUsage($file->fid);
    $this
      ->assertEqual(1, count($u), 'There should be one usage entry immediately after saving');
    $this
      ->assertEqual($file->fid, $u[0]->fid, 'usage entry should have fid ' . $file->fid);
    $this
      ->assertEqual('file', $u[0]->module, 'usage entry should have module file');
    $this
      ->assertEqual('node', $u[0]->type, 'usage entry should have type node');
    $this
      ->assertEqual($node->nid, $u[0]->id, 'usage entry should have id ' . $node->nid);
    $this
      ->assertEqual(1, $u[0]->count, 'usage entry should have count 1');

    // Check usage for converted video and thumbnails
    foreach ($conv + $tn as $df) {
      $u = $this
        ->getFileUsage($df->fid);
      $this
        ->assertEqual(1, count($u), 'There should be one usage entry for derived file ' . $df->fid . ' immediately after saving');
      if (count($u) == 0) {
        continue;
      }
      $this
        ->assertEqual('node', $u[0]->type, 'usage entry for derived file ' . $df->fid . ' should have type node');
      $this
        ->assertEqual($node->nid, $u[0]->id, 'usage entry for derived file ' . $df->fid . ' should have id ' . $node->nid);
    }
  }

  /**
   * Tests basic behavior for deleting a video from a node
   */
  public function testDeleteVideoFieldItem() {

    // Build test data
    $file = $this
      ->createFile('file1.mp4');
    $node = new stdClass();
    $node->uid = $this->user->uid;
    $node->type = 'page';
    $node->title = 'Test node';
    $node->videofield['und'][0] = array(
      'fid' => $file->fid,
      'dimensions' => '100x60',
    );
    node_save($node);
    $node = node_load($node->nid);

    // Quick sanity checks
    $queues = $this
      ->getQueues($file->fid);
    $this
      ->assertEqual(1, count($queues), 'One video_queue entry should be present');
    $this
      ->assertEqual(1, count($this
      ->getFileUsage($file->fid)), 'There should be one usage entry immediately after saving');
    $this
      ->transcodeVideo($node, $queues[0]->vid, $file->fid);
    $tn = $this
      ->getThumbnailFiles($file->fid);
    $conv = $this
      ->getConvertedFiles($file->fid);

    // Delete the file
    unset($node->videofield['und'][0]);
    node_save($node);

    // Check if everything is deleted properly
    $this
      ->assertEqual(0, count($this
      ->getQueues($file->fid)), 'video_queue entry should be removed');
    $this
      ->assertEqual(0, count($this
      ->getFileUsage($file->fid)), 'There should be no usage entries after deleting');
    $this
      ->assertEqual(0, count($this
      ->getThumbnailFiles($file->fid)), 'There should be no thumbnail entries after deleting');
    $this
      ->assertEqual(0, count($this
      ->getConvertedFiles($file->fid)), 'There should be no converted entries after deleting');

    // Check usage for converted video and thumbnails
    foreach ($conv + $tn as $df) {
      $u = $this
        ->getFileUsage($df->fid);
      $this
        ->assertEqual(0, count($u), 'There should be no usage entries for derived file ' . $df->fid . ' immediately after saving');
    }
  }

  /**
   * Tests saving a new video and adding it to two different nodes
   */
  public function testSaveVideoFieldItemTwice() {

    // Build test data
    $file = $this
      ->createFile('file2.mp4');
    $node1 = new stdClass();
    $node1->uid = $this->user->uid;
    $node1->type = 'page';
    $node1->title = 'Test node';
    $node1->videofield['und'][0] = array(
      'fid' => $file->fid,
      'dimensions' => '100x60',
    );
    node_save($node1);
    $node2 = new stdClass();
    $node2->uid = $this->user->uid;
    $node2->type = 'page';
    $node2->title = 'Test node';
    $node2->videofield['und'][0] = array(
      'fid' => $file->fid,
      'dimensions' => '100x60',
    );
    node_save($node2);

    // Check queue result
    $queues = $this
      ->getQueues($file->fid);
    $this
      ->assertEqual(1, count($queues), 'One video_queue entry should be present');
    $queue = array_shift($queues);
    $node1 = node_load($node1->nid);
    $this
      ->transcodeVideo($node1, $queue->vid, $file->fid);
    $node2 = node_load($node2->nid);

    // @todo the video module should not reference the entity itself because one fid can be associated with multiple entities
    $this
      ->assertEqual($node1->nid, $queue->entity_id, 'video_queue entry should entity_id ' . $node1->nid);

    // Two usage entries for the video
    $u = $this
      ->getFileUsage($file->fid);
    $this
      ->assertEqual(2, count($u), 'There should be two usage entries immediately after saving');

    // First usage row
    $this
      ->assertEqual($file->fid, $u[0]->fid, 'usage entry should have fid ' . $file->fid);
    $this
      ->assertEqual('file', $u[0]->module, 'usage entry should have module file');
    $this
      ->assertEqual('node', $u[0]->type, 'usage entry should have type node');
    $this
      ->assertEqual($node1->nid, $u[0]->id, 'usage entry should have id ' . $node1->nid);
    $this
      ->assertEqual(1, $u[0]->count, 'usage entry should have count 1');

    // Second usage row
    $this
      ->assertEqual($file->fid, $u[1]->fid, 'usage entry should have fid ' . $file->fid);
    $this
      ->assertEqual('file', $u[1]->module, 'usage entry should have module file');
    $this
      ->assertEqual('node', $u[1]->type, 'usage entry should have type node');
    $this
      ->assertEqual($node2->nid, $u[1]->id, 'usage entry should have id ' . $node2->nid);
    $this
      ->assertEqual(1, $u[1]->count, 'usage entry should have count 1');
  }

  /**
   * Tests adding a video to two different nodes and deleting them one by one
   */
  public function testDeleteVideoFieldItemTwice() {

    // Build test data
    $file = $this
      ->createFile('file3.mp4');
    $node1 = new stdClass();
    $node1->uid = $this->user->uid;
    $node1->type = 'page';
    $node1->title = 'Test node';
    $node1->videofield['und'][0] = array(
      'fid' => $file->fid,
      'dimensions' => '100x60',
    );
    node_save($node1);
    $node2 = new stdClass();
    $node2->uid = $this->user->uid;
    $node2->type = 'page';
    $node2->title = 'Test node';
    $node2->videofield['und'][0] = array(
      'fid' => $file->fid,
      'dimensions' => '100x60',
    );
    node_save($node2);
    $node1 = node_load($node1->nid);
    $node2 = node_load($node2->nid);

    // Sanity checks
    $queues = $this
      ->getQueues($file->fid);
    $this
      ->assertEqual(1, count($queues), 'One video_queue entry should be present');
    $this
      ->assertEqual(2, count($this
      ->getFileUsage($file->fid)), 'There should be two usage entries immediately after saving');
    $queue = array_shift($queues);
    $this
      ->transcodeVideo($node1, $queue->vid, $file->fid);
    node_save($node2);

    // Check converted files and thumbnails
    $conv = $this
      ->getConvertedFiles($file->fid);
    $tn = $this
      ->getThumbnailFiles($file->fid);
    $this
      ->assertEqual(1, count($conv), 'There should be 1 converted file immediately after saving');
    $this
      ->assertEqual(5, count($tn), 'There should be 5 thumbnail files immediately after saving');

    // Check usage of derived files: 2 usages should be registered
    foreach ($conv + $tn as $df) {
      $u = $this
        ->getFileUsage($df->fid);
      $this
        ->assertEqual(2, count($u), 'There should be one usage entry for derived file ' . $df->fid . ' after saving both nodes');
      if (count($u) == 0) {
        continue;
      }
      $this
        ->assertEqual('node', $u[0]->type, 'usage entry for derived file ' . $df->fid . ' should have type node');
      $this
        ->assertEqual($node1->nid, $u[0]->id, 'usage entry for derived file ' . $df->fid . ' should have id ' . $node1->nid);
      $this
        ->assertEqual('node', $u[1]->type, 'usage entry for derived file ' . $df->fid . ' should have type node');
      $this
        ->assertEqual($node2->nid, $u[1]->id, 'usage entry for derived file ' . $df->fid . ' should have id ' . $node2->nid);
    }

    // Delete the video from node 1
    unset($node1->videofield['und'][0]);
    node_save($node1);

    // Check usage of derived files: 1 usages should be registered
    foreach ($conv + $tn as $df) {
      $u = $this
        ->getFileUsage($df->fid);
      $this
        ->assertEqual(1, count($u), 'There should be one usage entry for derived file ' . $df->fid . ' after deleting the video from one node');
      if (count($u) == 0) {
        continue;
      }
      $this
        ->assertEqual('node', $u[0]->type, 'usage entry for derived file ' . $df->fid . ' should have type node');
      $this
        ->assertEqual($node2->nid, $u[0]->id, 'usage entry for derived file ' . $df->fid . ' should have id ' . $node2->nid);
    }

    // Queue entry should still be there, one usage should remain
    $this
      ->assertEqual(1, count($this
      ->getQueues($file->fid)), 'One video_queue entry should be present after deleting the video from one node');
    $this
      ->assertEqual(1, count($this
      ->getFileUsage($file->fid)), 'There should be one usage entry remaining after deleting the video from one node');

    // Check whether the converted files and thumbnails still exist
    $this
      ->assertEqual(1, count($this
      ->getConvertedFiles($file->fid)), 'There should be 1 converted file immediately after deleting the video from one node');
    $this
      ->assertEqual(5, count($this
      ->getThumbnailFiles($file->fid)), 'There should be 5 thumbnail files immediately after deleting the video from one node');

    // Delete the video from node 2
    unset($node2->videofield['und'][0]);
    node_save($node2);

    // Check if everything is deleted properly
    $this
      ->assertEqual(0, count($this
      ->getQueues($file->fid)), 'video_queue entry should be removed');
    $this
      ->assertEqual(0, count($this
      ->getFileUsage($file->fid)), 'There should be no usage entries after deleting');
    $this
      ->assertEqual(0, count($this
      ->getThumbnailFiles($file->fid)), 'There should be no thumbnail entries after deleting');
    $this
      ->assertEqual(0, count($this
      ->getConvertedFiles($file->fid)), 'There should be no converted entries after deleting');

    // Check usage of derived files: 0 usages should be registered
    foreach ($conv + $tn as $df) {
      $u = $this
        ->getFileUsage($df->fid);
      $this
        ->assertEqual(0, count($u), 'There should be no usage entry for derived file ' . $df->fid . ' after saving both nodes');
    }
  }

  /**
   * Tests adding a video to two different nodes and deleting the nodes
   */
  public function testDeleteVideoFieldItemTwice_EntityDelete() {

    // Build test data
    $file = $this
      ->createFile('file4.mp4');
    $node1 = new stdClass();
    $node1->uid = $this->user->uid;
    $node1->type = 'page';
    $node1->title = 'Test node';
    $node1->videofield['und'][0] = array(
      'fid' => $file->fid,
      'dimensions' => '100x60',
    );
    node_save($node1);
    $node2 = new stdClass();
    $node2->uid = $this->user->uid;
    $node2->type = 'page';
    $node2->title = 'Test node';
    $node2->videofield['und'][0] = array(
      'fid' => $file->fid,
      'dimensions' => '100x60',
    );
    node_save($node2);
    $node1 = node_load($node1->nid);
    $node2 = node_load($node2->nid);

    // Sanity checks
    $queues = $this
      ->getQueues($file->fid);
    $this
      ->assertEqual(1, count($queues), 'One video_queue entry should be present');
    $this
      ->assertEqual(2, count($this
      ->getFileUsage($file->fid)), 'There should be two usage entries immediately after saving');
    $this
      ->assertTrue(file_exists($file->uri), 'The file should exist');
    $queue = array_shift($queues);
    $this
      ->transcodeVideo($node1, $queue->vid, $file->fid);
    node_save($node2);

    // Delete node 1
    node_delete($node1->nid);

    // Queue entry should still be there, one usage should remain
    $this
      ->assertEqual(1, count($this
      ->getQueues($file->fid)), 'One video_queue entry should be present after deleting one node');
    $this
      ->assertEqual(1, count($this
      ->getFileUsage($file->fid)), 'There should be one usage entry remaining after deleting one node');
    $this
      ->assertTrue(file_exists($file->uri), 'The file should exist after deleting one node');

    // Check whether the converted files and thumbnails still exist
    $this
      ->assertEqual(1, count($this
      ->getConvertedFiles($file->fid)), 'There should be 1 converted file immediately after video from one node');
    $this
      ->assertEqual(5, count($this
      ->getThumbnailFiles($file->fid)), 'There should be 5 thumbnail files immediately after video from one node');

    // Delete node 2
    node_delete($node2->nid);

    // Queue entry and usage entry should still be removed
    $this
      ->assertEqual(0, count($this
      ->getQueues($file->fid)), 'No video_queue entry should be present after deleting all nodes');
    $this
      ->assertEqual(0, count($this
      ->getFileUsage($file->fid)), 'There should be no usage entries remaining after deleting all nodes');
    $this
      ->assertFalse(file_exists($file->uri), 'The file should be removed after deleting the video from all nodes');
  }

  /**
   * Tests validation logic in video_field_validate().
   */
  public function testVideoFieldValidate() {

    // Build test data
    $file = $this
      ->createFile('test.txt', 'text/plain');
    $node = new stdClass();
    $node->uid = $this->user->uid;
    $node->type = 'page';
    $node->title = 'Test node';
    $node->videofield['und'][0] = array(
      'fid' => $file->fid,
      'dimensions' => '100x60',
    );
    node_save($node);
  }
  private function createFile($name = 'file.mp4', $mime = 'video/mp4') {
    $dir = 'public://videos/original/';
    file_prepare_directory($dir, FILE_CREATE_DIRECTORY);
    $uri = $dir . $name;
    $filesize = 123;
    file_put_contents($uri, str_repeat('0', $filesize));
    $fid = db_insert('file_managed')
      ->fields(array(
      'filemime' => $mime,
      'uri' => $uri,
      'filename' => $name,
      'filesize' => $filesize,
      'status' => 0,
      'timestamp' => time(),
      'uid' => $this->user->uid,
    ))
      ->execute();
    return file_load(intval($fid));
  }
  private function getQueues($fid) {
    $queues = array();
    $result = db_query('SELECT q.* FROM {video_queue} q WHERE q.fid = :fid', array(
      ':fid' => $fid,
    ))
      ->fetchAll();
    foreach ($result as $q) {
      $q->data = unserialize($q->data);
      $queues[] = $q;
    }
    return $queues;
  }
  private function getConvertedFiles($originalfid) {
    return db_query('SELECT o.*, f.* FROM {video_output} o INNER JOIN {file_managed} f ON (f.fid = o.output_fid) WHERE o.original_fid = :fid', array(
      ':fid' => $originalfid,
    ))
      ->fetchAllAssoc('fid');
  }
  private function getThumbnailFiles($videofid) {
    return db_query('SELECT t.*, f.* FROM {video_thumbnails} t INNER JOIN {file_managed} f ON (f.fid = t.thumbnailfid) WHERE t.videofid = :fid', array(
      ':fid' => $videofid,
    ))
      ->fetchAllAssoc('fid');
  }
  private function getFileUsage($fid) {
    return db_query('SELECT u.* FROM {file_usage} u WHERE u.fid = :fid', array(
      ':fid' => $fid,
    ))
      ->fetchAll();
  }

  /**
   * Makes changes in the database such that a video looks transcoded.
   *
   * @todo use a fake transcoder class to transcode the file
   */
  private function transcodeVideo(stdClass &$node, $vid, $fid) {
    db_update('video_queue')
      ->fields(array(
      'status' => VIDEO_RENDERING_COMPLETE,
      'started' => time(),
      'completed' => time(),
    ))
      ->execute();

    // Converted file
    $of = $this
      ->createFile('video_' . $fid . '_transcoded.mp4');
    $of->status = FILE_STATUS_PERMANENT;
    file_save($of);
    db_insert('video_output')
      ->fields(array(
      'vid' => $vid,
      'original_fid' => $fid,
      'output_fid' => $of->fid,
    ))
      ->execute();

    // Thumbnails
    for ($i = 0; $i < variable_get('video_thumbnail_count', 5); $i++) {
      $tnf = $this
        ->createFile('thumbnail-' . $fid . '_' . sprintf('%04d', $i) . '.jpg', 'image/jpeg');
      $tnf->status = FILE_STATUS_PERMANENT;
      file_save($tnf);
      db_insert('video_thumbnails')
        ->fields(array(
        'videofid' => $fid,
        'thumbnailfid' => $tnf->fid,
      ))
        ->execute();
    }

    // Save the node to trigger usage generation
    node_save($node);
    $node = node_load($node->nid);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DrupalTestCase::$assertions protected property Assertions thrown in that test case.
DrupalTestCase::$databasePrefix protected property The database prefix of this test run.
DrupalTestCase::$originalFileDirectory protected property The original file directory, before it was changed for testing purposes.
DrupalTestCase::$results public property Current results of this test case.
DrupalTestCase::$setup protected property Flag to indicate whether the test has been set up.
DrupalTestCase::$setupDatabasePrefix protected property
DrupalTestCase::$setupEnvironment protected property
DrupalTestCase::$skipClasses protected property This class is skipped when looking for the source of an assertion.
DrupalTestCase::$testId protected property The test run ID.
DrupalTestCase::$timeLimit protected property Time limit for the test.
DrupalTestCase::$useSetupInstallationCache public property Whether to cache the installation part of the setUp() method.
DrupalTestCase::$useSetupModulesCache public property Whether to cache the modules installation part of the setUp() method.
DrupalTestCase::$verboseDirectoryUrl protected property URL to the verbose output file directory.
DrupalTestCase::assert protected function Internal helper: stores the assert.
DrupalTestCase::assertEqual protected function Check to see if two values are equal.
DrupalTestCase::assertFalse protected function Check to see if a value is false (an empty string, 0, NULL, or FALSE).
DrupalTestCase::assertIdentical protected function Check to see if two values are identical.
DrupalTestCase::assertNotEqual protected function Check to see if two values are not equal.
DrupalTestCase::assertNotIdentical protected function Check to see if two values are not identical.
DrupalTestCase::assertNotNull protected function Check to see if a value is not NULL.
DrupalTestCase::assertNull protected function Check to see if a value is NULL.
DrupalTestCase::assertTrue protected function Check to see if a value is not false (not an empty string, 0, NULL, or FALSE).
DrupalTestCase::deleteAssert public static function Delete an assertion record by message ID.
DrupalTestCase::error protected function Fire an error assertion. 1
DrupalTestCase::errorHandler public function Handle errors during test runs. 1
DrupalTestCase::exceptionHandler protected function Handle exceptions.
DrupalTestCase::fail protected function Fire an assertion that is always negative.
DrupalTestCase::generatePermutations public static function Converts a list of possible parameters into a stack of permutations.
DrupalTestCase::getAssertionCall protected function Cycles through backtrace until the first non-assertion method is found.
DrupalTestCase::getDatabaseConnection public static function Returns the database connection to the site running Simpletest.
DrupalTestCase::insertAssert public static function Store an assertion from outside the testing context.
DrupalTestCase::pass protected function Fire an assertion that is always positive.
DrupalTestCase::randomName public static function Generates a random string containing letters and numbers.
DrupalTestCase::randomString public static function Generates a random string of ASCII characters of codes 32 to 126.
DrupalTestCase::run public function Run all tests in this class.
DrupalTestCase::verbose protected function Logs a verbose message in a text file.
DrupalWebTestCase::$additionalCurlOptions protected property Additional cURL options.
DrupalWebTestCase::$content protected property The content of the page currently loaded in the internal browser.
DrupalWebTestCase::$cookieFile protected property The current cookie file used by cURL.
DrupalWebTestCase::$cookies protected property The cookies of the page currently loaded in the internal browser.
DrupalWebTestCase::$curlHandle protected property The handle of the current cURL connection.
DrupalWebTestCase::$drupalSettings protected property The value of the Drupal.settings JavaScript variable for the page currently loaded in the internal browser.
DrupalWebTestCase::$elements protected property The parsed version of the page.
DrupalWebTestCase::$generatedTestFiles protected property Whether the files were copied to the test files directory.
DrupalWebTestCase::$headers protected property The headers of the page currently loaded in the internal browser.
DrupalWebTestCase::$httpauth_credentials protected property HTTP authentication credentials (<username>:<password>).
DrupalWebTestCase::$httpauth_method protected property HTTP authentication method
DrupalWebTestCase::$loggedInUser protected property The current user logged in using the internal browser.
DrupalWebTestCase::$originalShutdownCallbacks protected property The original shutdown handlers array, before it was cleaned for testing purposes.
DrupalWebTestCase::$originalUser protected property The original user, before it was changed to a clean uid = 1 for testing purposes.
DrupalWebTestCase::$plainTextContent protected property The content of the page currently loaded in the internal browser (plain text version).
DrupalWebTestCase::$profile protected property The profile to install as a basis for testing. 20
DrupalWebTestCase::$redirect_count protected property The number of redirects followed during the handling of a request.
DrupalWebTestCase::$session_id protected property The current session ID, if available.
DrupalWebTestCase::$session_name protected property The current session name, if available.
DrupalWebTestCase::$url protected property The URL currently loaded in the internal browser.
DrupalWebTestCase::assertField protected function Asserts that a field exists with the given name or ID.
DrupalWebTestCase::assertFieldById protected function Asserts that a field exists in the current page with the given ID and value.
DrupalWebTestCase::assertFieldByName protected function Asserts that a field exists in the current page with the given name and value.
DrupalWebTestCase::assertFieldByXPath protected function Asserts that a field exists in the current page by the given XPath.
DrupalWebTestCase::assertFieldChecked protected function Asserts that a checkbox field in the current page is checked.
DrupalWebTestCase::assertLink protected function Pass if a link with the specified label is found, and optional with the specified index.
DrupalWebTestCase::assertLinkByHref protected function Pass if a link containing a given href (part) is found.
DrupalWebTestCase::assertMail protected function Asserts that the most recently sent e-mail message has the given value.
DrupalWebTestCase::assertMailPattern protected function Asserts that the most recently sent e-mail message has the pattern in it.
DrupalWebTestCase::assertMailString protected function Asserts that the most recently sent e-mail message has the string in it.
DrupalWebTestCase::assertNoDuplicateIds protected function Asserts that each HTML ID is used for just a single element.
DrupalWebTestCase::assertNoField protected function Asserts that a field does not exist with the given name or ID.
DrupalWebTestCase::assertNoFieldById protected function Asserts that a field does not exist with the given ID and value.
DrupalWebTestCase::assertNoFieldByName protected function Asserts that a field does not exist with the given name and value.
DrupalWebTestCase::assertNoFieldByXPath protected function Asserts that a field doesn't exist or its value doesn't match, by XPath.
DrupalWebTestCase::assertNoFieldChecked protected function Asserts that a checkbox field in the current page is not checked.
DrupalWebTestCase::assertNoLink protected function Pass if a link with the specified label is not found.
DrupalWebTestCase::assertNoLinkByHref protected function Pass if a link containing a given href (part) is not found.
DrupalWebTestCase::assertNoOptionSelected protected function Asserts that a select option in the current page is not checked.
DrupalWebTestCase::assertNoPattern protected function Will trigger a pass if the perl regex pattern is not present in raw content.
DrupalWebTestCase::assertNoRaw protected function Pass if the raw text is NOT found on the loaded page, fail otherwise. Raw text refers to the raw HTML that the page generated.
DrupalWebTestCase::assertNoResponse protected function Asserts the page did not return the specified response code.
DrupalWebTestCase::assertNoText protected function Pass if the text is NOT found on the text version of the page. The text version is the equivalent of what a user would see when viewing through a web browser. In other words the HTML has been filtered out of the contents.
DrupalWebTestCase::assertNoTitle protected function Pass if the page title is not the given string.
DrupalWebTestCase::assertNoUniqueText protected function Pass if the text is found MORE THAN ONCE on the text version of the page.
DrupalWebTestCase::assertOptionSelected protected function Asserts that a select option in the current page is checked.
DrupalWebTestCase::assertPattern protected function Will trigger a pass if the Perl regex pattern is found in the raw content.
DrupalWebTestCase::assertRaw protected function Pass if the raw text IS found on the loaded page, fail otherwise. Raw text refers to the raw HTML that the page generated.
DrupalWebTestCase::assertResponse protected function Asserts the page responds with the specified response code.
DrupalWebTestCase::assertText protected function Pass if the text IS found on the text version of the page. The text version is the equivalent of what a user would see when viewing through a web browser. In other words the HTML has been filtered out of the contents.
DrupalWebTestCase::assertTextHelper protected function Helper for assertText and assertNoText.
DrupalWebTestCase::assertThemeOutput protected function Asserts themed output.
DrupalWebTestCase::assertTitle protected function Pass if the page title is the given string.
DrupalWebTestCase::assertUniqueText protected function Pass if the text is found ONLY ONCE on the text version of the page.
DrupalWebTestCase::assertUniqueTextHelper protected function Helper for assertUniqueText and assertNoUniqueText.
DrupalWebTestCase::assertUrl protected function Pass if the internal browser's URL matches the given path.
DrupalWebTestCase::buildXPathQuery protected function Builds an XPath query.
DrupalWebTestCase::changeDatabasePrefix protected function Changes the database connection to the prefixed one.
DrupalWebTestCase::checkForMetaRefresh protected function Check for meta refresh tag and if found call drupalGet() recursively. This function looks for the http-equiv attribute to be set to "Refresh" and is case-sensitive.
DrupalWebTestCase::checkPermissions protected function Check to make sure that the array of permissions are valid.
DrupalWebTestCase::clickLink protected function Follows a link by name.
DrupalWebTestCase::constructFieldXpath protected function Helper function: construct an XPath for the given set of attributes and value.
DrupalWebTestCase::copySetupCache protected function Copy the setup cache from/to another table and files directory.
DrupalWebTestCase::cronRun protected function Runs cron in the Drupal installed by Simpletest.
DrupalWebTestCase::curlClose protected function Close the cURL handler and unset the handler.
DrupalWebTestCase::curlExec protected function Initializes and executes a cURL request.
DrupalWebTestCase::curlHeaderCallback protected function Reads headers and registers errors received from the tested site.
DrupalWebTestCase::curlInitialize protected function Initializes the cURL connection.
DrupalWebTestCase::drupalCompareFiles protected function Compare two files based on size and file name.
DrupalWebTestCase::drupalCreateContentType protected function Creates a custom content type based on default settings.
DrupalWebTestCase::drupalCreateNode protected function Creates a node based on default settings.
DrupalWebTestCase::drupalCreateRole protected function Creates a role with specified permissions.
DrupalWebTestCase::drupalCreateUser protected function Create a user with a given set of permissions.
DrupalWebTestCase::drupalGet protected function Retrieves a Drupal path or an absolute path.
DrupalWebTestCase::drupalGetAJAX protected function Retrieve a Drupal path or an absolute path and JSON decode the result.
DrupalWebTestCase::drupalGetContent protected function Gets the current raw HTML of requested page.
DrupalWebTestCase::drupalGetHeader protected function Gets the value of an HTTP response header. If multiple requests were required to retrieve the page, only the headers from the last request will be checked by default. However, if TRUE is passed as the second argument, all requests will be processed…
DrupalWebTestCase::drupalGetHeaders protected function Gets the HTTP response headers of the requested page. Normally we are only interested in the headers returned by the last request. However, if a page is redirected or HTTP authentication is in use, multiple requests will be required to retrieve the…
DrupalWebTestCase::drupalGetMails protected function Gets an array containing all e-mails sent during this test case.
DrupalWebTestCase::drupalGetNodeByTitle function Get a node from the database based on its title.
DrupalWebTestCase::drupalGetSettings protected function Gets the value of the Drupal.settings JavaScript variable for the currently loaded page.
DrupalWebTestCase::drupalGetTestFiles protected function Get a list files that can be used in tests.
DrupalWebTestCase::drupalGetToken protected function Generate a token for the currently logged in user.
DrupalWebTestCase::drupalHead protected function Retrieves only the headers for a Drupal path or an absolute path.
DrupalWebTestCase::drupalLogin protected function Log in a user with the internal browser.
DrupalWebTestCase::drupalLogout protected function
DrupalWebTestCase::drupalPost protected function Execute a POST request on a Drupal page. It will be done as usual POST request with SimpleBrowser.
DrupalWebTestCase::drupalPostAJAX protected function Execute an Ajax submission.
DrupalWebTestCase::drupalSetContent protected function Sets the raw HTML content. This can be useful when a page has been fetched outside of the internal browser and assertions need to be made on the returned page.
DrupalWebTestCase::drupalSetSettings protected function Sets the value of the Drupal.settings JavaScript variable for the currently loaded page.
DrupalWebTestCase::getAbsoluteUrl protected function Takes a path and returns an absolute path.
DrupalWebTestCase::getAllOptions protected function Get all option elements, including nested options, in a select.
DrupalWebTestCase::getSelectedItem protected function Get the selected value from a select field.
DrupalWebTestCase::getSetupCacheKey protected function Returns the cache key used for the setup caching.
DrupalWebTestCase::getUrl protected function Get the current URL from the cURL handler.
DrupalWebTestCase::handleForm protected function Handle form input related to drupalPost(). Ensure that the specified fields exist and attempt to create POST data in the correct manner for the particular field type.
DrupalWebTestCase::loadSetupCache protected function Copies the cached tables and files for a cached installation setup.
DrupalWebTestCase::parse protected function Parse content returned from curlExec using DOM and SimpleXML.
DrupalWebTestCase::preloadRegistry protected function Preload the registry from the testing site.
DrupalWebTestCase::prepareDatabasePrefix protected function Generates a database prefix for running tests.
DrupalWebTestCase::prepareEnvironment protected function Prepares the current environment for running the test.
DrupalWebTestCase::recursiveDirectoryCopy protected function Recursively copy one directory to another.
DrupalWebTestCase::refreshVariables protected function Refresh the in-memory set of variables. Useful after a page request is made that changes a variable in a different thread. 1
DrupalWebTestCase::resetAll protected function Reset all data structures after having enabled new modules.
DrupalWebTestCase::storeSetupCache protected function Store the installation setup to a cache.
DrupalWebTestCase::tearDown protected function Delete created files and temporary files directory, delete the tables created by setUp(), and reset the database prefix. 6
DrupalWebTestCase::verboseEmail protected function Outputs to verbose the most recent $count emails sent.
DrupalWebTestCase::xpath protected function Perform an xpath search on the contents of the internal browser. The search is relative to the root element (HTML tag normally) of the page.
DrupalWebTestCase::__construct function Constructor for DrupalWebTestCase. Overrides DrupalTestCase::__construct 1
VideoFieldTestCase::$user private property
VideoFieldTestCase::createFile private function
VideoFieldTestCase::getConvertedFiles private function
VideoFieldTestCase::getFileUsage private function
VideoFieldTestCase::getInfo public static function
VideoFieldTestCase::getQueues private function
VideoFieldTestCase::getThumbnailFiles private function
VideoFieldTestCase::setUp function Sets up a Drupal site for running functional and integration tests. Overrides DrupalWebTestCase::setUp
VideoFieldTestCase::testDeleteVideoFieldItem public function Tests basic behavior for deleting a video from a node
VideoFieldTestCase::testDeleteVideoFieldItemTwice public function Tests adding a video to two different nodes and deleting them one by one
VideoFieldTestCase::testDeleteVideoFieldItemTwice_EntityDelete public function Tests adding a video to two different nodes and deleting the nodes
VideoFieldTestCase::testSaveVideoFieldItem public function Tests basic behavior for saving a new video and adding it to a node.
VideoFieldTestCase::testSaveVideoFieldItemTwice public function Tests saving a new video and adding it to two different nodes
VideoFieldTestCase::testVideoFieldValidate public function Tests validation logic in video_field_validate().
VideoFieldTestCase::transcodeVideo private function Makes changes in the database such that a video looks transcoded.