You are here

protected function RulesTriggerTestCase::createTestRule in Rules 7.2

Same name and namespace in other branches
  1. 8.3 d7-tests/rules_test_trigger_case.test \RulesTriggerTestCase::createTestRule()

Helper function to create a test Rule.

6 calls to RulesTriggerTestCase::createTestRule()
RulesTriggerTestCase::testBasicReactionRule in tests/rules.test
Tests creating and triggering a basic reaction rule.
RulesTriggerTestCase::testReactiveRuleCreation in tests/rules.test
Tests CRUD for reaction rules - making sure the events are stored properly.
RulesTriggerTestCase::testRecursionOnDifferentArguments in tests/rules.test
Tests recursion prevention with altered arguments.
RulesTriggerTestCase::testRecursionPrevention in tests/rules.test
Tests preventing recursive rule invocations.
RulesTriggerTestCase::testVariableHandler in tests/rules.test
Tests a rule using a handler to load a variable.

... See full list

File

tests/rules.test, line 1135
Rules tests.

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;
}