You are here

protected function EntityCrudHookTest::assertHookMessageOrder in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Tests/Entity/EntityCrudHookTest.php \Drupal\system\Tests\Entity\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 $GLOBALS['entity_crud_hook_test'].

Parameters

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

7 calls to EntityCrudHookTest::assertHookMessageOrder()
EntityCrudHookTest::testBlockHooks in core/modules/system/src/Tests/Entity/EntityCrudHookTest.php
Tests hook invocations for CRUD operations on blocks.
EntityCrudHookTest::testCommentHooks in core/modules/system/src/Tests/Entity/EntityCrudHookTest.php
Tests hook invocations for CRUD operations on comments.
EntityCrudHookTest::testFileHooks in core/modules/system/src/Tests/Entity/EntityCrudHookTest.php
Tests hook invocations for CRUD operations on files.
EntityCrudHookTest::testNodeHooks in core/modules/system/src/Tests/Entity/EntityCrudHookTest.php
Tests hook invocations for CRUD operations on nodes.
EntityCrudHookTest::testTaxonomyTermHooks in core/modules/system/src/Tests/Entity/EntityCrudHookTest.php
Tests hook invocations for CRUD operations on taxonomy terms.

... See full list

File

core/modules/system/src/Tests/Entity/EntityCrudHookTest.php, line 69
Contains \Drupal\system\Tests\Entity\EntityCrudHookTest.

Class

EntityCrudHookTest
Tests the invocation of hooks when creating, inserting, loading, updating or deleting an entity.

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, $GLOBALS['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.');
}