You are here

public function ToolkitTest::testApply in Drupal 8

Test the image_apply() function.

File

core/tests/Drupal/FunctionalTests/Image/ToolkitTest.php, line 51

Class

ToolkitTest
Tests image toolkit functions.

Namespace

Drupal\FunctionalTests\Image

Code

public function testApply() {
  $data = [
    'p1' => 1,
    'p2' => TRUE,
    'p3' => 'text',
  ];
  $this
    ->assertTrue($this->image
    ->apply('my_operation', $data), 'Function returned the expected value.');

  // Check that apply was called and with the correct parameters.
  $this
    ->assertToolkitOperationsCalled([
    'apply',
  ]);
  $calls = $this
    ->imageTestGetAllCalls();
  $this
    ->assertEqual($calls['apply'][0][0], 'my_operation', "'my_operation' was passed correctly as operation");
  $this
    ->assertEqual($calls['apply'][0][1]['p1'], 1, 'integer parameter p1 was passed correctly');
  $this
    ->assertEqual($calls['apply'][0][1]['p2'], TRUE, 'boolean parameter p2 was passed correctly');
  $this
    ->assertEqual($calls['apply'][0][1]['p3'], 'text', 'string parameter p3 was passed correctly');
}