You are here

private function DbLogTest::verifyReports in Drupal 8

Same name and namespace in other branches
  1. 9 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
      ->assertText(t('Database Logging'), 'DBLog help was displayed');
  }

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

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

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

  // 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
      ->assertText(t('Details'), 'DBLog event node was displayed');
  }
}