function EntityCrudHookTest::assertHookMessageOrder
Same name in other branches
- 9 core/tests/Drupal/KernelTests/Core/Entity/EntityCrudHookTest.php \Drupal\KernelTests\Core\Entity\EntityCrudHookTest::assertHookMessageOrder()
- 10 core/tests/Drupal/KernelTests/Core/Entity/EntityCrudHookTest.php \Drupal\KernelTests\Core\Entity\EntityCrudHookTest::assertHookMessageOrder()
- 11.x core/tests/Drupal/KernelTests/Core/Entity/EntityCrudHookTest.php \Drupal\KernelTests\Core\Entity\EntityCrudHookTest::assertHookMessageOrder()
Checks the order of CRUD hook execution messages.
Module entity_crud_hook_test 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/
tests/ Drupal/ KernelTests/ Core/ Entity/ EntityCrudHookTest.php - Tests hook invocations for CRUD operations on blocks.
- EntityCrudHookTest::testCommentHooks in core/
tests/ Drupal/ KernelTests/ Core/ Entity/ EntityCrudHookTest.php - Tests hook invocations for CRUD operations on comments.
- EntityCrudHookTest::testFileHooks in core/
tests/ Drupal/ KernelTests/ Core/ Entity/ EntityCrudHookTest.php - Tests hook invocations for CRUD operations on files.
- EntityCrudHookTest::testNodeHooks in core/
tests/ Drupal/ KernelTests/ Core/ Entity/ EntityCrudHookTest.php - Tests hook invocations for CRUD operations on nodes.
- EntityCrudHookTest::testTaxonomyTermHooks in core/
tests/ Drupal/ KernelTests/ Core/ Entity/ EntityCrudHookTest.php - Tests hook invocations for CRUD operations on taxonomy terms.
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Entity/ EntityCrudHookTest.php, line 75
Class
- EntityCrudHookTest
- Tests the invocation of hooks when creating, inserting, loading, updating or deleting an entity.
Namespace
Drupal\KernelTests\Core\EntityCode
protected function assertHookMessageOrder($messages) {
$positions = [];
foreach ($messages as $message) {
// Verify that each message is found and record its position.
$position = array_search($message, $GLOBALS['entity_crud_hook_test']);
$this->assertNotFalse($position, $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.');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.