public function LoggingTest::testContribDriverLog in Drupal 10
Same name and namespace in other branches
- 9 core/tests/Drupal/KernelTests/Core/Database/LoggingTest.php \Drupal\KernelTests\Core\Database\LoggingTest::testContribDriverLog()
Tests that a log called by a custom database driver returns proper caller.
@covers ::findCaller
@dataProvider providerContribDriverLog
Parameters
string $driver_namespace: The driver namespace to be tested.
string $stack: A test debug_backtrace stack.
array $expected_entry: The expected stack entry.
File
- core/
tests/ Drupal/ KernelTests/ Core/ Database/ LoggingTest.php, line 158
Class
- LoggingTest
- Tests the query logging facility.
Namespace
Drupal\KernelTests\Core\DatabaseCode
public function testContribDriverLog($driver_namespace, $stack, array $expected_entry) {
$mock_builder = $this
->getMockBuilder(Log::class);
$log = $mock_builder
->onlyMethods([
'getDebugBacktrace',
])
->setConstructorArgs([
'test',
])
->getMock();
$log
->expects($this
->once())
->method('getDebugBacktrace')
->will($this
->returnValue($stack));
Database::addConnectionInfo('test', 'default', [
'driver' => 'mysql',
'namespace' => $driver_namespace,
]);
$result = $log
->findCaller($stack);
$this
->assertEquals($expected_entry, $result);
}