You are here

function ImagecacheProportionsDisplaytestCase::testDisplayStyles in Imagecache Proportions 7

Tests imagecache proportions formatters on node display.

File

./imagecache_proportions.test, line 54
Tests for imagecache_proportions

Class

ImagecacheProportionsDisplaytestCase

Code

function testDisplayStyles() {
  module_load_include('test', 'image');
  $scheme = 'public';
  $field_name = strtolower($this
    ->randomName());
  $this
    ->createImageField($field_name, 'article', array(
    'uri_scheme' => $scheme,
  ));
  $image = current($this
    ->drupalGetTestFiles('image'));
  $nid = $this
    ->uploadNodeImage($image, $field_name, 'article');
  $node = node_load($nid, NULL, TRUE);
  $image_uri = $node->{$field_name}[LANGUAGE_NONE][0]['uri'];
  $image_info = array(
    'path' => $image_uri,
    'width' => 40,
    'height' => 20,
  );
  $instance = field_info_instance('node', $field_name, 'article');

  // Test link to image.
  $instance['display']['default']['type'] = 'image';
  $instance['display']['default']['settings']['image_link'] = 'file';
  field_update_instance($instance);
  $default_output = l(theme('image', $image_info), file_create_url($image_uri), array(
    'html' => TRUE,
  ));
  $this
    ->drupalGet('node/' . $nid);
  $this
    ->assertRaw($default_output, t('Image linked to file formatter displaying correctly on full node view.'));

  // Test link to node.
  $instance['display']['default']['settings']['image_link'] = 'content';
  field_update_instance($instance);
  $default_output = l(theme('image', $image_info), 'node/' . $nid, array(
    'html' => TRUE,
    'attributes' => array(
      'class' => 'active',
    ),
  ));
  $this
    ->drupalGet('node/' . $nid);
  $this
    ->assertRaw($default_output, t('Image linked to content formatter displaying correctly on full node view.'));

  // Test link to none.
  $instance['display']['default']['settings']['image_link'] = '';
  field_update_instance($instance);
  $default_output = theme('image', $image_info);
  $this
    ->drupalGet('node/' . $nid);
  $this
    ->assertRaw($default_output, t('Image style thumbnail formatter displaying correctly on full node view.'));
}