I'm using PHPUnit Bridge in my Symfony project. I'm currently using PHPUnit 7 and I want to upgrade to PHPUnit 8.
In PHPUnit 8 array subset assertions are deprecated and generate warnings. I want to use dms/phpunit-arraysubset-asserts package to provide them. With regular PHPUnit I'd just composer require
it and call it a day.
Now, the Bridge doesn't have original PHPUnit as its dependency, instead it installs it to a temporary folder, patches it and runs from there. phpunit-arraysubset-asserts has PHPUnit dependency though and generates a warning:
Adding phpunit/phpunit as a dependency is discouraged in favor of Symfony's PHPUnit Bridge.
* Instead:
1. Remove it now: composer remove --dev phpunit/phpunit
2. Use Symfony's bridge: composer require --dev phpunit
I don't want to install phpunit/phpunit
to avoid confusion.
I've tried to ignore it by adding a *
replacement, but just adding the replacement to composer.json
produces a Composer error:
Your requirements could not be resolved to an installable set of packages.
Problem 1
- __root__ No version set (parsed as 1.0.0) conflicts with symfony/phpunit-bridge[v5.0.5].
- symfony/phpunit-bridge v5.0.5 conflicts with __root__[No version set (parsed as 1.0.0)].
- Installation request for __root__ No version set (parsed as 1.0.0) -> satisfiable by __root__[No version set (parsed as 1.0.0)].
- Installation request for symfony/phpunit-bridge v5.0.5 -> satisfiable by symfony/phpunit-bridge[v5.0.5].
What's the correct way to add a PHPUnit extension when using PHPUnit Bridge?
WARNING I do not know phpunit-bridge well (in fact today was my first day with it), but I can see the way to achieve what you want. It's not that convenient, but possible. I think it's better to either check with symfony team (maybe there is a supported way for this) or just use plain phpunit (it seems easier and it should be possible to integrate it with symfony's phpunit-bridge without relaying on bridge to install phpunit itself)
For phpunit 8, use phpunit verion 8.0 in
phpunit.xml.dist
and install your plugin like thiscomposer require --no-plugins 'dms/phpunit-arraysubset-asserts:*'
, that will work.To make it reproducible for others in your team you will need to provide composer scripts (to create dummy files and install plugin, but it should do the trick) and hook them into something like
post-install
andpost-update
events.