You are here

private function DbLogTest::verifyReports in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/dblog/tests/src/Functional/DbLogTest.php \Drupal\Tests\dblog\Functional\DbLogTest::verifyReports()
  2. 10 core/modules/dblog/tests/src/Functional/DbLogTest.php \Drupal\Tests\dblog\Functional\DbLogTest::verifyReports()

Confirms that database log reports are displayed at the correct paths.

Parameters

int $response: (optional) HTTP response code. Defaults to 200.

1 call to DbLogTest::verifyReports()
DbLogTest::testDbLog in core/modules/dblog/tests/src/Functional/DbLogTest.php
Tests Database Logging module functionality through interfaces.

File

core/modules/dblog/tests/src/Functional/DbLogTest.php, line 298

Class

DbLogTest
Generate events and verify dblog entries; verify user access to log reports based on permissions.

Namespace

Drupal\Tests\dblog\Functional

Code

private function verifyReports($response = 200) {

  // View the database log help page.
  $this
    ->drupalGet('admin/help/dblog');
  $this
    ->assertSession()
    ->statusCodeEquals($response);
  if ($response == 200) {
    $this
      ->assertSession()
      ->pageTextContains('Database Logging');
  }

  // View the database log report page.
  $this
    ->drupalGet('admin/reports/dblog');
  $this
    ->assertSession()
    ->statusCodeEquals($response);
  if ($response == 200) {
    $this
      ->assertSession()
      ->pageTextContains('Recent log messages');
  }
  $this
    ->drupalGet('admin/reports/dblog/confirm');
  $this
    ->assertSession()
    ->statusCodeEquals($response);
  if ($response == 200) {
    $this
      ->assertSession()
      ->pageTextContains('Are you sure you want to delete the recent logs?');
  }

  // View the database log page-not-found report page.
  $this
    ->drupalGet('admin/reports/page-not-found');
  $this
    ->assertSession()
    ->statusCodeEquals($response);
  if ($response == 200) {
    $this
      ->assertSession()
      ->pageTextContains("Top 'page not found' errors");
  }

  // View the database log access-denied report page.
  $this
    ->drupalGet('admin/reports/access-denied');
  $this
    ->assertSession()
    ->statusCodeEquals($response);
  if ($response == 200) {
    $this
      ->assertSession()
      ->pageTextContains("Top 'access denied' errors");
  }

  // View the database log event page.
  $query = Database::getConnection()
    ->select('watchdog');
  $query
    ->addExpression('MIN([wid])');
  $wid = $query
    ->execute()
    ->fetchField();
  $this
    ->drupalGet('admin/reports/dblog/event/' . $wid);
  $this
    ->assertSession()
    ->statusCodeEquals($response);
  if ($response == 200) {
    $this
      ->assertSession()
      ->pageTextContains('Details');
  }
}