You are here

protected function SqlModeTest::getDatabaseConnectionInfo in Drupal 9

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/tests/Drupal/KernelTests/Core/Database/SqlModeTest.php, line 36

Class

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

Namespace

Drupal\KernelTests\Core\Database

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;
}