function LoggingTest::testEnableTargetLoggingNoTarget 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::testEnableTargetLoggingNoTarget()
Tests that logs to separate targets use 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
- core/
modules/ system/ src/ Tests/ Database/ LoggingTest.php, line 88 - Contains \Drupal\system\Tests\Database\LoggingTest.
Class
- LoggingTest
- Tests the query logging facility.
Namespace
Drupal\system\Tests\DatabaseCode
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 "replica" 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, 'Recorded queries from all targets.');
$this
->assertEqual($queries1[0]['target'], 'default', 'First query used default target.');
$this
->assertEqual($queries1[1]['target'], 'default', 'Second query used default target as fallback.');
}