You are here

function DatabaseLoggingTestCase::testEnableMultiLogging in SimpleTest 7

Test that we can run two logs in parallel.

File

tests/database_test.test, line 2355

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, t('Correct number of queries recorded for log 1.'));
  $this
    ->assertEqual(count($queries2), 1, t('Correct number of queries recorded for log 2.'));
}