You are here

function OembedFileEntityTestCase::testOembedImageFileFormatters in oEmbed 7

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

Tests the oembed render element types.

File

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

Class

OembedFileEntityTestCase

Code

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

    // If a response is a photo or has a thumbnail, it should always render
    // an image here.
    $file = oembed_url_to_file($url, TRUE);
    if ($info['type'] == 'photo' || isset($info['thumbnail']) && $info['thumbnail']) {
      foreach (array_keys(image_styles()) as $style_name) {
        $displays = array(
          'oembed_image' => array(
            'status' => TRUE,
            'weight' => 1,
            'settings' => array(
              'image_style' => $style_name,
              'alt' => '',
              'title' => '',
            ),
          ),
        );
        $element = file_view_file($file, $displays);
        $this
          ->assertRenderedElement($element, '//img');
        $url = image_style_url($style_name, $element['#path']);
        $this
          ->drupalGet($url);
        $this
          ->assertResponse(200, t('Image was generated at the URL.'));
      }
    }
  }
}