yifei3212
yifei3212

Reputation: 851

How to upgrade symfony/phpunit-bridge to use PHPUnit 7?

I'm using Symfony 4.2 with test-pack which includes symfony/phpunit-bridge 4.2.

The default version of PHPUnit is 6.5, but I want to upgrade it to 7.5.

On the Symfony PHPUnit Bridger doc, it says:

Set the SYMFONY_PHPUNIT_VERSION env var to e.g. 5.5 to change the base version of PHPUnit to 5.5 instead of the default 5.3.

It's also possible to set this env var in the phpunit.xml.dist file.

I tried three ways:

  1. Set SYMFONY_PHPUNIT_VERSION in the phpunit.xml/phpunit.xml.dist file in the project root folder.
  2. Set SYMFONY_PHPUNIT_VERSION in .env.test file.
  3. Set SYMFONY_PHPUNIT_VERSION to 7.5 in the /bin/phpunit file.

And then, I removed the /bin/.phpunit folder and ran /bin/phpunit command to reinstall the PHPUnit.

Only the 3rd way worked on upgrading the PHPUnit version.

What have I done wrong here?

Where is the best place to set SYMFONY_PHPUNIT_VERSION?

Upvotes: 3

Views: 2812

Answers (1)

Michael Petri
Michael Petri

Reputation: 221

I had the same problem and stumbled across your post, thanks for your hint with this env var.

In my case, I put the SYMFONY_PHPUNIT_VERSION into my docker-compose.yml to my container environment definition. It was not necessary to delete the bin/.phpunit folder because re-running bin/phpunit takes care that the required version is installed.

If you don't use docker you could could try this:

SYMFONY_PHPUNIT_VERSION=7.5 bin/phpunit

or

export SYMFONY_PHPUNIT_VERSION=7.5
bin/phpunit

Upvotes: 3

Related Questions