Skip to content

Commit

Permalink
bug #34305 [PhpUnitBridge] Read configuration CLI directive (ro0NL)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
nicolas-grekas committed Nov 28, 2019
2 parents 33731bf + 22931a0 commit da459d7
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 da459d7

Please sign in to comment.