function SqlModeTest::getDatabaseConnectionInfo

Same name in this branch
  1. 11.x core/modules/mysql/tests/src/Kernel/mysql/SqlModeTest.php \Drupal\Tests\mysql\Kernel\mysql\SqlModeTest::getDatabaseConnectionInfo()
Same name and namespace in other branches
  1. 9 core/modules/mysql/tests/src/Kernel/mysql/SqlModeTest.php \Drupal\Tests\mysql\Kernel\mysql\SqlModeTest::getDatabaseConnectionInfo()
  2. 10 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/mysqli/tests/src/Kernel/mysqli/SqlModeTest.php, line 29

Class

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

Namespace

Drupal\Tests\mysqli\Kernel\mysqli

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'] === 'mysqli') {
    $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.