2

I'm working with Symfony 5 and I installed phpunit-bridge with the command included in the documentation : composer require --dev symfony/phpunit-bridge.

When I run phpunit with this command, php bin/phpunit, I have this error :

PHP Fatal error : Uncaught Error: Call to undefined method PHPUnit\TextUI\TestRunner::doRun()

4
  • Please share more details. Commented May 17, 2020 at 17:19
  • Ok, what kind of details? Commented May 17, 2020 at 19:09
  • 1
    Just start with anything. This is such a standard way of running PHPUnit that I can't imagine it's broken for everyone. But as you haven't shown anything (like: an environment where anybody could reproduce the problem), it's close to impossible to provide any hint Commented May 18, 2020 at 6:22
  • I'm working with Symfony 5.0 and Windows 7. I installed symfony/phpunit-bridge with this comand : composer require --dev symfony/phpunit-bridge. When I run php bin/phpunitI to install PHPUnit, I have this error :C:\cmder\roadtrip>php bin/phpunit PHP Fatal error: Uncaught Error: Call to undefined method PHPUnit\TextUI\TestRunner::doRun() in C:\cmder\roadtrip\bin\.phpunit\phpunit-7.5-0\src\TextUI\Command.php:206 Commented May 18, 2020 at 8:26

2 Answers 2

3

I'll try to guess.

You also have a bundle like liip/functional-test-bundle or other, which require PHPUnit in requirements (or even you require PHPUnit directly in your composer.json together with phpunit-bridge).

As a result you have two different version of PHPUnit installed in project, with two different api.

If installed liip/functional-test-bundle is your case and you do not want to remove it, you need to install by bridge same PHPUnit version as installed by Liip bundle dependency. You can set version through SYMFONY_PHPUNIT_VERSION env variable or directly in bin/phpunit file. Or you can redefine path to already installed PHPUnit version (in vendors/) through SYMFONY_PHPUNIT_DIR env or directly in bin/phpunit.

Note: you can not set SYMFONY_PHPUNIT_VERSION or SYMFONY_PHPUNIT_DIR through .env.* files, since bin/phpunit not read this files. So it should be real env vars.

Sign up to request clarification or add additional context in comments.

1 Comment

I many times installed and uninstalled orm-fixtures, phpunit, liip/tests and symfony/phpunit-bridge. Now, it's working. Thank you very much.
0

I had a similar issue with symfony 5.1. I tried upgrading all dev packages related to testing but it didn't work. Once I completely remove all dev (testing related) packages and reinstalling the symfony phpunit bridge package it worked. You have to remove the phpunit file inside the root/bin directory

Steps to follow

  1. Remove all dev test packages (Eg: composer remove symfony/browser-kit)
  2. Remove if there are following packages : phpunit/phpunit, symfony/phpunit-bridge, symfony/css-selector, symfony/browser-kit
  3. Install the brdge package again by running composer require --dev symfony/phpunit-bridge

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.