View source
<?php
namespace Drupal\Tests\image_effects\Functional\Effect;
use Drupal\Tests\image_effects\Functional\ImageEffectsTestBase;
class InvertTest extends ImageEffectsTestBase {
public function testInvertEffect($toolkit_id, $toolkit_config, array $toolkit_settings) {
$this
->changeToolkit($toolkit_id, $toolkit_config, $toolkit_settings);
$effect = [
'id' => 'image_effects_invert',
];
$this
->addEffectToTestStyle($effect);
$original_uri = $this
->getTestImageCopyUri('/files/image-test.png', 'simpletest');
$colors = [
$this->cyan,
$this->fuchsia,
$this->transparent,
$this->yellow,
];
$derivative_uri = $this->testImageStyle
->buildUri($original_uri);
$this->testImageStyle
->createDerivative($original_uri, $derivative_uri);
$image = $this->imageFactory
->get($derivative_uri, 'gd');
$this
->assertColorsAreEqual($colors[0], $this
->getPixelColor($image, 0, 0));
$this
->assertColorsAreEqual($colors[1], $this
->getPixelColor($image, 39, 0));
$this
->assertColorsAreEqual($colors[2], $this
->getPixelColor($image, 0, 19));
$this
->assertColorsAreEqual($colors[3], $this
->getPixelColor($image, 39, 19));
}
}