You are here

public function ToolkitGdTest::testMissingOperation in Drupal 8

Same name and namespace in other branches
  1. 9 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 525

Class

ToolkitGdTest
Tests that core image manipulations work properly: scale, resize, rotate, crop, scale and crop, and desaturate.

Namespace

Drupal\KernelTests\Core\Image

Code

public function testMissingOperation() {

  // Test that the image factory is set to use the GD toolkit.
  $this
    ->assertEqual($this->imageFactory
    ->getToolkitId(), 'gd', '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.');
}