I'm getting this error on the bottom of the suite result in any project I run with phpunit.
I tested with dev-master (5.4-g7735f76) and 5.2.12.
PHP Fatal error: Uncaught Error: Call to undefined method PHPUnit_Framework_TestResult::warnings() in /home/jean/.composer/vendor/phpunit/phpunit/src/TextUI/ResultPrinter.php:297
Stack trace:
#0 /home/jean/.composer/vendor/phpunit/phpunit/src/TextUI/ResultPrinter.php(187): PHPUnit_TextUI_ResultPrinter->printWarnings(Object(PHPUnit_Framework_TestResult))
#1 /home/jean/projects/doctrine2/vendor/phpunit/phpunit/src/TextUI/TestRunner.php(446): PHPUnit_TextUI_ResultPrinter->printResult(Object(PHPUnit_Framework_TestResult))
#2 /home/jean/.composer/vendor/phpunit/phpunit/src/TextUI/Command.php(162): PHPUnit_TextUI_TestRunner->doRun(Array, true)
#3 /home/jean/.composer/vendor/phpunit/phpunit/src/TextUI/Command.php(113): PHPUnit_TextUI_Command->run(Array, true)
#4 /home/jean/.composer/vendor/phpunit/phpunit/phpunit(47): PHPUnit_TextUI_Command::main()
#5 {main}
thrown in /home/jean/.composer/vendor/phpunit/phpunit/src/TextUI/ResultPrinter.php on line 297
Fatal error: Uncaught Error: Call to undefined method PHPUnit_Framework_TestResult::warnings() in /home/jean/.composer/vendor/phpunit/phpunit/src/TextUI/ResultPrinter.php:297
Stack trace:
#0 /home/jean/.composer/vendor/phpunit/phpunit/src/TextUI/ResultPrinter.php(187): PHPUnit_TextUI_ResultPrinter->printWarnings(Object(PHPUnit_Framework_TestResult))
#1 /home/jean/projects/doctrine2/vendor/phpunit/phpunit/src/TextUI/TestRunner.php(446): PHPUnit_TextUI_ResultPrinter->printResult(Object(PHPUnit_Framework_TestResult))
#2 /home/jean/.composer/vendor/phpunit/phpunit/src/TextUI/Command.php(162): PHPUnit_TextUI_TestRunner->doRun(Array, true)
#3 /home/jean/.composer/vendor/phpunit/phpunit/src/TextUI/Command.php(113): PHPUnit_TextUI_Command->run(Array, true)
#4 /home/jean/.composer/vendor/phpunit/phpunit/phpunit(47): PHPUnit_TextUI_Command::main()
#5 {main}
thrown in /home/jean/.composer/vendor/phpunit/phpunit/src/TextUI/ResultPrinter.php on line 297
Using the phpunit's test suite I dont get this error. I wonder if it might be something related to my enviroment?
Looking at your stacktrace, it appears that you might be mixing two versions of PHPUnit, one installed at /home/jean/.composer/vendor/phpunit/phpunit and one installed at /home/jean/projects/doctrine2/vendor/phpunit/phpunit.
That is right. I removed one of them from the path and it worked correctly, thanks.
would it be advisable to not composer global require phpunit/phpunit?
PHP Fatal error: Call to undefined method PHPUnit_Framework_TestResult::warningCount() in /usr/share/php/PHPUnit/TextUI/ResultPrinter.php on line 185
Error is showing like this.Can you sove it?
Issue can happen because of mismatch between PHP and PHPUnit versions
@vjfelix between PHP and PHPUnit or between global PHPUnit and local PHPUnit?
I've tested on PHP5.6, PHP7.0, PHP7.1 and PHP7.2 without affecting the outcome.
Changing the global PHPUnit version does clear the error.
+1 for advising against global phpunit installation. I was actually searching the docs for it prior to installing - have I seen that advice, I'd at least be more careful. :)
Most helpful comment
Looking at your stacktrace, it appears that you might be mixing two versions of PHPUnit, one installed at
/home/jean/.composer/vendor/phpunit/phpunitand one installed at/home/jean/projects/doctrine2/vendor/phpunit/phpunit.