function ToolkitTest::testDerivative

Same name in other branches
  1. 8.9.x core/tests/Drupal/FunctionalTests/Image/ToolkitTest.php \Drupal\FunctionalTests\Image\ToolkitTest::testDerivative()
  2. 10 core/tests/Drupal/KernelTests/Core/Image/ToolkitTest.php \Drupal\KernelTests\Core\Image\ToolkitTest::testDerivative()
  3. 11.x core/tests/Drupal/KernelTests/Core/Image/ToolkitTest.php \Drupal\KernelTests\Core\Image\ToolkitTest::testDerivative()

Tests image toolkit operations inheritance by derivative toolkits.

File

core/tests/Drupal/KernelTests/Core/Image/ToolkitTest.php, line 113

Class

ToolkitTest
Tests the image toolkit.

Namespace

Drupal\KernelTests\Core\Image

Code

public function testDerivative() {
    $toolkit_manager = $this->container
        ->get('image.toolkit.manager');
    $operation_manager = $this->container
        ->get('image.toolkit.operation.manager');
    $toolkit = $toolkit_manager->createInstance('test:derived_toolkit');
    $this->assertInstanceOf(ImageToolkitInterface::class, $toolkit);
    // Load an overwritten and an inherited operation.
    $blur = $operation_manager->getToolkitOperation($toolkit, 'blur');
    $invert = $operation_manager->getToolkitOperation($toolkit, 'invert');
    // 'Blur' operation overwritten by derivative.
    $this->assertEquals('foo_derived', $blur->getPluginId());
    // "Invert" operation inherited from base plugin.
    $this->assertEquals('bar', $invert->getPluginId());
}

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