public function ToolkitOperationsTest::testCreateNewImageFailures in ImageMagick 8.3
Same name and namespace in other branches
- 8.2 tests/src/Kernel/ToolkitOperationsTest.php \Drupal\Tests\imagemagick\Kernel\ToolkitOperationsTest::testCreateNewImageFailures()
Test failures of CreateNew.
@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 69
Class
- ToolkitOperationsTest
- Tests for ImageMagick toolkit operations.
Namespace
Drupal\Tests\imagemagick\KernelCode
public function testCreateNewImageFailures(string $toolkit_id, string $toolkit_config, array $toolkit_settings) : void {
$this
->setUpToolkit($toolkit_id, $toolkit_config, $toolkit_settings);
$image = $this->imageFactory
->get();
$image
->createNew(-50, 20);
$this
->assertFalse($image
->isValid(), 'CreateNew with negative width fails.');
$image
->createNew(50, 20, 'foo');
$this
->assertFalse($image
->isValid(), 'CreateNew with invalid extension fails.');
$image
->createNew(50, 20, 'gif', '#foo');
$this
->assertFalse($image
->isValid(), 'CreateNew with invalid color hex string fails.');
$image
->createNew(50, 20, 'gif', '#ff0000');
$this
->assertTrue($image
->isValid(), 'CreateNew with valid arguments validates the Image.');
}