public function ToolkitOperationsTest::testOperationsOnImageWithNoDimensions in ImageMagick 8.3
Same name and namespace in other branches
- 8.2 tests/src/Kernel/ToolkitOperationsTest.php \Drupal\Tests\imagemagick\Kernel\ToolkitOperationsTest::testOperationsOnImageWithNoDimensions()
Test operations on image with no dimensions.
@dataProvider providerToolkitConfiguration
Parameters
string $toolkit_id: The id of the toolkit to set up.
string $toolkit_config: The config object of the toolkit to set up.
array $toolkit_settings: The settings of the toolkit to set up.
File
- tests/
src/ Kernel/ ToolkitOperationsTest.php, line 94
Class
- ToolkitOperationsTest
- Tests for ImageMagick toolkit operations.
Namespace
Drupal\Tests\imagemagick\KernelCode
public function testOperationsOnImageWithNoDimensions(string $toolkit_id, string $toolkit_config, array $toolkit_settings) : void {
$this
->setUpToolkit($toolkit_id, $toolkit_config, $toolkit_settings);
$image = $this->imageFactory
->get();
$image
->createNew(100, 200);
$this
->assertSame(100, $image
->getWidth());
$this
->assertsame(200, $image
->getHeight());
$image
->getToolkit()
->setWidth(NULL);
$image
->getToolkit()
->setHeight(NULL);
$this
->assertNull($image
->getWidth());
$this
->assertNull($image
->getHeight());
// Rotate does not necessarily require previous dimensions, so it should
// not fail.
$this
->assertTrue($image
->rotate(5));
$this
->assertNull($image
->getWidth());
$this
->assertNull($image
->getHeight());
$this
->assertFalse($image
->crop(10, 10, 20, 20));
$this
->assertNull($image
->getWidth());
$this
->assertNull($image
->getHeight());
$this
->assertFalse($image
->scaleAndCrop(10, 10));
$this
->assertNull($image
->getWidth());
$this
->assertNull($image
->getHeight());
$this
->assertFalse($image
->scale(5));
$this
->assertNull($image
->getWidth());
$this
->assertNull($image
->getHeight());
// Resize sets explicitly the new dimension, so it should not fail.
$this
->assertTrue($image
->resize(50, 100));
$this
->assertSame(50, $image
->getWidth());
$this
->assertsame(100, $image
->getHeight());
if (substr(PHP_OS, 0, 3) === 'WIN') {
$this
->assertSame("-size 100x200 xc:transparent -background \"transparent\" -rotate 5 +repage -resize 50x100!", $image
->getToolkit()
->arguments()
->toString(ImagemagickExecArguments::POST_SOURCE));
}
else {
$this
->assertSame("-size 100x200 xc:transparent -background 'transparent' -rotate 5 +repage -resize 50x100!", $image
->getToolkit()
->arguments()
->toString(ImagemagickExecArguments::POST_SOURCE));
}
}