Tests that the expected hooks have been invoked on the expected entities.
$expected_hooks: An array keyed by hook name, with one entry per expected invocation. Each entry is the value of the "$entity" parameter the hook is expected to have been passed.
$actual_hooks: The array of actual hook invocations recorded by field_test_memorize().
function checkHooksInvocations($expected_hooks, $actual_hooks) {
foreach ($expected_hooks as $hook => $invocations) {
$actual_invocations = $actual_hooks[$hook];
// Check that the number of invocations is correct.
$this
->assertEqual(count($actual_invocations), count($invocations), "{$hook}() was called the expected number of times.");
// Check that the hook was called for each expected argument.
foreach ($invocations as $argument) {
$found = FALSE;
foreach ($actual_invocations as $actual_arguments) {
if ($actual_arguments[1] == $argument) {
$found = TRUE;
break;
}
}
$this
->assertTrue($found, "{$hook}() was called on expected argument");
}
}
}