function DatabaseLoggingTestCase::testEnableTargetLoggingNoTarget in SimpleTest 7
Test that logs to separate targets collapse to the same connection properly.
This test is identical to the one above, except that it doesn't create a fake target so the query should fall back to running on the default target.
File
- tests/
database_test.test, line 2400
Class
- DatabaseLoggingTestCase
- Query logging tests.
Code
function testEnableTargetLoggingNoTarget() {
Database::startLog('testing1');
db_query('SELECT name FROM {test} WHERE age > :age', array(
':age' => 25,
))
->fetchCol();
// We use "fake" here as a target because any non-existent target will do.
// However, because all of the tests in this class share a single page
// request there is likely to be a target of "slave" from one of the other
// unit tests, so we use a target here that we know with absolute certainty
// does not exist.
db_query('SELECT age FROM {test} WHERE name = :name', array(
':name' => 'Ringo',
), array(
'target' => 'fake',
))
->fetchCol();
$queries1 = Database::getLog('testing1');
$this
->assertEqual(count($queries1), 2, t('Recorded queries from all targets.'));
$this
->assertEqual($queries1[0]['target'], 'default', t('First query used default target.'));
$this
->assertEqual($queries1[1]['target'], 'default', t('Second query used default target as fallback.'));
}