function ConnectionTest::testFindCallerFromDebugBacktraceWithMockedBacktrace
Same name in other branches
- 10 core/tests/Drupal/Tests/Core/Database/ConnectionTest.php \Drupal\Tests\Core\Database\ConnectionTest::testFindCallerFromDebugBacktraceWithMockedBacktrace()
Tests that a log called by a custom database driver returns proper caller.
@covers ::findCallerFromDebugBacktrace @covers ::removeDatabaseEntriesFromDebugBacktrace
@dataProvider providerMockedBacktrace
@group legacy
Parameters
string $driver_namespace: The driver namespace to be tested.
array $stack: A test debug_backtrace stack.
array $expected_entry: The expected stack entry.
File
-
core/
tests/ Drupal/ Tests/ Core/ Database/ ConnectionTest.php, line 706
Class
- ConnectionTest
- Tests the Connection class.
Namespace
Drupal\Tests\Core\DatabaseCode
public function testFindCallerFromDebugBacktraceWithMockedBacktrace(string $driver_namespace, array $stack, array $expected_entry) : void {
$mock_builder = $this->getMockBuilder(StubConnection::class);
$connection = $mock_builder->onlyMethods([
'getDebugBacktrace',
'getConnectionOptions',
])
->setConstructorArgs([
$this->createMock(StubPDO::class),
[],
])
->getMock();
$connection->expects($this->once())
->method('getConnectionOptions')
->willReturn([
'driver' => 'test',
'namespace' => $driver_namespace,
]);
$connection->expects($this->once())
->method('getDebugBacktrace')
->willReturn($stack);
$result = $connection->findCallerFromDebugBacktrace();
$this->assertEquals($expected_entry, $result);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.