Skip to content

Commit 147d8c4

Browse files
Merge branch '4.4' into 5.0
* 4.4: [Validator] fix access to uninitialized property when getting value [HttpClient] Fix regex bearer [Translator] Default value for 'sort' option in translation:update should be 'asc' [HttpKernel] Fix stale-if-error behavior, add tests [Intl] Provide more locale translations [Mailer] Fix STARTTLS support for Postmark and Mandrill [Messenger] Check for all serialization exceptions during message dec… [Messenger] Fix bug when using single route with XML config Fix exception message in Doctrine Messenger [DI] CheckTypeDeclarationsPass now checks if value is type of parameter type [SecurityBundle] fix security.authentication.provider.ldap_bind arguments Improved error message when no supported user provider is found Mysqli doesn't support the named parameters used by PdoAdapter Added debug argument to decide if debug page should be shown or not Mysqli doesn't support the named parameters used by PdoStore Properly handle phpunit arguments for configuration file [Mailer] add tests for http transports
2 parents 7f83594 + 58e3ade commit 147d8c4

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)