You are here

function ImageToolkitTestCase::assertToolkitOperationsCalled in Drupal 7

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 ImageToolkitTestCase::assertToolkitOperationsCalled()
ImageEffectsUnitTest::testCropEffect in modules/image/image.test
Test the image_crop_effect() function.
ImageEffectsUnitTest::testDesaturateEffect in modules/image/image.test
Test the image_desaturate_effect() function.
ImageEffectsUnitTest::testResizeEffect in modules/image/image.test
Test the image_resize_effect() function.
ImageEffectsUnitTest::testRotateEffect in modules/image/image.test
Test the image_rotate_effect() function.
ImageEffectsUnitTest::testScaleAndCropEffect in modules/image/image.test
Test the image_scale_and_crop_effect() function.

... See full list

File

modules/simpletest/tests/image.test, line 51
Tests for core image handling API.

Class

ImageToolkitTestCase
Base class for image manipulation testing.

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.');
  }
}