You are here

private function DbLogTest::verifyCron in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/modules/dblog/src/Tests/DbLogTest.php \Drupal\dblog\Tests\DbLogTest::verifyCron()

Verifies that cron correctly applies the database log row limit.

Parameters

int $row_limit: The row limit.

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

File

core/modules/dblog/src/Tests/DbLogTest.php, line 115
Contains \Drupal\dblog\Tests\DbLogTest.

Class

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

Namespace

Drupal\dblog\Tests

Code

private function verifyCron($row_limit) {

  // Generate additional log entries.
  $this
    ->generateLogEntries($row_limit + 10);

  // Verify that the database log row count exceeds the row limit.
  $count = db_query('SELECT COUNT(wid) FROM {watchdog}')
    ->fetchField();
  $this
    ->assertTrue($count > $row_limit, format_string('Dblog row count of @count exceeds row limit of @limit', array(
    '@count' => $count,
    '@limit' => $row_limit,
  )));

  // Run a cron job.
  $this
    ->cronRun();

  // Verify that the database log row count equals the row limit plus one
  // because cron adds a record after it runs.
  $count = db_query('SELECT COUNT(wid) FROM {watchdog}')
    ->fetchField();
  $this
    ->assertTrue($count == $row_limit + 1, format_string('Dblog row count of @count equals row limit of @limit plus one', array(
    '@count' => $count,
    '@limit' => $row_limit,
  )));
}