function SqlModeTest::getDatabaseConnectionInfo

Same name and namespace in other branches
  1. 10 core/modules/mysql/tests/src/Kernel/mysql/SqlModeTest.php \Drupal\Tests\mysql\Kernel\mysql\SqlModeTest::getDatabaseConnectionInfo()
  2. 11.x core/modules/mysql/tests/src/Kernel/mysql/SqlModeTest.php \Drupal\Tests\mysql\Kernel\mysql\SqlModeTest::getDatabaseConnectionInfo()

Returns the Database connection info to be used for this test.

This method only exists for tests of the Database component itself, because they require multiple database connections. Each SQLite :memory: connection creates a new/separate database in memory. A shared-memory SQLite file URI triggers PHP open_basedir/allow_url_fopen/allow_url_include restrictions. Due to that, Database tests are running against a SQLite database that is located in an actual file in the system's temporary directory.

Other tests should not override this method.

@internal

Return value

array A Database connection info array.

Overrides KernelTestBase::getDatabaseConnectionInfo

File

core/modules/mysql/tests/src/Kernel/mysql/SqlModeTest.php, line 27

Class

SqlModeTest
Tests compatibility of the MySQL driver with various sql_mode options.

Namespace

Drupal\Tests\mysql\Kernel\mysql

Code

protected function getDatabaseConnectionInfo() {
    $info = parent::getDatabaseConnectionInfo();
    // This runs during setUp(), so is not yet skipped for non MySQL databases.
    // We defer skipping the test to later in setUp(), so that that can be
    // based on databaseType() rather than 'driver', but here all we have to go
    // on is 'driver'.
    if ($info['default']['driver'] === 'mysql') {
        $info['default']['init_commands']['sql_mode'] = "SET sql_mode = ''";
    }
    return $info;
}

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