bug #39858 Fix problem when SYMFONY_PHPUNIT_VERSION is empty string value (alexander-schranz)

This PR was squashed before being merged into the 4.4 branch.

Discussion
----------

Fix problem when SYMFONY_PHPUNIT_VERSION is empty string value

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? |
| Tickets       | Fix #... <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead -->
| License       | MIT
| Doc PR        | symfony/symfony-docs#... <!-- required for new features -->

This should fix that when `SYMFONY_PHPUNIT_VERSION` is set again on empty:

```
SYMFONY_PHPUNIT_VERSION= vendor/bin/simple-phpunit
```

it does not error with:

```bash
Creating a "phpunit/phpunit" project at "./phpunit--1"

  [UnexpectedValueException]
  Could not parse version constraint .*: Invalid version string ".*"
```

Commits
-------

72ce010c0b Fix problem when SYMFONY_PHPUNIT_VERSION is empty string value
This commit is contained in:
Fabien Potencier 2021-01-18 13:32:08 +01:00
commit 6af444607c

View File

@ -95,19 +95,19 @@ $passthruOrFail = function ($command) {
if (\PHP_VERSION_ID >= 80000) {
// PHP 8 requires PHPUnit 9.3+
$PHPUNIT_VERSION = $getEnvVar('SYMFONY_PHPUNIT_VERSION', '9.4');
$PHPUNIT_VERSION = $getEnvVar('SYMFONY_PHPUNIT_VERSION', '9.4') ?: '9.4';
} elseif (\PHP_VERSION_ID >= 70200) {
// PHPUnit 8 requires PHP 7.2+
$PHPUNIT_VERSION = $getEnvVar('SYMFONY_PHPUNIT_VERSION', '8.3');
$PHPUNIT_VERSION = $getEnvVar('SYMFONY_PHPUNIT_VERSION', '8.3') ?: '8.3';
} elseif (\PHP_VERSION_ID >= 70100) {
// PHPUnit 7 requires PHP 7.1+
$PHPUNIT_VERSION = $getEnvVar('SYMFONY_PHPUNIT_VERSION', '7.5');
$PHPUNIT_VERSION = $getEnvVar('SYMFONY_PHPUNIT_VERSION', '7.5') ?: '7.5';
} elseif (\PHP_VERSION_ID >= 70000) {
// PHPUnit 6 requires PHP 7.0+
$PHPUNIT_VERSION = $getEnvVar('SYMFONY_PHPUNIT_VERSION', '6.5');
$PHPUNIT_VERSION = $getEnvVar('SYMFONY_PHPUNIT_VERSION', '6.5') ?: '6.5';
} elseif (\PHP_VERSION_ID >= 50600) {
// PHPUnit 4 does not support PHP 7
$PHPUNIT_VERSION = $getEnvVar('SYMFONY_PHPUNIT_VERSION', '5.7');
$PHPUNIT_VERSION = $getEnvVar('SYMFONY_PHPUNIT_VERSION', '5.7') ?: '5.7';
} else {
// PHPUnit 5.1 requires PHP 5.6+
$PHPUNIT_VERSION = '4.8';