function ToolkitGdTest::testTransparentColorOutOfRange in Zircon Profile 8.0
Same name and namespace in other branches
- 8 core/modules/system/src/Tests/Image/ToolkitGdTest.php \Drupal\system\Tests\Image\ToolkitGdTest::testTransparentColorOutOfRange()
Tests loading an image whose transparent color index is out of range.
File
- core/
modules/ system/ src/ Tests/ Image/ ToolkitGdTest.php, line 441 - Contains \Drupal\system\Tests\Image\ToolkitGdTest.
Class
- ToolkitGdTest
- Tests that core image manipulations work properly: scale, resize, rotate, crop, scale and crop, and desaturate.
Namespace
Drupal\system\Tests\ImageCode
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('core/modules/simpletest/files/image-test.gif');
// imagecolortransparent($image, 6);
// imagegif($image, 'core/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 = $this->imageFactory
->get(drupal_get_path('module', 'simpletest') . '/files/' . $file);
$toolkit = $image
->getToolkit();
if (!$image
->isValid()) {
$this
->fail(SafeMarkup::format('Could not load image %file.', array(
'%file' => $file,
)));
}
else {
// All images should be converted to truecolor when loaded.
$image_truecolor = imageistruecolor($toolkit
->getResource());
$this
->assertTrue($image_truecolor, SafeMarkup::format('Image %file after load is a truecolor image.', array(
'%file' => $file,
)));
}
}