You are here

public function RulesUiTestCase::testComponentPermissions in Rules 7.2

Tests setting component permissions in the UI.

See also

https://www.drupal.org/project/rules/issues/2340505

File

rules_admin/tests/rules_admin.test, line 214
Rules UI tests.

Class

RulesUiTestCase
Tests for creating rules through the UI.

Code

public function testComponentPermissions() {

  // Create a simple user account with permission to create a rule.
  $user = $this
    ->drupalCreateUser(array(
    'access administration pages',
    'administer rules',
    'bypass rules access',
  ));
  $this
    ->drupalLogin($user);

  // The rules_test module defines the component 'rules_test_action_set'.
  // Verify that this code-provided component appears in the UI.
  $this
    ->drupalGet('admin/config/workflow/rules/components');
  $this
    ->assertText('rules_test_action_set', 'Test component is defined.');

  // Visit the component edit page.
  $this
    ->clickLink('rules_test_action_set');
  $this
    ->assertText('Configure access for using this component with a permission.', 'Enable component permission checkbox is present.');
  $this
    ->assertText('Use Rules component rules_test_action_set', 'Permission configuration form is present.');

  // Try to enable permissions on this component and set a component
  // permission at the same time.
  $edit = array(
    'settings[access][access_exposed]' => TRUE,
    'settings[access][permissions][matrix][checkboxes][1][use Rules component rules_test_action_set]' => TRUE,
  );
  $this
    ->drupalPost(NULL, $edit, 'Save changes');
}