View source
<?php
namespace Drupal\Tests\image_effects\Functional\Effect;
use Drupal\Tests\image_effects\Functional\ImageEffectsTestBase;
class BrightnessTest extends ImageEffectsTestBase {
public function providerToolkits() {
$toolkits = parent::providerToolkits();
unset($toolkits['ImageMagick-graphicsmagick']);
return $toolkits;
}
public function testBrightnessEffect($toolkit_id, $toolkit_config, array $toolkit_settings) {
$this
->changeToolkit($toolkit_id, $toolkit_config, $toolkit_settings);
$original_uri = $this
->getTestImageCopyUri('core/tests/fixtures/files/image-test.png');
$test_data = [
'0' => [
$this->red,
$this->green,
$this->transparent,
$this->blue,
],
'-100' => [
$this->black,
$this->black,
$this->transparent,
$this->black,
],
'100' => [
$this->white,
$this->white,
$this->transparent,
$this->white,
],
];
foreach ($test_data as $key => $colors) {
$effect = [
'id' => 'image_effects_brightness',
'data' => [
'level' => $key,
],
];
$uuid = $this
->addEffectToTestStyle($effect);
$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));
$uuid = $this
->removeEffectFromTestStyle($uuid);
}
}
}