You are here

private function DbLogTest::verifyReports in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/dblog/tests/src/Functional/DbLogTest.php \Drupal\Tests\dblog\Functional\DbLogTest::verifyReports()
  2. 9 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.

File

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

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');
  }
}