You are here

public function RulesConditionalUITestCase::testCaseUI in Conditional Rules 7

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

Tests RulesConditionalCaseUI.

File

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

Class

RulesConditionalUITestCase
UI tests.

Code

public function testCaseUI() {

  // Create component.
  $componentName = 'case_test';
  $comp = rules_action_set(array(
    'node' => array(
      'type' => 'node',
      'label' => t('Node'),
    ),
  ))
    ->action($switch = rules_conditional_switch('node:type'));
  $comp->component = TRUE;
  $comp
    ->integrityCheck()
    ->save($componentName);
  $componentPath = 'admin/config/workflow/rules/components';
  RulesPluginUI::$basePath = $componentPath;
  $addPath = RulesPluginUI::path($componentName, 'add', $switch, 'case');

  // Test adding a case.
  $this
    ->drupalGet($addPath);
  $this
    ->assertFieldByXPath("//select[@name='parameter[value][settings][value]']", NULL, 'Option case values are shown as select list.');
  $edit = array(
    'parameter[value][settings][value]' => 'page',
  );
  $this
    ->drupalPost(NULL, $edit, t('Save'));

  // Reload and execute component.
  $comp = rules_config_load($componentName);

  // Navigate to switch.
  $comp
    ->elements()
    ->current()
    ->elements()
    ->current()
    ->action('data_set', array(
    'data:select' => 'node:title',
    'value' => 'evaluate case',
  ));
  $comp
    ->execute($node = $this
    ->drupalCreateNode());
  $this
    ->assertEqual('evaluate case', $node->title, 'Case element created from case UI can be evaluated.');
}