You are here

function ImagecacheExternalTestCase::testCachingExternalImage in Imagecache External 8

Same name and namespace in other branches
  1. 7.2 imagecache_external.test \ImagecacheExternalTestCase::testCachingExternalImage()

Test caching an external image.

1 call to ImagecacheExternalTestCase::testCachingExternalImage()
ImagecacheExternalTestCase::testCachingExternalImageUsingWhitelist in ./imagecache_external.test
Test caching an external image using the whitelist.

File

./imagecache_external.test, line 115
Tests for Imagecache External.

Class

ImagecacheExternalTestCase
Tests the functions for working with public/private file schemes.

Code

function testCachingExternalImage() {

  // Create a text field that uses the new style for rendering the image.
  $field_name = strtolower($this
    ->randomName(10));
  $this
    ->createTextField($field_name, 'article');
  $instance = field_info_instance('node', $field_name, 'article');
  $instance['display']['default']['type'] = 'imagecache_external_image';
  $instance['display']['default']['settings']['imagecache_external_style'] = 'large';
  field_update_instance($instance);

  // Create a new node with an image attached.
  $nid = $this
    ->addNodeImage($this->external_image_uri, $field_name, 'article');
  $node = node_load($nid);

  // Test that image is displayed using newly created style.
  $this
    ->drupalGet('node/' . $nid);
  $img_tag = theme('imagecache_external', [
    'style_name' => 'large',
    'path' => $this->external_image_uri,
    'width' => 420,
    'height' => 480,
  ]);
  $this
    ->assertRaw($img_tag, t('Image was successfully cached as %path.', [
    '%path' => $img_tag,
  ]));
}