Skip to content

Commit da459d7

Browse files
bug #34305 [PhpUnitBridge] Read configuration CLI directive (ro0NL)
This PR was merged into the 4.3 branch. Discussion ---------- [PhpUnitBridge] Read configuration CLI directive | Q | A | ------------- | --- | Branch? | 4.3 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #34300 | License | MIT | Doc PR | symfony/symfony-docs#... <!-- required for new features --> Commits ------- 22931a0 [PhpUnitBridge] Read configuration CLI directive
2 parents 33731bf + 22931a0 commit da459d7

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/Symfony/Bridge/PhpUnit/bin/simple-phpunit.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,21 @@
1414

1515
error_reporting(-1);
1616

17-
$getEnvVar = function ($name, $default = false) {
17+
global $argv, $argc;
18+
$argv = isset($_SERVER['argv']) ? $_SERVER['argv'] : array();
19+
$argc = isset($_SERVER['argc']) ? $_SERVER['argc'] : 0;
20+
$getEnvVar = function ($name, $default = false) use ($argv) {
1821
if (false !== $value = getenv($name)) {
1922
return $value;
2023
}
2124

2225
static $phpunitConfig = null;
2326
if (null === $phpunitConfig) {
27+
$opt = min(array_search('-c', $opts = array_reverse($argv), true) ?: INF, array_search('--configuration', $opts, true) ?: INF);
2428
$phpunitConfigFilename = null;
25-
if (file_exists('phpunit.xml')) {
29+
if (INF !== $opt && isset($opts[$opt - 1])) {
30+
$phpunitConfigFilename = $opts[$opt - 1];
31+
} elseif (file_exists('phpunit.xml')) {
2632
$phpunitConfigFilename = 'phpunit.xml';
2733
} elseif (file_exists('phpunit.xml.dist')) {
2834
$phpunitConfigFilename = 'phpunit.xml.dist';
@@ -165,10 +171,6 @@ class SymfonyBlacklistPhpunit {}
165171

166172
}
167173

168-
global $argv, $argc;
169-
$argv = isset($_SERVER['argv']) ? $_SERVER['argv'] : array();
170-
$argc = isset($_SERVER['argc']) ? $_SERVER['argc'] : 0;
171-
172174
if ($PHPUNIT_VERSION < 8.0) {
173175
$argv = array_filter($argv, function ($v) use (&$argc) { if ('--do-not-cache-result' !== $v) return true; --$argc; return false; });
174176
} elseif (filter_var(getenv('SYMFONY_PHPUNIT_DISABLE_RESULT_CACHE'), FILTER_VALIDATE_BOOLEAN)) {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy