public function ToolkitGdTest::testMissingOperation in Drupal 9
Same name and namespace in other branches
- 8 core/tests/Drupal/KernelTests/Core/Image/ToolkitGdTest.php \Drupal\KernelTests\Core\Image\ToolkitGdTest::testMissingOperation()
Tests calling a missing image operation plugin.
File
- core/
tests/ Drupal/ KernelTests/ Core/ Image/ ToolkitGdTest.php, line 548
Class
- ToolkitGdTest
- Tests that core image manipulations work properly: scale, resize, rotate, crop, scale and crop, and desaturate.
Namespace
Drupal\KernelTests\Core\ImageCode
public function testMissingOperation() {
// Test that the image factory is set to use the GD toolkit.
$this
->assertEquals('gd', $this->imageFactory
->getToolkitId(), 'The image factory is set to use the \'gd\' image toolkit.');
// An image file that will be tested.
$file = 'image-test.png';
// Load up a fresh image.
$image = $this->imageFactory
->get('core/tests/fixtures/files/' . $file);
if (!$image
->isValid()) {
$this
->fail(new FormattableMarkup('Could not load image %file.', [
'%file' => $file,
]));
}
// Try perform a missing toolkit operation.
$this
->assertFalse($image
->apply('missing_op', []), 'Calling a missing image toolkit operation plugin fails.');
}