I'm using Symfony 3.3.10
on PHP 7.0.25-0ubuntu0.16.04.1
By default this combination goes with phpunit 5.x
.
But I want to force phpunit 6.x
.
When I invoke the vendor/bin/simple-phpunit
for the first time, it installs phpunit/phpunit
version 5.7.*
as stated in the source code here:
https://github.com/symfony/phpunit-bridge/blob/v3.4.11/bin/simple-phpunit
lines 18-27:
if (PHP_VERSION_ID >= 70200) {
// PHPUnit 6 is required for PHP 7.2+
$PHPUNIT_VERSION = getenv('SYMFONY_PHPUNIT_VERSION') ?: '6.5';
} elseif (PHP_VERSION_ID >= 50600) {
// PHPUnit 4 does not support PHP 7
$PHPUNIT_VERSION = getenv('SYMFONY_PHPUNIT_VERSION') ?: '5.7';
} else {
// PHPUnit 5.1 requires PHP 5.6+
$PHPUNIT_VERSION = '4.8';
}
As my version of PHP is 7.0
it chooses phpunit version 5.7
.
I see I may "force" the bridge to go with phpunit 6.5
if I set it in the environment variable:
In a shell, I do:
rm -Rf vendor
export SYMFONY_PHPUNIT_VERSION=6.5
composer install
vendor/bin/simple-phpunit
Now I properly get: PHPUnit 6.5.8
Instead, if I logout and login again, it looses the env-var and the next invocation to vendor/bin/simple-phpunit
and it forces to install a 5.7.
I already know I could set the env-var into my bash scripts and blah, blah, blah, but this is not an acceptable solution for two reasons:
git clone
+ composer install
+ vendor/bin/simple-phpunit
and it should be properly testing with no extra, manual, steps.Is it possible to tell the project (maybe something in the composer.json
) to have some fancy setup so symfony's phpunit bridge is forced to use phpunit 6.x
(for example 6.5
) over the 5.7
version for all installs of the repo and not depending on anything global external to the repo?
Since version 4.1 you can configure this in phpunit.xml
/phpunit.xml.dist
:
<php>
<env name="SYMFONY_PHPUNIT_VERSION" value="6.5" />
</php>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With