1 actions.test | protected ActionLoopTestCase::triggerActions() |
Create an infinite loop by causing a watchdog message to be set, which causes the actions to be triggered again, up to actions_max_stack times.
File
- core/
modules/ simpletest/ tests/ actions.test, line 37 - Tests for checking the actions system within Backdrop.
Class
- ActionLoopTestCase
- Test actions executing in a potential loop, and make sure they abort properly.
Code
protected function triggerActions() {
$this->backdropGet('<front>', array('query' => array('trigger_actions_on_watchdog' => 'actions_loop_test_log')));
$expected = array();
$expected[] = 'Triggering action loop';
$recursion_limit = config_get('system.core', 'action_recursion_limit');
for ($i = 1; $i <= $recursion_limit; $i++) {
$expected[] = "Test log #$i";
}
$expected[] = 'Stack overflow: recursion limit for actions_execute() has been reached. Stack is limited by %limit calls.';
$result = db_query("SELECT message FROM {watchdog} WHERE type = 'actions_loop_test' OR type = 'actions' ORDER BY wid");
foreach ($result as $row) {
$expected_message = array_shift($expected);
$this->assertEqual($row->message, $expected_message, t('Expected message %expected, got %message.', array('%expected' => $expected_message, '%message' => $row->message)));
}
$this->assertTrue(empty($expected), t('All expected messages found.'));
}