function ImageToolkitTestCase::assertToolkitOperationsCalled in SimpleTest 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.
9 calls to ImageToolkitTestCase::assertToolkitOperationsCalled()
- ImageToolkitUnitTest::testCrop in tests/
image.test - Test the image_crop() function.
- ImageToolkitUnitTest::testDesaturate in tests/
image.test - Test the image_desaturate() function.
- ImageToolkitUnitTest::testGetAvailableToolkits in tests/
image.test - Check that hook_image_toolkits() is called and only available toolkits are returned.
- ImageToolkitUnitTest::testLoad in tests/
image.test - Test the image_load() function.
- ImageToolkitUnitTest::testResize in tests/
image.test - Test the image_resize() function.
File
- tests/
image.test, line 44 - Unit tests for the Drupal Form 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, t('Expected operations %expected to be called but %uncalled was not called.', array(
'%expected' => implode(', ', $expected),
'%uncalled' => implode(', ', $uncalled),
)));
}
else {
$this
->assertTrue(TRUE, t('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, t('Unexpected operations were called: %unexpected.', array(
'%unexpected' => implode(', ', $unexpected),
)));
}
else {
$this
->assertTrue(TRUE, t('No unexpected operations were called.'));
}
}