I've run into a puzzling error when I try to run my global PHPUnit in a project.
My system-wide PHPUnit is version 7.2.6 and my PHP version is 7.2.7.
Here is the error that I get:
PHPUnit 7.2.6 by Sebastian Bergmann and contributors.
PHP Fatal error: Uncaught Error: Call to undefined method PHPUnit\Util\Configuration::hasValidationErrors() in /Users/ronald/Sites/painting/vendor/phpunit/phpunit/src/TextUI/TestRunner.php:337
Stack trace:
#0 /Users/ronald/.composer/vendor/phpunit/phpunit/src/TextUI/Command.php(198): PHPUnit\TextUI\TestRunner->doRun(Object(PHPUnit\Framework\TestSuite), Array, true)
#1 /Users/ronald/.composer/vendor/phpunit/phpunit/src/TextUI/Command.php(151): PHPUnit\TextUI\Command->run(Array, true)
#2 /Users/ronald/.composer/vendor/phpunit/phpunit/phpunit(53): PHPUnit\TextUI\Command::main()
#3 {main}
thrown in /Users/ronald/Sites/painting/vendor/phpunit/phpunit/src/TextUI/TestRunner.php on line 337
Fatal error: Uncaught Error: Call to undefined method PHPUnit\Util\Configuration::hasValidationErrors() in /Users/ronald/Sites/painting/vendor/phpunit/phpunit/src/TextUI/TestRunner.php on line 337
Error: Call to undefined method PHPUnit\Util\Configuration::hasValidationErrors() in /Users/ronald/Sites/painting/vendor/phpunit/phpunit/src/TextUI/TestRunner.php on line 337
Call Stack:
0.0026 395856 1. {main}() /Users/ronald/.composer/vendor/phpunit/phpunit/phpunit:0
0.0512 1935008 2. PHPUnit\TextUI\Command::main() /Users/ronald/.composer/vendor/phpunit/phpunit/phpunit:53
0.0512 1935120 3. PHPUnit\TextUI\Command->run() /Users/ronald/.composer/vendor/phpunit/phpunit/src/TextUI/Command.php:151
0.0960 5578520 4. PHPUnit\TextUI\TestRunner->doRun() /Users/ronald/.composer/vendor/phpunit/phpunit/src/TextUI/Command.php:198
The funny thing is that it works when I run vendor/bin/phpunit but not the global PHPUnit. I can run the global version in any of my projects and it works just fine, so I'm not sure what the problem is.
Lastly, here is my phpunit.xml file.
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
<testsuites>
<testsuite name="Feature">
<directory suffix="Test.php">./tests/Feature</directory>
</testsuite>
<testsuite name="Unit">
<directory suffix="Test.php">./tests/Unit</directory>
</testsuite>
</testsuites>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./app</directory>
</whitelist>
</filter>
<php>
<env name="APP_ENV" value="testing"/>
<env name="CACHE_DRIVER" value="array"/>
<env name="SESSION_DRIVER" value="array"/>
<env name="QUEUE_DRIVER" value="sync"/>
<env name="MAIL_DRIVER" value="array"/>
<env name="DB_CONNECTION" value="sqlite_testing" />
</php>
</phpunit>
/Users/ronald/.composer/vendor/phpunit/(global) in you stack trace, but the error occurs in/Users/ronald/Sites/painting/vendor/phpunit/phpunit/src/TextUI/TestRunner.php(local)