You are here

public function RulesConditionalUITestCase::testBaseUI in Conditional Rules 7

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

Tests RulesConditionalPluginUI.

File

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

Class

RulesConditionalUITestCase
UI tests.

Code

public function testBaseUI() {

  // Create component.
  $componentName = 'base_test';
  $comp = rules_action_set(array())
    ->action($container = new RulesConditionalTestStubContainer());
  $comp->component = TRUE;
  $comp
    ->integrityCheck()
    ->save($componentName);
  $componentPath = 'admin/config/workflow/rules/components';
  RulesPluginUI::$basePath = $componentPath;
  $managePath = RulesPluginUI::path($componentName);
  $addSinglePath = RulesPluginUI::path($componentName, 'add', $container, 'stub conditional single element');
  $addDependentPath = RulesPluginUI::path($componentName, 'add', $container, 'stub conditional dependent element');

  // Test 'conditional depends'.
  $this
    ->drupalGet($managePath);

  // Check dependent element cannot be added.
  $this
    ->assertNoLinkByHref(url($addDependentPath), 'Dependent plugin is unavailable to add.');

  // Add element and then check for link to add dependent element.
  $element = new RulesConditionalTestStubElement();
  $element
    ->setParent($container);
  $comp
    ->save();
  $this
    ->drupalGet($managePath);
  $this
    ->assertLinkByHref(url($addDependentPath), 0, 'Dependent plugin can be added on fulfilling prerequisite.');

  // Test 'conditional single'.
  $element = new RulesConditionalTestStubSingleElement();
  $element
    ->setParent($container);
  $comp
    ->save();
  $this
    ->drupalGet($managePath);
  $this
    ->assertNoLinkByHref(url($addSinglePath), 'Single plugins cannot be added more than once.');
}