You are here

protected function OverviewPageTest::checkOperations in Search API 8

Tests server operations in the overview page.

1 call to OverviewPageTest::checkOperations()
OverviewPageTest::testOverviewPage in tests/src/Functional/OverviewPageTest.php
Tests various scenarios for the overview page.

File

tests/src/Functional/OverviewPageTest.php, line 204

Class

OverviewPageTest
Tests the Search API overview page.

Namespace

Drupal\Tests\search_api\Functional

Code

protected function checkOperations() {
  $server = $this
    ->getTestServer();
  $this
    ->drupalGet($this->overviewPageUrl);
  $basic_url = $this->urlGenerator
    ->generateFromRoute('entity.search_api_server.canonical', [
    'search_api_server' => $server
      ->id(),
  ]);
  $destination = "?destination=" . $this->urlGenerator
    ->generateFromRoute('search_api.overview');
  $this
    ->assertSession()
    ->responseContains("<a href=\"{$basic_url}/edit{$destination}\">Edit</a>");
  $this
    ->assertSession()
    ->responseContains("<a href=\"{$basic_url}/disable{$destination}\">Disable</a>");
  $this
    ->assertSession()
    ->responseContains("<a href=\"{$basic_url}/delete{$destination}\">Delete</a>");
  $this
    ->assertSession()
    ->responseNotContains("<a href=\"{$basic_url}/enable{$destination}\">Enable</a>");
  $server
    ->setStatus(FALSE)
    ->save();
  $this
    ->drupalGet($this->overviewPageUrl);

  // Since \Drupal\Core\Access\CsrfTokenGenerator uses the current session ID,
  // we cannot verify the validity of the token from here.
  $params = $destination ? "{$destination}&amp;token=" : '?token=';
  $this
    ->assertSession()
    ->responseContains("<a href=\"{$basic_url}/enable{$params}");
  $this
    ->assertSession()
    ->responseNotContains("<a href=\"{$basic_url}/disable{$destination}\">Disable</a>");
}