gpt4 book ai didi

PHPUnit未定义的方法调用

转载 作者:行者123 更新时间:2023-12-04 16:44:35 24 4
gpt4 key购买 nike

当我尝试在项目中运行我的global PHPUnit 时遇到了一个令人费解的错误。

我的系统级 PHPUnit 版本是 7.2.6,我的 PHP 版本是 7.2.7。

这是我得到的错误:

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

有趣的是,当我运行 vendor/bin/phpunit 而不是全局 PHPUnit 时,它会起作用。我可以在我的任何项目中运行全局版本并且它工作得很好,所以我不确定问题出在哪里。

最后,这是我的 phpunit.xml 文件。

<?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>

最佳答案

永远不要将全局 PHPUnit 安装与本地项目、Composer 安装的 PHPUnit 混合使用。

关于PHPUnit未定义的方法调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51264351/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com