Skip to content

Commit f00800c

Browse files
authored
Merge pull request #7037 from morozov/test-util-parameters
Do not hardcode allowed parameters in TestUtil
2 parents 8ee3562 + 95ae878 commit f00800c

File tree

1 file changed

+4
-22
lines changed

1 file changed

+4
-22
lines changed

tests/TestUtil.php

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
use function implode;
2424
use function in_array;
2525
use function is_string;
26+
use function str_starts_with;
2627
use function strlen;
2728
use function strpos;
2829
use function substr;
@@ -189,31 +190,12 @@ private static function mapConnectionParameters(array $configuration, string $pr
189190
{
190191
$parameters = [];
191192

192-
foreach (
193-
[
194-
'driver',
195-
'user',
196-
'password',
197-
'host',
198-
'dbname',
199-
'memory',
200-
'port',
201-
'server',
202-
'ssl_key',
203-
'ssl_cert',
204-
'ssl_ca',
205-
'ssl_capath',
206-
'ssl_cipher',
207-
'unix_socket',
208-
'path',
209-
'charset',
210-
] as $parameter
211-
) {
212-
if (! isset($configuration[$prefix . $parameter])) {
193+
foreach ($configuration as $key => $value) {
194+
if (! str_starts_with($key, $prefix)) {
213195
continue;
214196
}
215197

216-
$parameters[$parameter] = $configuration[$prefix . $parameter];
198+
$parameters[substr($key, strlen($prefix))] = $value;
217199
}
218200

219201
foreach ($configuration as $param => $value) {

0 commit comments

Comments
 (0)