Skip to content

Commit

Permalink
[PhpUnitBridge] Read configuration CLI directive
Browse files Browse the repository at this point in the history
  • Loading branch information
ro0NL authored and nicolas-grekas committed Nov 28, 2019
1 parent 06e7458 commit 22931a0
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/Symfony/Bridge/PhpUnit/bin/simple-phpunit.php
Expand Up @@ -14,15 +14,21 @@

error_reporting(-1);

$getEnvVar = function ($name, $default = false) {
global $argv, $argc;
$argv = isset($_SERVER['argv']) ? $_SERVER['argv'] : array();
$argc = isset($_SERVER['argc']) ? $_SERVER['argc'] : 0;
$getEnvVar = function ($name, $default = false) use ($argv) {
if (false !== $value = getenv($name)) {
return $value;
}

static $phpunitConfig = null;
if (null === $phpunitConfig) {
$opt = min(array_search('-c', $opts = array_reverse($argv), true) ?: INF, array_search('--configuration', $opts, true) ?: INF);
$phpunitConfigFilename = null;
if (file_exists('phpunit.xml')) {
if (INF !== $opt && isset($opts[$opt - 1])) {
$phpunitConfigFilename = $opts[$opt - 1];
} elseif (file_exists('phpunit.xml')) {
$phpunitConfigFilename = 'phpunit.xml';
} elseif (file_exists('phpunit.xml.dist')) {
$phpunitConfigFilename = 'phpunit.xml.dist';
Expand Down Expand Up @@ -165,10 +171,6 @@ class SymfonyBlacklistPhpunit {}

}

global $argv, $argc;
$argv = isset($_SERVER['argv']) ? $_SERVER['argv'] : array();
$argc = isset($_SERVER['argc']) ? $_SERVER['argc'] : 0;

if ($PHPUNIT_VERSION < 8.0) {
$argv = array_filter($argv, function ($v) use (&$argc) { if ('--do-not-cache-result' !== $v) return true; --$argc; return false; });
} elseif (filter_var(getenv('SYMFONY_PHPUNIT_DISABLE_RESULT_CACHE'), FILTER_VALIDATE_BOOLEAN)) {
Expand Down

0 comments on commit 22931a0

Please sign in to comment.