You are here

protected function PageManagerAdminTest::doTestAccessConditions in Page Manager 8

Tests access conditions step on both add and edit wizard.

Parameters

string $path: The path this step is supposed to be at.

bool|TRUE $redirect: Whether or not to redirect to the path.

2 calls to PageManagerAdminTest::doTestAccessConditions()
PageManagerAdminTest::doTestAddPage in page_manager_ui/src/Tests/PageManagerAdminTest.php
Tests adding a page.
PageManagerAdminTest::testAdmin in page_manager_ui/src/Tests/PageManagerAdminTest.php
Tests the Page Manager admin UI.

File

page_manager_ui/src/Tests/PageManagerAdminTest.php, line 153
Contains \Drupal\page_manager_ui\Tests\PageManagerAdminTest.

Class

PageManagerAdminTest
Tests the admin UI for page entities.

Namespace

Drupal\page_manager_ui\Tests

Code

protected function doTestAccessConditions($path = 'admin/structure/page_manager/manage/foo/access', $redirect = TRUE) {
  if ($this
    ->getUrl() !== $path && $redirect) {
    $this
      ->drupalGet($path);
  }
  $this
    ->assertRaw('No required conditions have been configured.');

  // Configure a new condition.
  $edit = [
    'conditions' => 'user_role',
  ];
  $this
    ->drupalPostForm(NULL, $edit, 'Add Condition');
  $this
    ->assertTitle('Add access condition | Drupal');
  $edit = [
    'roles[authenticated]' => TRUE,
  ];
  $this
    ->drupalPostForm(NULL, $edit, 'Save');
  $this
    ->assertRaw('The user is a member of Authenticated user');

  // Make sure we're still on the same wizard.
  $this
    ->assertUrl($path);

  // Edit the condition.
  $this
    ->clickLink('Edit');
  $this
    ->assertTitle('Edit access condition | Drupal');
  $edit = [
    'roles[anonymous]' => TRUE,
  ];
  $this
    ->drupalPostForm(NULL, $edit, 'Save');
  $this
    ->assertRaw('The user is a member of Anonymous user, Authenticated user');
  $this
    ->assertUrl($path);

  // Delete the condition.
  $this
    ->clickLink('Delete');
  $this
    ->assertTitle('Are you sure you want to delete the user_role condition? | Drupal');
  $this
    ->drupalPostForm(NULL, [], 'Delete');
  $this
    ->assertRaw('No required conditions have been configured.');
  $this
    ->assertUrl($path);
}