You are here

public function RulesSchedulerTestCase::testCustomTaskHandler in Rules 7.2

Tests that custom task handlers are properly invoked.

File

rules_scheduler/tests/rules_scheduler.test, line 133
Rules Scheduler tests.

Class

RulesSchedulerTestCase
Test cases for the Rules Scheduler module.

Code

public function testCustomTaskHandler() {

  // Set up a scheduled task that will simply write a variable when executed.
  $variable = 'rules_schedule_task_handler_variable';
  rules_scheduler_schedule_task(array(
    'date' => REQUEST_TIME,
    'identifier' => '',
    'config' => '',
    'data' => array(
      'variable' => $variable,
    ),
    'handler' => 'RulesTestTaskHandler',
  ));

  // Run cron to let the rules scheduler do its work.
  $this
    ->cronRun();

  // The task handler should have set the variable to TRUE now.
  $this
    ->assertTrue(variable_get($variable));
}