You are here

function ActionLoopTestCase::testActionLoop in SimpleTest 7

Set up a loop with 10-50 recursions, and see if it aborts properly.

File

tests/actions.test, line 85

Class

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

Code

function testActionLoop() {
  $user = $this
    ->drupalCreateUser(array(
    'administer actions',
  ));
  $this
    ->drupalLogin($user);
  $hash = md5('actions_loop_test_log');
  $edit = array(
    'aid' => $hash,
  );
  $this
    ->drupalPost('admin/structure/trigger/actions_loop_test', $edit, t('Assign'));

  // Delete any existing watchdog messages to clear the plethora of
  // "Action added" messages from when Drupal was installed.
  db_delete('watchdog')
    ->execute();
  $this
    ->triggerActions();

  // Clear the log again for another test, this time with a random maximum.
  db_delete('watchdog')
    ->execute();
  variable_set('actions_max_stack', mt_rand(10, 50));
  $this
    ->triggerActions();
}