You are here

protected function RulesConditionalTestCase::createTestComponent in Conditional Rules 7

Same name and namespace in other branches
  1. 8 tests/rules_conditional.test \RulesConditionalTestCase::createTestComponent()

Creates an action set to test a conditional.

2 calls to RulesConditionalTestCase::createTestComponent()
RulesConditionalTestCase::testEvaluate in tests/rules_conditional.test
Tests evaluation.
RulesConditionalTestCase::testExport in tests/rules_conditional.test
Tests exporting.

File

tests/rules_conditional.test, line 354
SimpleTest testing suites.

Class

RulesConditionalTestCase
Default if-else tests.

Code

protected function createTestComponent() {
  return rules_action_set(array(
    'node' => array(
      'type' => 'node',
      'label' => 'Node',
    ),
  ))
    ->action(rules_conditional()
    ->if('data_is', array(
    'data:select' => 'node:title',
    'value' => 'if',
  ))
    ->action('rules_conditional_test_throw', array(
    'message' => 'if',
  ))
    ->elseIf('data_is', array(
    'data:select' => 'node:title',
    'value' => 'else if',
  ))
    ->action('rules_conditional_test_throw', array(
    'message' => 'else if',
  ))
    ->else()
    ->action('rules_conditional_test_throw', array(
    'message' => 'else',
  )));
}