ConvolutionSharpenTest.php in Image Effects 8
File
tests/src/Functional/Effect/ConvolutionSharpenTest.php
View source
<?php
namespace Drupal\Tests\image_effects\Functional\Effect;
use Drupal\Tests\image_effects\Functional\ImageEffectsTestBase;
class ConvolutionSharpenTest extends ImageEffectsTestBase {
public function providerToolkits() {
$toolkits = parent::providerToolkits();
unset($toolkits['ImageMagick-graphicsmagick']);
return $toolkits;
}
public function testConvolutionSharpenEffect($toolkit_id, $toolkit_config, array $toolkit_settings) {
$this
->changeToolkit($toolkit_id, $toolkit_config, $toolkit_settings);
$original_uri = $this
->getTestImageCopyUri('/files/image-test.png', 'simpletest');
$derivative_uri = 'public://test-images/image-test-derived.png';
$effect = [
'id' => 'image_effects_convolution_sharpen',
'data' => [
'level' => 10,
],
];
$uuid = $this
->addEffectToTestStyle($effect);
$image = $this->imageFactory
->get($original_uri);
$effect = $this->testImageStyle
->getEffect($uuid);
$effect
->applyEffect($image);
switch ($this->imageFactory
->getToolkitId()) {
case 'gd':
$image
->save($derivative_uri);
$derivative_image = $this->imageFactory
->get($derivative_uri);
$this
->assertTrue($derivative_image
->isValid());
break;
case 'imagemagick':
$argument = $image
->getToolkit()
->getArguments()[$image
->getToolkit()
->findArgument('-morphology')];
$this
->assertEqual("-morphology Convolve '3x3:-0.1,-0.1,-0.1 -0.1,1.8,-0.1 -0.1,-0.1,-0.1'", $argument);
break;
}
$this
->removeEffectFromTestStyle($uuid);
}
}