7.x actions.test 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.

1 call to ActionLoopTestCase::triggerActions()
ActionLoopTestCase::testActionLoop in modules/simpletest/tests/actions.test
Set up a loop with 3 - 12 recursions, and see if it aborts properly.


modules/simpletest/tests/actions.test, line 109


Test actions executing in a potential loop, and make sure they abort properly.


protected function triggerActions() {
    ->drupalGet('<front>', array(
    'query' => array(
      'trigger_actions_on_watchdog' => TRUE,
  $expected = array();
  $expected[] = 'Triggering action loop';
  for ($i = 1; $i <= variable_get('actions_max_stack', 35); $i++) {
    $expected[] = "Test log #{$i}";
  $expected[] = 'Stack overflow: too many calls to actions_do(). Aborting to prevent infinite recursion.';
  $result = db_query("SELECT message FROM {watchdog} WHERE type = 'actions_loop_test' OR type = 'actions' ORDER BY wid");
  $loop_started = FALSE;
  foreach ($result as $row) {
    $expected_message = array_shift($expected);
      ->assertEqual($row->message, $expected_message, t('Expected message %expected, got %message.', array(
      '%expected' => $expected_message,
      '%message' => $row->message,
    ->assertTrue(empty($expected), t('All expected messages found.'));