You are here

public function ErrorHandlerTest::testErrorPages in Apigee Edge 8

Tests connection error page configuration and developer failures.

File

tests/src/Functional/ErrorHandlerTest.php, line 71

Class

ErrorHandlerTest
Apigee Edge API connection error page tests.

Namespace

Drupal\Tests\apigee_edge\Functional

Code

public function testErrorPages() {
  $this
    ->drupalLogin($this->rootUser);
  $errorPageTitle = $this
    ->getRandomGenerator()
    ->word(16);
  $this
    ->drupalPostForm(Url::fromRoute('apigee_edge.settings.error_page'), [
    'error_page_title' => $errorPageTitle,
  ], 'Save configuration');
  $this
    ->assertSession()
    ->pageTextContains('The configuration options have been saved.');
  $this
    ->drupalLogin($this->drupalUser);
  $parameters = [
    'user' => $this->drupalUser
      ->id(),
    'app' => 'x',
  ];
  $routes = [
    'entity.developer_app.collection_by_developer',
    'entity.developer_app.add_form_for_developer',
    'entity.developer_app.canonical_by_developer',
    'entity.developer_app.edit_form_for_developer',
    'entity.developer_app.delete_form_for_developer',
    'entity.developer_app.analytics_for_developer',
  ];
  foreach ($routes as $route_name) {
    $route = Url::fromRoute($route_name, $parameters);
    $this
      ->drupalGet($route);
    $this
      ->assertEquals(Response::HTTP_SERVICE_UNAVAILABLE, $this
      ->getSession()
      ->getStatusCode(), $route_name);
    $this
      ->assertSession()
      ->pageTextContains($errorPageTitle);
  }
}