function ImageToolkitGdTestCase::testTransparentColorOutOfRange

Tests loading an image whose transparent color index is out of range.

File

drupal/modules/simpletest/tests/image.test, line 514
Tests for core image handling API.

Class

ImageToolkitGdTestCase
Test the core GD image manipulation functions.

Code

function testTransparentColorOutOfRange() {

  // This image was generated by taking an initial image with a palette size
  // of 6 colors, and setting the transparent color index to 6 (one higher
  // than the largest allowed index), as follows:
  // @code
  // $image = imagecreatefromgif('modules/simpletest/files/image-test.gif');
  // imagecolortransparent($image, 6);
  // imagegif($image, 'modules/simpletest/files/image-test-transparent-out-of-range.gif');
  // @endcode
  // This allows us to test that an image with an out-of-range color index
  // can be loaded correctly.
  $file = 'image-test-transparent-out-of-range.gif';
  $image = image_load(drupal_get_path('module', 'simpletest') . '/files/' . $file);
  if (!$image) {
    $this
      ->fail(format_string('Could not load image %file.', array(
      '%file' => $file,
    )));
  }
  else {

    // All images should be converted to truecolor when loaded.
    $image_truecolor = imageistruecolor($image->resource);
    $this
      ->assertTrue($image_truecolor, format_string('Image %file after load is a truecolor image.', array(
      '%file' => $file,
    )));
  }
}