function UrlConversionTest::providerConvertDbUrlToConnectionInfo
Same name in other branches
- 8.9.x 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()
Data provider for testDbUrlToConnectionConversion().
Return value
array Array of arrays with the following elements:
- 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 61
Class
- UrlConversionTest
- Tests for database URL to/from database connection array conversions.
Namespace
Drupal\Tests\Core\DatabaseCode
public function providerConvertDbUrlToConnectionInfo() {
$root = dirname(__FILE__, 7);
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\\mysql\\Driver\\Database\\mysql',
'autoload' => 'core/modules/mysql/src/Driver/Database/mysql/',
],
FALSE,
],
'SQLite, relative to root, without prefix' => [
'sqlite://localhost/test_database',
[
'driver' => 'sqlite',
'host' => 'localhost',
'database' => $root . '/test_database',
'namespace' => 'Drupal\\sqlite\\Driver\\Database\\sqlite',
'autoload' => 'core/modules/sqlite/src/Driver/Database/sqlite/',
],
FALSE,
],
'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' => 'bar',
'port' => 3306,
'namespace' => 'Drupal\\mysql\\Driver\\Database\\mysql',
'autoload' => 'core/modules/mysql/src/Driver/Database/mysql/',
],
FALSE,
],
'SQLite, relative to root, with prefix' => [
'sqlite://localhost/test_database#foo',
[
'driver' => 'sqlite',
'host' => 'localhost',
'database' => $root . '/test_database',
'prefix' => 'foo',
'namespace' => 'Drupal\\sqlite\\Driver\\Database\\sqlite',
'autoload' => 'core/modules/sqlite/src/Driver/Database/sqlite/',
],
FALSE,
],
'SQLite, absolute path, without prefix' => [
'sqlite://localhost//baz/test_database',
[
'driver' => 'sqlite',
'host' => 'localhost',
'database' => '/baz/test_database',
'namespace' => 'Drupal\\sqlite\\Driver\\Database\\sqlite',
'autoload' => 'core/modules/sqlite/src/Driver/Database/sqlite/',
],
FALSE,
],
'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/',
],
TRUE,
],
'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' => 'bar',
'port' => 3306,
'namespace' => 'Drupal\\driver_test\\Driver\\Database\\DrivertestMysql',
'autoload' => 'core/modules/system/tests/modules/driver_test/src/Driver/Database/DrivertestMysql/',
],
TRUE,
],
'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/',
],
TRUE,
],
'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' => 'bar',
'port' => 5432,
'namespace' => 'Drupal\\driver_test\\Driver\\Database\\DrivertestPgsql',
'autoload' => 'core/modules/system/tests/modules/driver_test/src/Driver/Database/DrivertestPgsql/',
],
TRUE,
],
'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\\mysql\\Driver\\Database\\mysql',
'autoload' => 'core/modules/mysql/src/Driver/Database/mysql/',
],
FALSE,
],
'MySql with the module name mysql' => [
'mysql://test_user:test_pass@test_host:3306/test_database?module=mysql',
[
'driver' => 'mysql',
'username' => 'test_user',
'password' => 'test_pass',
'host' => 'test_host',
'database' => 'test_database',
'port' => 3306,
'namespace' => 'Drupal\\mysql\\Driver\\Database\\mysql',
'autoload' => 'core/modules/mysql/src/Driver/Database/mysql/',
],
FALSE,
],
'PostgreSql without the module name set' => [
'pgsql://test_user:test_pass@test_host/test_database',
[
'driver' => 'pgsql',
'username' => 'test_user',
'password' => 'test_pass',
'host' => 'test_host',
'database' => 'test_database',
'namespace' => 'Drupal\\pgsql\\Driver\\Database\\pgsql',
'autoload' => 'core/modules/pgsql/src/Driver/Database/pgsql/',
],
FALSE,
],
'PostgreSql with the module name pgsql' => [
'pgsql://test_user:test_pass@test_host/test_database?module=pgsql',
[
'driver' => 'pgsql',
'username' => 'test_user',
'password' => 'test_pass',
'host' => 'test_host',
'database' => 'test_database',
'namespace' => 'Drupal\\pgsql\\Driver\\Database\\pgsql',
'autoload' => 'core/modules/pgsql/src/Driver/Database/pgsql/',
],
FALSE,
],
'SQLite, relative to root, without prefix and with the module name sqlite' => [
'sqlite://localhost/test_database?module=sqlite',
[
'driver' => 'sqlite',
'host' => 'localhost',
'database' => $root . '/test_database',
'namespace' => 'Drupal\\sqlite\\Driver\\Database\\sqlite',
'autoload' => 'core/modules/sqlite/src/Driver/Database/sqlite/',
],
FALSE,
],
];
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.