Skip to content

Commit 58e3ade

Browse files
Merge branch '4.3' into 4.4
* 4.3: [Validator] fix access to uninitialized property when getting value [HttpClient] Fix regex bearer [HttpKernel] Fix stale-if-error behavior, add tests Improved error message when no supported user provider is found Properly handle phpunit arguments for configuration file
2 parents 901b0c0 + e7a22bc commit 58e3ade

File tree

1 file changed

+39
-7
lines changed

1 file changed

+39
-7
lines changed

bin/simple-phpunit.php

+39-7
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,47 @@
2424

2525
static $phpunitConfig = null;
2626
if (null === $phpunitConfig) {
27-
$opt = min(array_search('-c', $opts = array_reverse($argv), true) ?: INF, array_search('--configuration', $opts, true) ?: INF);
2827
$phpunitConfigFilename = null;
29-
if (INF !== $opt && isset($opts[$opt - 1])) {
30-
$phpunitConfigFilename = $opts[$opt - 1];
31-
} elseif (file_exists('phpunit.xml')) {
32-
$phpunitConfigFilename = 'phpunit.xml';
33-
} elseif (file_exists('phpunit.xml.dist')) {
34-
$phpunitConfigFilename = 'phpunit.xml.dist';
28+
$getPhpUnitConfig = function ($probableConfig) use (&$getPhpUnitConfig) {
29+
if (!$probableConfig) {
30+
return null;
31+
}
32+
if (is_dir($probableConfig)) {
33+
return $getPhpUnitConfig($probableConfig.DIRECTORY_SEPARATOR.'phpunit.xml');
34+
}
35+
36+
if (file_exists($probableConfig)) {
37+
return $probableConfig;
38+
}
39+
if (file_exists($probableConfig.'.dist')) {
40+
return $probableConfig.'.dist';
41+
}
42+
43+
return null;
44+
};
45+
46+
foreach ($argv as $cliArgumentIndex => $cliArgument) {
47+
if ('--' === $cliArgument) {
48+
break;
49+
}
50+
// long option
51+
if ('--configuration' === $cliArgument && array_key_exists($cliArgumentIndex + 1, $argv)) {
52+
$phpunitConfigFilename = $getPhpUnitConfig($argv[$cliArgumentIndex + 1]);
53+
break;
54+
}
55+
// short option
56+
if (0 === strpos($cliArgument, '-c')) {
57+
if ('-c' === $cliArgument && array_key_exists($cliArgumentIndex + 1, $argv)) {
58+
$phpunitConfigFilename = $getPhpUnitConfig($argv[$cliArgumentIndex + 1]);
59+
} else {
60+
$phpunitConfigFilename = $getPhpUnitConfig(substr($cliArgument, 2));
61+
}
62+
break;
63+
}
3564
}
65+
66+
$phpunitConfigFilename = $phpunitConfigFilename ?: $getPhpUnitConfig('phpunit.xml');
67+
3668
if ($phpunitConfigFilename) {
3769
$phpunitConfig = new DomDocument();
3870
$phpunitConfig->load($phpunitConfigFilename);

0 commit comments

Comments
 (0)