function RulesTestCase::testVariableMapping in Rules 8.3
Same name and namespace in other branches
- 7.2 tests/rules.test \RulesTestCase::testVariableMapping()
Test setting up a rule and mapping variables.
File
- d7-tests/
rules_test_case.test, line 175 - Rules 7.x tests.
Class
Code
function testVariableMapping() {
$rule = rule(array(
'node' => array(
'type' => 'node',
),
'node_unchanged' => array(
'type' => 'node',
),
));
$rule
->condition(rules_condition('rules_condition_content_is_published')
->negate())
->condition('rules_condition_content_is_type', array(
'type' => array(
'page',
'story',
),
))
->action('rules_node_publish_action', array(
'node:select' => 'node_unchanged',
));
$node1 = $this
->drupalCreateNode(array(
'status' => 0,
'type' => 'page',
));
$node2 = $this
->drupalCreateNode(array(
'status' => 0,
'type' => 'page',
));
$rule
->integrityCheck();
$rule
->execute($node1, $node2);
$this
->assertEqual($node2->status, 1, 'Action executed correctly on node2.');
$this
->assertEqual($node1->status, 0, 'Action not executed on node1.');
RulesLog::logger()
->checkLog();
}