1 layout.test | protected LayoutHookTestCase::assertHookMessageOrder($messages) |
Checks the order of CRUD hook execution messages.
layout_test.module implements all core layout CRUD hooks and stores a message for each in state_get('layout_test').
Parameters
$messages: An array of plain-text messages in the order they should appear.
File
- core/
modules/ layout/ tests/ layout.test, line 2978 - Tests for the Layout module.
Class
- LayoutHookTestCase
- Tests invocation of hooks when performing an action.
Code
protected function assertHookMessageOrder($messages) {
$positions = array();
$state_get = state_get('layout_test');
foreach ($messages as $message) {
// Verify that each message is found and record its position.
$position = array_search($message, $state_get);
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.');
}