function ToolkitGdTest::testMissingOperation

Same name and namespace in other branches
  1. 9 core/tests/Drupal/KernelTests/Core/Image/ToolkitGdTest.php \Drupal\KernelTests\Core\Image\ToolkitGdTest::testMissingOperation()
  2. 10 core/tests/Drupal/KernelTests/Core/Image/ToolkitGdTest.php \Drupal\KernelTests\Core\Image\ToolkitGdTest::testMissingOperation()
  3. 11.x 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.');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.