protected function EntityCrudHookTest::assertHookMessageOrder

Checks the order of CRUD hook execution messages.

entity_crud_hook_test.module implements all core entity CRUD hooks and stores a message for each in $_SESSION['entity_crud_hook_test'].

Parameters

$messages: An array of plain-text messages in the order they should appear.

6 calls to EntityCrudHookTest::assertHookMessageOrder()
EntityCrudHookTest::testCommentHooks in drupal/core/modules/system/lib/Drupal/system/Tests/Entity/EntityCrudHookTest.php
Tests hook invocations for CRUD operations on comments.
EntityCrudHookTest::testFileHooks in drupal/core/modules/system/lib/Drupal/system/Tests/Entity/EntityCrudHookTest.php
Tests hook invocations for CRUD operations on files.
EntityCrudHookTest::testNodeHooks in drupal/core/modules/system/lib/Drupal/system/Tests/Entity/EntityCrudHookTest.php
Tests hook invocations for CRUD operations on nodes.
EntityCrudHookTest::testTaxonomyTermHooks in drupal/core/modules/system/lib/Drupal/system/Tests/Entity/EntityCrudHookTest.php
Tests hook invocations for CRUD operations on taxonomy terms.
EntityCrudHookTest::testTaxonomyVocabularyHooks in drupal/core/modules/system/lib/Drupal/system/Tests/Entity/EntityCrudHookTest.php
Tests hook invocations for CRUD operations on taxonomy vocabularies.

... See full list

File

drupal/core/modules/system/lib/Drupal/system/Tests/Entity/EntityCrudHookTest.php, line 52
Definition of Drupal\system\Tests\Entity\EntityCrudHookTest.

Class

EntityCrudHookTest
Tests invocation of hooks when performing an action.

Namespace

Drupal\system\Tests\Entity

Code

protected function assertHookMessageOrder($messages) {
  $positions = array();
  foreach ($messages as $message) {

    // Verify that each message is found and record its position.
    $position = array_search($message, $_SESSION['entity_crud_hook_test']);
    if ($this
      ->assertTrue($position !== FALSE, $message)) {
      $positions[] = $position;
    }
  }

  // Sort the positions and ensure they remain in the same order.
  $sorted = $positions;
  sort($sorted);
  $this
    ->assertTrue($sorted == $positions, 'The hook messages appear in the correct order.');
}