Skip to content

Commit

Permalink
Merge branch '3.6.x' into 4.0.x
Browse files Browse the repository at this point in the history
* 3.6.x:
  Fix test cases for URL parsing
  • Loading branch information
derrabus committed Dec 31, 2022
2 parents e987d6b + 186a3fb commit 6073b69
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions tests/DriverManagerTest.php
Expand Up @@ -21,6 +21,7 @@
use function in_array;
use function is_array;

/** @psalm-import-type Params from DriverManager */
class DriverManagerTest extends TestCase
{
use VerifyDeprecations;
Expand Down Expand Up @@ -100,6 +101,7 @@ public function testDatabaseUrlPrimaryReplica(): void
'wrapperClass' => PrimaryReadReplicaConnection::class,
];

$this->expectDeprecationWithIdentifier('https://github.com/doctrine/dbal/pull/5843');
$conn = DriverManager::getConnection($options);

$params = $conn->getParams();
Expand Down Expand Up @@ -134,6 +136,7 @@ public function testDatabaseUrlPrimaryReplica(): void

/**
* @param array<string, mixed>|false $expected
* @psalm-param Params|string $url
*
* @dataProvider databaseUrls
*/
Expand Down Expand Up @@ -161,14 +164,22 @@ public function testDatabaseUrlDeprecated(array|string $url, array|false $expect
}

/**
* @param array<string, mixed>|false $expected
* @param array<string, mixed>|string $url
* @param array<string, mixed>|false $expected
*
* @dataProvider databaseUrls
*/
public function testDatabaseUrl(array|string $url, array|false $expected): void
{
if (is_array($url)) {
if (isset($url['driverClass'])) {
self::markTestSkipped(
'Legacy test case: Merging driverClass into the parsed parameters has to be done in userland now.',
);
}

['url' => $url] = $options = $url;
unset($options['url']);
} else {
$options = [];
}
Expand All @@ -194,7 +205,11 @@ public function testDatabaseUrl(array|string $url, array|false $expected): void
}
}

/** @return array<string, list<mixed>> */
/** @psalm-return array<string, array{
* string|array<string, mixed>,
* array<string, mixed>|false,
* }>
*/
public function databaseUrls(): iterable
{
$driver = $this->createMock(Driver::class);
Expand Down

0 comments on commit 6073b69

Please sign in to comment.