function LoggingTest::testEnableLogging in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/system/src/Tests/Database/LoggingTest.php \Drupal\system\Tests\Database\LoggingTest::testEnableLogging()
Tests that we can log the existence of a query.
File
- core/
modules/ system/ src/ Tests/ Database/ LoggingTest.php, line 22 - Contains \Drupal\system\Tests\Database\LoggingTest.
Class
- LoggingTest
- Tests the query logging facility.
Namespace
Drupal\system\Tests\DatabaseCode
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();
// Trigger a call that does not have file in the backtrace.
call_user_func_array('db_query', array(
'SELECT age FROM {test} WHERE name = :name',
array(
':name' => 'Ringo',
),
))
->fetchCol();
$queries = Database::getLog('testing', 'default');
$this
->assertEqual(count($queries), 3, 'Correct number of queries recorded.');
foreach ($queries as $query) {
$this
->assertEqual($query['caller']['function'], __FUNCTION__, 'Correct function in query log.');
}
}