public function RulesSchedulerTestCase::testComponentSchedule in Rules 7.2
Tests scheduling components from the action.
Note that this also makes sure Rules properly handles timezones, else this test could fail due to a wrong 'now' timestamp.
File
- rules_scheduler/
tests/ rules_scheduler.test, line 39 - Rules Scheduler tests.
Class
- RulesSchedulerTestCase
- Test cases for the Rules Scheduler module.
Code
public function testComponentSchedule() {
$set = rules_rule_set(array(
'node1' => array(
'type' => 'node',
'label' => 'node',
),
));
$set
->rule(rule()
->condition('node_is_published', array(
'node:select' => 'node1',
))
->action('node_unpublish', array(
'node:select' => 'node1',
)));
$set
->integrityCheck()
->save('rules_test_set_2');
// Use different names for the variables to ensure they are properly mapped.
$rule = rule(array(
'node2' => array(
'type' => 'node',
'label' => 'node',
),
));
$rule
->action('schedule', array(
'component' => 'rules_test_set_2',
'identifier' => 'node_[node2:nid]',
'date' => 'now',
'param_node1:select' => 'node2',
));
$node = $this
->drupalCreateNode(array(
'title' => 'The title.',
'status' => 1,
));
$rule
->execute($node);
// Run cron to let the rules scheduler do its work.
$this
->cronRun();
$node = node_load($node->nid, NULL, TRUE);
$this
->assertFalse($node->status, 'The component has been properly scheduled.');
RulesLog::logger()
->checkLog();
}