function BulkDeleteTest::checkHooksInvocations

Tests that the expected hooks have been invoked on the expected entities.

Parameters

$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().

2 calls to BulkDeleteTest::checkHooksInvocations()
BulkDeleteTest::testPurgeField in drupal/core/modules/field/lib/Drupal/field/Tests/BulkDeleteTest.php
Verify that fields are preserved and purged correctly as multiple instances are deleted and purged.
BulkDeleteTest::testPurgeInstance in drupal/core/modules/field/lib/Drupal/field/Tests/BulkDeleteTest.php
Verify that field data items and instances are purged when an instance is deleted.

File

drupal/core/modules/field/lib/Drupal/field/Tests/BulkDeleteTest.php, line 70
Definition of Drupal\field\Tests\BulkDeleteTest.

Class

BulkDeleteTest
Unit test class for field bulk delete and batch purge functionality.

Namespace

Drupal\field\Tests

Code

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) {

        // $entity is sometimes the first and sometimes the second argument.
        if ($actual_arguments[0] == $argument || $actual_arguments[1] == $argument) {
          $found = TRUE;
          break;
        }
      }
      $this
        ->assertTrue($found, "{$hook}() was called on expected argument");
    }
  }
}