You are here

class OembedProviderTestCase in oEmbed 8

Same name and namespace in other branches
  1. 7 modules/oembedprovider/oembedprovider.test \OembedProviderTestCase
  2. 7.0 oembedprovider/oembedprovider.test \OembedProviderTestCase

Hierarchy

Expanded class hierarchy of OembedProviderTestCase

File

modules/oembedprovider/oembedprovider.test, line 3

View source
class OembedProviderTestCase extends OembedTestHelper {
  function setUp() {
    parent::setUp(array(
      'file_entity',
      'oembedprovider',
    ));
  }
  public static function getInfo() {
    return array(
      'name' => 'oEmbed providers',
      'description' => 'Tests oEmbed providers.',
      'group' => 'oEmbed',
    );
  }
  function testOembedProviders() {
    ctools_include('plugins');
    $file = current($this
      ->drupalGetTestFiles('image'));
    $file->uid = 1;
    $file->status = FILE_STATUS_PERMANENT;
    file_save($file);
    $account = drupal_anonymous_user();
    $this
      ->assertFileEntityAccess(array(
      'view' => TRUE,
    ), $file, $account);
    $url = url('file/' . $file->fid, array(
      'absolute' => TRUE,
    ));
    $plugin = ctools_get_plugins('oembed', 'providers', 'file');
    $matches = array(
      1 => $file->fid,
    );
    $embed = oembed_oembed_fetch($plugin, $url, $matches);
    $errors = oembed_validate_response($embed);
    $this
      ->assertTrue(empty($errors), 'oEmbed response is valid');
    $output = theme('oembed__photo', array(
      'embed' => $embed,
    ));
    $vars = array(
      'path' => $file->uri,
      'alt' => oembed_alt_attr($embed),
      'width' => $file->image_dimensions['width'],
      'height' => $file->image_dimensions['height'],
    );
    $this
      ->assertEqual($output, theme('image', $vars), t('Expected img tag was found.'));
    $node = $this
      ->drupalCreateNode();
    $this
      ->assertTrue(node_load($node->nid), t('Node created.'));
    $url = url('node/' . $node->nid, array(
      'absolute' => TRUE,
    ));
    $plugin = ctools_get_plugins('oembed', 'providers', 'node');
    $matches = array(
      1 => $node->nid,
    );
    $embed = oembed_oembed_fetch($plugin, $url, $matches);
    $errors = oembed_validate_response($embed);
    $this
      ->assertTrue(empty($errors), 'oEmbed response is valid');
    $output = theme('oembed__rich', array(
      'embed' => $embed,
    ));
    $node = node_load($node->nid);
    $compare = node_view($node);
    $this
      ->assertEqual($output, render($compare), t('oEmbed node matches theme output.'));
  }

}

Members