1 entity_crud_hook_test.test | protected EntityCrudHookTestCase::assertHookMessageOrder($messages) |
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.
File
- core/
modules/ entity/ tests/ entity_crud_hook_test.test, line 36 - CRUD hook tests for the Entity CRUD API.
Class
- EntityCrudHookTestCase
- Tests invocation of hooks when performing an action.
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.');
}