function ToolkitTestBase::assertToolkitOperationsCalled

Assert that all of the specified image toolkit operations were called exactly once once, other values result in failure.

Parameters

$expected: Array with string containing with the operation name, e.g. 'load', 'save', 'crop', etc.

15 calls to ToolkitTestBase::assertToolkitOperationsCalled()
ImageEffectsTest::testCropEffect in drupal/core/modules/image/lib/Drupal/image/Tests/ImageEffectsTest.php
Test the image_crop_effect() function.
ImageEffectsTest::testDesaturateEffect in drupal/core/modules/image/lib/Drupal/image/Tests/ImageEffectsTest.php
Test the image_desaturate_effect() function.
ImageEffectsTest::testResizeEffect in drupal/core/modules/image/lib/Drupal/image/Tests/ImageEffectsTest.php
Test the image_resize_effect() function.
ImageEffectsTest::testRotateEffect in drupal/core/modules/image/lib/Drupal/image/Tests/ImageEffectsTest.php
Test the image_rotate_effect() function.
ImageEffectsTest::testScaleAndCropEffect in drupal/core/modules/image/lib/Drupal/image/Tests/ImageEffectsTest.php
Test the image_scale_and_crop_effect() function.

... See full list

File

drupal/core/modules/system/lib/Drupal/system/Tests/Image/ToolkitTestBase.php, line 58
Definition of Drupal\system\Tests\Image\ToolkitTestBase.

Class

ToolkitTestBase
Base class for image manipulation testing.

Namespace

Drupal\system\Tests\Image

Code

function assertToolkitOperationsCalled(array $expected) {

  // Determine which operations were called.
  $actual = array_keys(array_filter(image_test_get_all_calls()));

  // Determine if there were any expected that were not called.
  $uncalled = array_diff($expected, $actual);
  if (count($uncalled)) {
    $this
      ->assertTrue(FALSE, format_string('Expected operations %expected to be called but %uncalled was not called.', array(
      '%expected' => implode(', ', $expected),
      '%uncalled' => implode(', ', $uncalled),
    )));
  }
  else {
    $this
      ->assertTrue(TRUE, format_string('All the expected operations were called: %expected', array(
      '%expected' => implode(', ', $expected),
    )));
  }

  // Determine if there were any unexpected calls.
  $unexpected = array_diff($actual, $expected);
  if (count($unexpected)) {
    $this
      ->assertTrue(FALSE, format_string('Unexpected operations were called: %unexpected.', array(
      '%unexpected' => implode(', ', $unexpected),
    )));
  }
  else {
    $this
      ->assertTrue(TRUE, 'No unexpected operations were called.');
  }
}