function RulesTriggerTestCase::createTestRule

Same name in other branches
  1. 7.x-2.x tests/rules.test \RulesTriggerTestCase::createTestRule()
6 calls to RulesTriggerTestCase::createTestRule()
RulesTriggerTestCase::testBasicReactionRule in d7-tests/rules_test_trigger_case.test
Tests creating and triggering a basic reaction rule.
RulesTriggerTestCase::testReactiveRuleCreation in d7-tests/rules_test_trigger_case.test
Tests CRUD for reaction rules - making sure the events are stored properly.
RulesTriggerTestCase::testRecursionOnDifferentArguments in d7-tests/rules_test_trigger_case.test
Ensure the recursion prevention still allows to let the rule trigger again during evaluation of the same event set, if the event isn't caused by the rule itself - thus we won't run in an infinite loop.
RulesTriggerTestCase::testRecursionPrevention in d7-tests/rules_test_trigger_case.test
Tests preventing recursive rule invocations by creating a rule that reacts on node-update and generates a node update that would trigger it itself.
RulesTriggerTestCase::testVariableHandler in d7-tests/rules_test_trigger_case.test
Test a rule using a handler to load a variable.

... See full list

File

d7-tests/rules_test_trigger_case.test, line 33

Class

RulesTriggerTestCase
Test triggering rules.

Code

protected function createTestRule($action = TRUE, $event = 'node_presave') {
    $rule = rules_reaction_rule();
    $rule->event($event)
        ->condition(rules_condition('data_is', array(
        'data:select' => 'node:status',
        'value' => TRUE,
    ))->negate())
        ->condition('data_is', array(
        'data:select' => 'node:type',
        'value' => 'page',
    ));
    if ($action) {
        $rule->action('rules_action_delete_node');
    }
    return $rule;
}