You are here

class OembedTestHelper in oEmbed 8

Same name and namespace in other branches
  1. 7 oembed.test \OembedTestHelper
  2. 7.0 oembed.test \OembedTestHelper

@file Tests for oembed.module.

Hierarchy

Expanded class hierarchy of OembedTestHelper

File

./oembed.test, line 8
Tests for oembed.module.

View source
class OembedTestHelper extends DrupalWebTestCase {
  protected $profile = 'minimal';

  // One URL for each provider supported by the oEmbed module. The URLs predict the type
  // of oEmbed response and the viability of a thumbnail.
  protected $urls = array(
    'http://www.flickr.com/photos/boris/2351723120/' => array(
      'type' => 'photo',
      'thumbnail' => TRUE,
    ),
    'http://qik.com/video/7046119' => array(
      'type' => 'video',
      'thumbnail' => FALSE,
    ),
    'http://revision3.com/hak5/hospital' => array(
      'type' => 'video',
      'thumbnail' => FALSE,
    ),
    'http://www.scribd.com/doc/3828502/Drupal' => array(
      'type' => 'rich',
      'thumbnail' => TRUE,
    ),
    'http://www.slideshare.net/eaton/drupal-deployment-presentation' => array(
      'type' => 'rich',
      'thumbnail' => TRUE,
    ),
    'http://soozphotography.smugmug.com/Events/Drupal-7-Release-Party-at/i-mnVjkZg/1/L/DSC_0555-L.jpg' => array(
      'type' => 'photo',
      'thumbnail' => FALSE,
    ),
    'http://soundcloud.com/headstart-cms/drupal' => array(
      'type' => 'rich',
      'thumbnail' => TRUE,
    ),
    'https://twitter.com/drupal/status/266208177161400320' => array(
      'type' => 'rich',
      'thumbnail' => FALSE,
    ),
    'http://www.viddler.com/v/bdce8c7' => array(
      'type' => 'video',
      'thumbnail' => TRUE,
    ),
    'https://vimeo.com/18352872' => array(
      'type' => 'video',
      'thumbnail' => TRUE,
    ),
    'http://www.youtube.com/watch?v=XgYu7-DQjDQ' => array(
      'type' => 'video',
      'thumbnail' => TRUE,
    ),
  );
  function setUp() {
    $modules = func_get_args();
    if (isset($modules[0]) && is_array($modules[0])) {
      $modules = $modules[0];
    }
    $modules[] = 'oembed';
    parent::setUp($modules);
  }
  protected function assertRenderedElement(array $element, $xpath, array $xpath_args = array()) {
    $original_element = $element;
    $this
      ->drupalSetContent(drupal_render($element));
    $this
      ->verbose('<pre>' . check_plain(var_export($original_element, TRUE)) . '</pre>' . '<pre>' . check_plain(var_export($element, TRUE)) . '</pre>' . '<hr />' . $this
      ->drupalGetContent());

    // @see DrupalWebTestCase::xpath()
    $xpath = $this
      ->buildXPathQuery($xpath, $xpath_args);
    $element += array(
      '#value' => NULL,
    );
    $type = isset($element['#type']) ? $element['#type'] : 'markup';
    $this
      ->assertFieldByXPath($xpath, $element['#value'], t('#type @type was properly rendered.', array(
      '@type' => var_export($type, TRUE),
    )));
  }
  protected function xpathArgsFromAttributes(array $attributes = array()) {
    $args = array();
    foreach ($attributes as $key => $value) {
      $args[':' . $key] = $value;
    }
    return $args;
  }

  /**
   * Asserts file_entity_access correctly grants or denies access.
   */
  function assertFileEntityAccess($ops, $file, $account) {
    foreach ($ops as $op => $result) {
      $msg = t("file_entity_access returns @result with operation '@op'.", array(
        '@result' => $result ? 'true' : 'false',
        '@op' => $op,
      ));
      $this
        ->assertEqual($result, file_entity_access($op, $file, $account), $msg);
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
OembedTestHelper::$profile protected property
OembedTestHelper::$urls protected property
OembedTestHelper::assertFileEntityAccess function Asserts file_entity_access correctly grants or denies access.
OembedTestHelper::assertRenderedElement protected function
OembedTestHelper::setUp function 3
OembedTestHelper::xpathArgsFromAttributes protected function