You are here

function LoggingTest::testEnableMultiLogging in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Tests/Database/LoggingTest.php \Drupal\system\Tests\Database\LoggingTest::testEnableMultiLogging()

Tests that we can run two logs in parallel.

File

core/modules/system/src/Tests/Database/LoggingTest.php, line 43
Contains \Drupal\system\Tests\Database\LoggingTest.

Class

LoggingTest
Tests the query logging facility.

Namespace

Drupal\system\Tests\Database

Code

function testEnableMultiLogging() {
  Database::startLog('testing1');
  db_query('SELECT name FROM {test} WHERE age > :age', array(
    ':age' => 25,
  ))
    ->fetchCol();
  Database::startLog('testing2');
  db_query('SELECT age FROM {test} WHERE name = :name', array(
    ':name' => 'Ringo',
  ))
    ->fetchCol();
  $queries1 = Database::getLog('testing1');
  $queries2 = Database::getLog('testing2');
  $this
    ->assertEqual(count($queries1), 2, 'Correct number of queries recorded for log 1.');
  $this
    ->assertEqual(count($queries2), 1, 'Correct number of queries recorded for log 2.');
}