You are here

protected function IntegrationTest::checkAdminAccess in Search API Autocomplete 8

Verifies that admin pages are properly protected.

1 call to IntegrationTest::checkAdminAccess()
IntegrationTest::testModule in tests/src/FunctionalJavascript/IntegrationTest.php
Tests the complete functionality of the module via the UI.

File

tests/src/FunctionalJavascript/IntegrationTest.php, line 516

Class

IntegrationTest
Tests the functionality of the whole module from a user's perspective.

Namespace

Drupal\Tests\search_api_autocomplete\FunctionalJavascript

Code

protected function checkAdminAccess() {
  $assert_session = $this
    ->assertSession();

  // Make sure anonymous and non-admin users cannot access admin pages.
  $users = [
    'non-admin' => $this->normalUser,
    'anonymous' => NULL,
  ];
  $paths = [
    'index overview' => $this
      ->getAdminPath(),
    'search edit form' => $this
      ->getAdminPath('edit'),
    'search delete form' => $this
      ->getAdminPath('delete'),
  ];
  foreach ($users as $user_type => $account) {
    $this
      ->drupalLogout();
    if ($account) {
      $this
        ->drupalLogin($account);
    }
    foreach ($paths as $label => $path) {
      $this
        ->drupalGet($path);
      $assert_session
        ->pageTextContains('Access denied');
      $assert_session
        ->pageTextContains('You are not authorized to access this page.');
    }
  }
  $this
    ->drupalLogin($this->adminUser);
}