You are here

function DatabaseLoggingTestCase::testEnableLogging in SimpleTest 7

Test that we can log the existence of a query.

File

tests/database_test.test, line 2337

Class

DatabaseLoggingTestCase
Query logging tests.

Code

function testEnableLogging() {
  Database::startLog('testing');
  db_query('SELECT name FROM {test} WHERE age > :age', array(
    ':age' => 25,
  ))
    ->fetchCol();
  db_query('SELECT age FROM {test} WHERE name = :name', array(
    ':name' => 'Ringo',
  ))
    ->fetchCol();
  $queries = Database::getLog('testing', 'default');
  $this
    ->assertEqual(count($queries), 2, t('Correct number of queries recorded.'));
  foreach ($queries as $query) {
    $this
      ->assertEqual($query['caller']['function'], __FUNCTION__, t('Correct function in query log.'));
  }
}