当我尝试在项目中运行 全局PHPUnit 时,我遇到了一个令人费解的错误。
我的系统级 PHPUnit版本是7.2.6 ,而我的 PHP版本是7.2.7。
这是我得到的错误:
vars = vars.drop_duplicates()
有趣的是,它在我运行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
时有效,但在全局PHPUnit上无效。我可以在我的任何项目中运行全局版本,并且可以正常运行,所以我不确定问题出在哪里。
最后,这是我的phpunit.xml文件。
vendor/bin/phpunit
答案 0 :(得分:1)
永远不要将全局PHPUnit安装与在本地项目,Composer安装的PHPUnit混合使用。