You are here

function DatabaseLoggingTestCase::testEnableMultiLogging in Drupal 7

Test that we can run two logs in parallel.

File

modules/simpletest/tests/database_test.test, line 2999

Class

DatabaseLoggingTestCase
Query logging tests.

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