|
5 | 5 | namespace Doctrine\DBAL\Tests\Driver\AbstractOracleDriver; |
6 | 6 |
|
7 | 7 | use Doctrine\DBAL\Driver\AbstractOracleDriver\EasyConnectString; |
| 8 | +use Doctrine\Deprecations\PHPUnit\VerifyDeprecations; |
8 | 9 | use PHPUnit\Framework\Attributes\DataProvider; |
9 | 10 | use PHPUnit\Framework\TestCase; |
10 | 11 |
|
11 | 12 | class EasyConnectStringTest extends TestCase |
12 | 13 | { |
| 14 | + use VerifyDeprecations; |
| 15 | + |
13 | 16 | /** @param mixed[] $params */ |
14 | 17 | #[DataProvider('connectionParametersProvider')] |
15 | 18 | public function testFromConnectionParameters(array $params, string $expected): void |
@@ -70,4 +73,49 @@ public static function connectionParametersProvider(): iterable |
70 | 73 | ], |
71 | 74 | ]; |
72 | 75 | } |
| 76 | + |
| 77 | + /** @param array<string, mixed> $parameters */ |
| 78 | + #[DataProvider('getConnectionParameters')] |
| 79 | + public function testParameterDeprecation( |
| 80 | + array $parameters, |
| 81 | + string $expectedConnectString, |
| 82 | + bool $expectDeprecation, |
| 83 | + ): void { |
| 84 | + if ($expectDeprecation) { |
| 85 | + $this->expectDeprecationWithIdentifier('https://github.com/doctrine/dbal/pull/7239'); |
| 86 | + } else { |
| 87 | + $this->expectNoDeprecationWithIdentifier('https://github.com/doctrine/dbal/pull/7239'); |
| 88 | + } |
| 89 | + |
| 90 | + $string = EasyConnectString::fromConnectionParameters($parameters); |
| 91 | + |
| 92 | + self::assertSame($expectedConnectString, (string) $string); |
| 93 | + } |
| 94 | + |
| 95 | + /** @return iterable<string, array{array<string, mixed>, string, bool}> */ |
| 96 | + public static function getConnectionParameters(): iterable |
| 97 | + { |
| 98 | + $sidString = '(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521))' |
| 99 | + . '(CONNECT_DATA=(SID=BILLING)))'; |
| 100 | + |
| 101 | + yield 'dbname' => [ |
| 102 | + [ |
| 103 | + 'host' => 'localhost', |
| 104 | + 'port' => 1521, |
| 105 | + 'dbname' => 'BILLING', |
| 106 | + ], |
| 107 | + $sidString, |
| 108 | + true, |
| 109 | + ]; |
| 110 | + |
| 111 | + yield 'sid' => [ |
| 112 | + [ |
| 113 | + 'host' => 'localhost', |
| 114 | + 'port' => 1521, |
| 115 | + 'sid' => 'BILLING', |
| 116 | + ], |
| 117 | + $sidString, |
| 118 | + false, |
| 119 | + ]; |
| 120 | + } |
73 | 121 | } |
0 commit comments