function UrlConversionTest::providerConvertDbUrlToConnectionInfo
Same name in other branches
- 9 core/tests/Drupal/Tests/Core/Database/UrlConversionTest.php \Drupal\Tests\Core\Database\UrlConversionTest::providerConvertDbUrlToConnectionInfo()
- 10 core/tests/Drupal/Tests/Core/Database/UrlConversionTest.php \Drupal\Tests\Core\Database\UrlConversionTest::providerConvertDbUrlToConnectionInfo()
- 11.x core/tests/Drupal/Tests/Core/Database/UrlConversionTest.php \Drupal\Tests\Core\Database\UrlConversionTest::providerConvertDbUrlToConnectionInfo()
Dataprovider for testDbUrltoConnectionConversion().
Return value
array Array of arrays with the following elements:
- root: The baseroot string, only used with sqlite drivers.
- url: The full URL string to be tested.
- database_array: An array containing the expected results.
File
-
core/
tests/ Drupal/ Tests/ Core/ Database/ UrlConversionTest.php, line 65
Class
- UrlConversionTest
- Tests for database URL to/from database connection array coversions.
Namespace
Drupal\Tests\Core\DatabaseCode
public function providerConvertDbUrlToConnectionInfo() {
return [
'MySql without prefix' => [
'',
'mysql://test_user:test_pass@test_host:3306/test_database',
[
'driver' => 'mysql',
'username' => 'test_user',
'password' => 'test_pass',
'host' => 'test_host',
'database' => 'test_database',
'port' => 3306,
'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql',
],
],
'SQLite, relative to root, without prefix' => [
'/var/www/d8',
'sqlite://localhost/test_database',
[
'driver' => 'sqlite',
'host' => 'localhost',
'database' => '/var/www/d8/test_database',
'namespace' => 'Drupal\\Core\\Database\\Driver\\sqlite',
],
],
'MySql with prefix' => [
'',
'mysql://test_user:test_pass@test_host:3306/test_database#bar',
[
'driver' => 'mysql',
'username' => 'test_user',
'password' => 'test_pass',
'host' => 'test_host',
'database' => 'test_database',
'prefix' => [
'default' => 'bar',
],
'port' => 3306,
'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql',
],
],
'SQLite, relative to root, with prefix' => [
'/var/www/d8',
'sqlite://localhost/test_database#foo',
[
'driver' => 'sqlite',
'host' => 'localhost',
'database' => '/var/www/d8/test_database',
'prefix' => [
'default' => 'foo',
],
'namespace' => 'Drupal\\Core\\Database\\Driver\\sqlite',
],
],
'SQLite, absolute path, without prefix' => [
'/var/www/d8',
'sqlite://localhost//baz/test_database',
[
'driver' => 'sqlite',
'host' => 'localhost',
'database' => '/baz/test_database',
'namespace' => 'Drupal\\Core\\Database\\Driver\\sqlite',
],
],
'MySQL contrib test driver without prefix' => [
'',
'DrivertestMysql://test_user:test_pass@test_host:3306/test_database?module=driver_test',
[
'driver' => 'DrivertestMysql',
'username' => 'test_user',
'password' => 'test_pass',
'host' => 'test_host',
'database' => 'test_database',
'port' => 3306,
'namespace' => 'Drupal\\driver_test\\Driver\\Database\\DrivertestMysql',
'autoload' => 'core/modules/system/tests/modules/driver_test/src/Driver/Database/DrivertestMysql/',
],
],
'MySQL contrib test driver with prefix' => [
'',
'DrivertestMysql://test_user:test_pass@test_host:3306/test_database?module=driver_test#bar',
[
'driver' => 'DrivertestMysql',
'username' => 'test_user',
'password' => 'test_pass',
'host' => 'test_host',
'database' => 'test_database',
'prefix' => [
'default' => 'bar',
],
'port' => 3306,
'namespace' => 'Drupal\\driver_test\\Driver\\Database\\DrivertestMysql',
'autoload' => 'core/modules/system/tests/modules/driver_test/src/Driver/Database/DrivertestMysql/',
],
],
'PostgreSQL contrib test driver without prefix' => [
'',
'DrivertestPgsql://test_user:test_pass@test_host:5432/test_database?module=driver_test',
[
'driver' => 'DrivertestPgsql',
'username' => 'test_user',
'password' => 'test_pass',
'host' => 'test_host',
'database' => 'test_database',
'port' => 5432,
'namespace' => 'Drupal\\driver_test\\Driver\\Database\\DrivertestPgsql',
'autoload' => 'core/modules/system/tests/modules/driver_test/src/Driver/Database/DrivertestPgsql/',
],
],
'PostgreSQL contrib test driver with prefix' => [
'',
'DrivertestPgsql://test_user:test_pass@test_host:5432/test_database?module=driver_test#bar',
[
'driver' => 'DrivertestPgsql',
'username' => 'test_user',
'password' => 'test_pass',
'host' => 'test_host',
'database' => 'test_database',
'prefix' => [
'default' => 'bar',
],
'port' => 5432,
'namespace' => 'Drupal\\driver_test\\Driver\\Database\\DrivertestPgsql',
'autoload' => 'core/modules/system/tests/modules/driver_test/src/Driver/Database/DrivertestPgsql/',
],
],
'MySql with a custom query parameter' => [
'',
'mysql://test_user:test_pass@test_host:3306/test_database?extra=value',
[
'driver' => 'mysql',
'username' => 'test_user',
'password' => 'test_pass',
'host' => 'test_host',
'database' => 'test_database',
'port' => 3306,
'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql',
],
],
];
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.