function UrlConversionTest::providerGetConnectionInfoAsUrl
Same name in other branches
- 9 core/tests/Drupal/Tests/Core/Database/UrlConversionTest.php \Drupal\Tests\Core\Database\UrlConversionTest::providerGetConnectionInfoAsUrl()
- 8.9.x core/tests/Drupal/Tests/Core/Database/UrlConversionTest.php \Drupal\Tests\Core\Database\UrlConversionTest::providerGetConnectionInfoAsUrl()
- 11.x core/tests/Drupal/Tests/Core/Database/UrlConversionTest.php \Drupal\Tests\Core\Database\UrlConversionTest::providerGetConnectionInfoAsUrl()
Data provider for testGetConnectionInfoAsUrl().
Return value
array Array of arrays with the following elements:
- An array mocking the database connection info. Possible keys are database, username, password, prefix, host, port, namespace and driver.
- The expected URL after conversion.
File
-
core/
tests/ Drupal/ Tests/ Core/ Database/ UrlConversionTest.php, line 328
Class
- UrlConversionTest
- Tests for database URL to/from database connection array conversions.
Namespace
Drupal\Tests\Core\DatabaseCode
public static function providerGetConnectionInfoAsUrl() {
$info1 = [
'database' => 'test_database',
'username' => 'test_user',
'password' => 'test_pass',
'prefix' => '',
'host' => 'test_host',
'port' => '3306',
'driver' => 'mysql',
];
$expected_url1 = 'mysql://test_user:test_pass@test_host:3306/test_database?module=mysql';
$info2 = [
'database' => 'test_database',
'username' => 'test_user',
'password' => 'test_pass',
'prefix' => 'pre',
'host' => 'test_host',
'port' => '3306',
'driver' => 'mysql',
];
$expected_url2 = 'mysql://test_user:test_pass@test_host:3306/test_database?module=mysql#pre';
$info3 = [
'database' => 'test_database',
'driver' => 'sqlite',
];
$expected_url3 = 'sqlite://localhost/test_database?module=sqlite';
$info4 = [
'database' => 'test_database',
'driver' => 'sqlite',
'prefix' => 'pre',
];
$expected_url4 = 'sqlite://localhost/test_database?module=sqlite#pre';
$info5 = [
'database' => 'test_database',
'username' => 'test_user',
'password' => 'test_pass',
'prefix' => '',
'host' => 'test_host',
'port' => '3306',
'driver' => 'DrivertestMysql',
'namespace' => 'Drupal\\driver_test\\Driver\\Database\\DrivertestMysql',
'autoload' => 'core/modules/system/tests/modules/driver_test/src/Driver/Database/DrivertestMysql/',
];
$expected_url5 = 'DrivertestMysql://test_user:test_pass@test_host:3306/test_database?module=driver_test';
$info6 = [
'database' => 'test_database',
'username' => 'test_user',
'password' => 'test_pass',
'prefix' => 'pre',
'host' => 'test_host',
'port' => '3306',
'driver' => 'DrivertestMysql',
'namespace' => 'Drupal\\driver_test\\Driver\\Database\\DrivertestMysql',
'autoload' => 'core/modules/system/tests/modules/driver_test/src/Driver/Database/DrivertestMysql/',
];
$expected_url6 = 'DrivertestMysql://test_user:test_pass@test_host:3306/test_database?module=driver_test#pre';
$info7 = [
'database' => 'test_database',
'username' => 'test_user',
'password' => 'test_pass',
'prefix' => '',
'host' => 'test_host',
'port' => '5432',
'driver' => 'DrivertestPgsql',
'namespace' => 'Drupal\\driver_test\\Driver\\Database\\DrivertestPgsql',
'autoload' => 'core/modules/system/tests/modules/driver_test/src/Driver/Database/DrivertestPgsql/',
];
$expected_url7 = 'DrivertestPgsql://test_user:test_pass@test_host:5432/test_database?module=driver_test';
$info8 = [
'database' => 'test_database',
'username' => 'test_user',
'password' => 'test_pass',
'prefix' => 'pre',
'host' => 'test_host',
'port' => '5432',
'driver' => 'DrivertestPgsql',
'namespace' => 'Drupal\\driver_test\\Driver\\Database\\DrivertestPgsql',
'autoload' => 'core/modules/system/tests/modules/driver_test/src/Driver/Database/DrivertestPgsql/',
];
$expected_url8 = 'DrivertestPgsql://test_user:test_pass@test_host:5432/test_database?module=driver_test#pre';
$info9 = [
'database' => 'test_database',
'username' => 'test_user',
'password' => 'test_pass',
'prefix' => '',
'host' => 'test_host',
'port' => '3306',
'driver' => 'DrivertestMysql',
'namespace' => 'Drupal\\driver_test\\Driver\\Database\\DrivertestMysql',
'autoload' => 'core/modules/system/tests/modules/driver_test/src/Driver/Database/DrivertestMysql/',
'dependencies' => [
'mysql' => [
'namespace' => 'Drupal\\mysql',
'autoload' => 'core/modules/mysql/src/',
],
'pgsql' => [
'namespace' => 'Drupal\\pgsql',
'autoload' => 'core/modules/pgsql/src/',
],
],
];
$expected_url9 = 'DrivertestMysql://test_user:test_pass@test_host:3306/test_database?module=driver_test';
return [
[
$info1,
$expected_url1,
],
[
$info2,
$expected_url2,
],
[
$info3,
$expected_url3,
],
[
$info4,
$expected_url4,
],
[
$info5,
$expected_url5,
],
[
$info6,
$expected_url6,
],
[
$info7,
$expected_url7,
],
[
$info8,
$expected_url8,
],
[
$info9,
$expected_url9,
],
];
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.