function LoggingTest::providerContribDriverLog

Same name and namespace in other branches
  1. 10 core/tests/Drupal/KernelTests/Core/Database/LoggingTest.php \Drupal\KernelTests\Core\Database\LoggingTest::providerContribDriverLog()

Provides data for the testContribDriverLog test.

Return value

array[] A associative array of simple arrays, each having the following elements:

  • the contrib driver PHP namespace
  • a test debug_backtrace stack
  • the stack entry expected to be returned.

See also

::testContribDriverLog()

File

core/tests/Drupal/KernelTests/Core/Database/LoggingTest.php, line 184

Class

LoggingTest
Tests the query logging facility.

Namespace

Drupal\KernelTests\Core\Database

Code

public function providerContribDriverLog() {
    $stack = [
        [
            'file' => '/var/www/core/lib/Drupal/Core/Database/Log.php',
            'line' => 125,
            'function' => 'findCaller',
            'class' => 'Drupal\\Core\\Database\\Log',
            'object' => 'test',
            'type' => '->',
            'args' => [
                0 => 'test',
            ],
        ],
        [
            'file' => '/var/www/libraries/drudbal/lib/Statement.php',
            'line' => 264,
            'function' => 'log',
            'class' => 'Drupal\\Core\\Database\\Log',
            'object' => 'test',
            'type' => '->',
            'args' => [
                0 => 'test',
            ],
        ],
        [
            'file' => '/var/www/libraries/drudbal/lib/Connection.php',
            'line' => 213,
            'function' => 'execute',
            'class' => 'Drupal\\Driver\\Database\\dbal\\Statement',
            'object' => 'test',
            'type' => '->',
            'args' => [
                0 => 'test',
            ],
        ],
        [
            'file' => '/var/www/core/tests/Drupal/KernelTests/Core/Database/LoggingTest.php',
            'line' => 23,
            'function' => 'query',
            'class' => 'Drupal\\Driver\\Database\\dbal\\Connection',
            'object' => 'test',
            'type' => '->',
            'args' => [
                0 => 'test',
            ],
        ],
        [
            'file' => '/var/www/vendor/phpunit/phpunit/src/Framework/TestCase.php',
            'line' => 1154,
            'function' => 'testEnableLogging',
            'class' => 'Drupal\\KernelTests\\Core\\Database\\LoggingTest',
            'object' => 'test',
            'type' => '->',
            'args' => [
                0 => 'test',
            ],
        ],
        [
            'file' => '/var/www/vendor/phpunit/phpunit/src/Framework/TestCase.php',
            'line' => 842,
            'function' => 'runTest',
            'class' => 'PHPUnit\\Framework\\TestCase',
            'object' => 'test',
            'type' => '->',
            'args' => [
                0 => 'test',
            ],
        ],
        [
            'file' => '/var/www/vendor/phpunit/phpunit/src/Framework/TestResult.php',
            'line' => 693,
            'function' => 'runBare',
            'class' => 'PHPUnit\\Framework\\TestCase',
            'object' => 'test',
            'type' => '->',
            'args' => [
                0 => 'test',
            ],
        ],
        [
            'file' => '/var/www/vendor/phpunit/phpunit/src/Framework/TestCase.php',
            'line' => 796,
            'function' => 'run',
            'class' => 'PHPUnit\\Framework\\TestResult',
            'object' => 'test',
            'type' => '->',
            'args' => [
                0 => 'test',
            ],
        ],
        [
            'file' => 'Standard input code',
            'line' => 57,
            'function' => 'run',
            'class' => 'PHPUnit\\Framework\\TestCase',
            'object' => 'test',
            'type' => '->',
            'args' => [
                0 => 'test',
            ],
        ],
        [
            'file' => 'Standard input code',
            'line' => 111,
            'function' => '__phpunit_run_isolated_test',
            'args' => [
                0 => 'test',
            ],
        ],
    ];
    return [
        // Test that if the driver namespace is in the stack trace, the first
        // non-database entry is returned.
'contrib driver namespace' => [
            'Drupal\\Driver\\Database\\dbal',
            $stack,
            [
                'class' => 'Drupal\\KernelTests\\Core\\Database\\LoggingTest',
                'function' => 'testEnableLogging',
                'file' => '/var/www/core/tests/Drupal/KernelTests/Core/Database/LoggingTest.php',
                'line' => 23,
                'type' => '->',
                'args' => [
                    0 => 'test',
                ],
            ],
        ],
        // Extreme case, should not happen at normal runtime - if the driver
        // namespace is not in the stack trace, the first entry to a method
        // in core database namespace is returned.
'missing driver namespace' => [
            'Drupal\\Driver\\Database\\fake',
            $stack,
            [
                'class' => 'Drupal\\Driver\\Database\\dbal\\Statement',
                'function' => 'execute',
                'file' => '/var/www/libraries/drudbal/lib/Statement.php',
                'line' => 264,
                'type' => '->',
                'args' => [
                    0 => 'test',
                ],
            ],
        ],
    ];
}

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