function ImageTest::getToolkitOperationMock

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/Image/ImageTest.php \Drupal\Tests\Core\Image\ImageTest::getToolkitOperationMock()
  2. 8.9.x core/tests/Drupal/Tests/Core/Image/ImageTest.php \Drupal\Tests\Core\Image\ImageTest::getToolkitOperationMock()
  3. 10 core/tests/Drupal/Tests/Core/Image/ImageTest.php \Drupal\Tests\Core\Image\ImageTest::getToolkitOperationMock()

Mocks a toolkit operation.

Parameters

string $class_name: The name of the GD toolkit operation class to be mocked.

\Drupal\Core\ImageToolkit\ImageToolkitInterface $toolkit: The image toolkit object.

Return value

\PHPUnit\Framework\MockObject\MockObject

1 call to ImageTest::getToolkitOperationMock()
ImageTest::getTestImageForOperation in core/tests/Drupal/Tests/Core/Image/ImageTest.php
Get an image with mocked toolkit and operation, for operation testing.

File

core/tests/Drupal/Tests/Core/Image/ImageTest.php, line 85

Class

ImageTest
Tests the image class.

Namespace

Drupal\Tests\Core\Image

Code

protected function getToolkitOperationMock($class_name, ImageToolkitInterface $toolkit) {
    $mock_builder = $this->getMockBuilder('Drupal\\system\\Plugin\\ImageToolkit\\Operation\\gd\\' . $class_name);
    $logger = $this->createMock('Psr\\Log\\LoggerInterface');
    return $mock_builder->onlyMethods([
        'execute',
    ])
        ->setConstructorArgs([
        [],
        '',
        [],
        $toolkit,
        $logger,
    ])
        ->getMock();
}

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