function ConnectionTest::testFindCallerFromDebugBacktrace

Same name in other branches
  1. 10 core/tests/Drupal/Tests/Core/Database/ConnectionTest.php \Drupal\Tests\Core\Database\ConnectionTest::testFindCallerFromDebugBacktrace()

Tests that the proper caller is retrieved from the backtrace.

@covers ::findCallerFromDebugBacktrace @covers ::removeDatabaseEntriesFromDebugBacktrace @covers ::getDebugBacktrace

File

core/tests/Drupal/Tests/Core/Database/ConnectionTest.php, line 672

Class

ConnectionTest
Tests the Connection class.

Namespace

Drupal\Tests\Core\Database

Code

public function testFindCallerFromDebugBacktrace() : void {
    Database::addConnectionInfo('default', 'default', [
        'driver' => 'test',
        'namespace' => 'Drupal\\Tests\\Core\\Database\\Stub',
    ]);
    $connection = new StubConnection($this->createMock(StubPDO::class), []);
    $result = $connection->findCallerFromDebugBacktrace();
    $this->assertSame([
        'file' => __FILE__,
        'line' => __LINE__ - 3,
        'function' => 'testFindCallerFromDebugBacktrace',
        'class' => 'Drupal\\Tests\\Core\\Database\\ConnectionTest',
        'type' => '->',
        'args' => [],
    ], $result);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.