function RulesTriggerTestCase::testRecursionPrevention in Rules 8.3
Same name and namespace in other branches
- 7.2 tests/rules.test \RulesTriggerTestCase::testRecursionPrevention()
Tests preventing recursive rule invocations by creating a rule that reacts on node-update and generates a node update that would trigger it itself.
File
- d7-tests/
rules_test_trigger_case.test, line 140 - Rules 7.x tests.
Class
- RulesTriggerTestCase
- Test triggering rules.
Code
function testRecursionPrevention() {
$rule = $this
->createTestRule(FALSE, 'node_update');
$rule
->action('rules_node_make_sticky_action');
$rule
->integrityCheck()
->save();
// Now trigger the rule.
$node = $this
->drupalCreateNode(array(
'type' => 'page',
'sticky' => 0,
'status' => 0,
));
node_save($node);
$text = RulesTestCase::t('Not evaluating reaction rule %label to prevent recursion.', array(
'label' => $rule->name,
));
//debug(RulesLog::logger()->render());
$this
->assertTrue(strpos(RulesLog::logger()
->render(), $text) !== FALSE, "Recursion prevented.");
//debug(RulesLog::logger()->render());
}