1

I try running this command :

php bin/phpunit

I get this error :

PHP Fatal error: Uncaught Error: Call to undefined method PHPUnit\TextUI\TestRunner::doRun() in C:\wamp64\www\Test___Hanff_Web\bin.phpunit\phpunit-7.5-0\src\TextUI\Command.php:206

I see that it is using phpunit 7.5, but i have require phpunit 9.2 in my composer.json :

// composer.json
"require": {
        "php": "^7.4",
        ...
        "phpunit/phpunit": "^9.2",       <-- here
        "sensio/framework-extra-bundle": "^5.1",
        "spatie/enum": "^2.3",
        "symfony/asset": "^5.1",
        ...
        "symfony/framework-bundle": "5.1.*",
        ...
    },
    "require-dev": {
        "dama/doctrine-test-bundle": "^6.3",
        "doctrine/doctrine-fixtures-bundle": "^3.3",
        "symfony/browser-kit": "^5.1",
        "symfony/css-selector": "^5.1",
        "symfony/debug-pack": "^1.0",
        "symfony/phpunit-bridge": "^5.1",   <-- Also here because symfony doc told me to import that
        "symfony/stopwatch": "^5.1",
        "symfony/twig-bundle": "^5.1",
        "symfony/web-profiler-bundle": "^5.1"
    },

When i trying to execute this :

> vendor\bin\phpunit --version

PHPUnit 9.2.6 by Sebastian Bergmann and contributors.

I get version 9.2 instead of this :

> php bin/phpunit --version

PHPUnit 7.5.20 by Sebastian Bergmann and contributors.

So i try to run composer update but it don't change anything. Then i try to self update phpunit as described here but nothing do !

I'm actually only being able to run my php test by execute this command :

> vendor\bin\phpunit tests/Controller/WebTest_ArticleController.php

It execute all the tests in one TestCase file, but i can't execute all the test for all the tests/* directory.

I would like to be able to run all my test as :

> php bin/phpunit

... Runing all test

Or something like :

> vendor\bin\phpunit tests/*

... Runing all test in tests/ directory

I have also read this PHPunit Uncaught Error: Call to undefined method PHPUnit_Util_Configuration::getTestdoxGroupConfiguration() But it doesn't provide me any satisfying solution

vincent PHILIPPE
  • 975
  • 11
  • 26
  • Rename your directory vendor to vendorbkp and run `composer install` and try again. – Benilson Jul 31 '20 at 11:49
  • What have you tried to debug the problem? Why do you use two seperate versions of PHPUnit, and not just one? – Nico Haase Jul 31 '20 at 11:54
  • @NicoHaase The thing i have try are described in my question. Composer update, self update, check my composer.json, searching on the internet. As i don't find any solution, i come and ask. And i dond't know why i have got two separate versions of PHPUnit, this is exactly why i ask for it – vincent PHILIPPE Jul 31 '20 at 12:35
  • Sadly it doesn't work @Benilson as the vendor\bin\phpunit is the already up to date version. – vincent PHILIPPE Jul 31 '20 at 12:54

1 Answers1

1

You have to use vendor\bin\phpunit and name your test case in tests folder something like XXXXXXXtest.php else, phpunit would not find it.

tests/
   Controller/
      ArticleController_WebTest.php
      MenuController_WebTest.php
      SecurityController_WebTest.php
      ...
   Repository/
      ArticleRepository_KernelTest.php
      ...
   Services/
      Service_UnitTest.php
      ...
   Utils/
       Util_UnitTest.php
       ...

This is why i wasn't being able to execute all of my test just by running \vendor\bin\phpunit

vincent PHILIPPE
  • 975
  • 11
  • 26