You are here

function OembedFileEntityTestCase::testOembedFileFormatters in oEmbed 7

Same name and namespace in other branches
  1. 8 oembed.test \OembedFileEntityTestCase::testOembedFileFormatters()
  2. 7.0 oembed.test \OembedFileEntityTestCase::testOembedFileFormatters()

Tests the oembed render element types.

File

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

Class

OembedFileEntityTestCase

Code

function testOembedFileFormatters() {
  foreach ($this->urls as $url => $info) {

    // Every URL should render through the oEmbed formatter.
    $file = oembed_url_to_file($url, TRUE);
    $displays = array(
      'oembed' => array(
        'status' => TRUE,
        'weight' => 1,
        'settings' => array(),
      ),
    );
    $element = file_view_file($file, $displays);
    $this
      ->assertRenderedElement($element, '//*');

    // Only responses with thumbnails will render through the oembed_thumbnail
    // formatter. Rendered elements are always images.
    if (isset($info['thumbnail']) && $info['thumbnail']) {
      $displays = array(
        'oembed_thumbnail' => array(
          'status' => TRUE,
          'weight' => 1,
          'settings' => array(),
        ),
      );
      $element = file_view_file($file, $displays);
      $this
        ->assertRenderedElement($element, '//img');
    }

    // If a response is a photo or has a thumbnail, it should always render
    // an image here.
    if ($info['type'] == 'photo' || isset($info['thumbnail']) && $info['thumbnail']) {
      $displays = array(
        'oembed_thumbnail' => array(
          'status' => TRUE,
          'weight' => 1,
          'settings' => array(),
        ),
        'oembed' => array(
          'status' => TRUE,
          'weight' => 2,
          'settings' => array(),
        ),
      );
      $element = file_view_file($file, $displays);
      $this
        ->assertRenderedElement($element, '//img');
    }
  }
}