From 4bb75058a34358ae8058b4e36528402d0426bac1 Mon Sep 17 00:00:00 2001 From: David CARLIER Date: Mon, 16 Oct 2023 08:04:55 +0100 Subject: [PATCH] Fix 12424 PDO_PGSQL unit test unexistent variables (#12446) * Fix 12424 PDO_PGSQL unit test unexistent variables Co-authored-by: Saki Takamachi <34942839+SakiTakamachi@users.noreply.github.com> --- ext/pdo_pgsql/tests/gh12423.phpt | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/ext/pdo_pgsql/tests/gh12423.phpt b/ext/pdo_pgsql/tests/gh12423.phpt index 2f585cb58b4..11d299af51f 100644 --- a/ext/pdo_pgsql/tests/gh12423.phpt +++ b/ext/pdo_pgsql/tests/gh12423.phpt @@ -11,14 +11,17 @@ PDOTest::skip(); [ - 'PDOTEST_DSN' => $dsnWithCredentials, - 'PDOTEST_USER' => $user, - 'PDOTEST_PASS' => $password, - ], -] = __DIR__ . '/common.phpt'; - +$dsnWithCredentials = $config['ENV']['PDOTEST_DSN']; +$user = $config['ENV']['PDOTEST_USER'] ?? null; +$password = $config['ENV']['PDOTEST_PASS'] ?? null; +if (!$user) { + preg_match('/user=(.*?) /', $dsnWithCredentials, $match); + $user = $match[1] ?? ''; +} +if (!$password) { + preg_match('/password=(.*?) /', $dsnWithCredentials, $match); + $password = $match[1] ?? ''; +} $dsn = str_replace(" user={$user} password={$password}", '', $dsnWithCredentials); echo "dsn without credentials / correct user / correct password\n";