PHPUnit 通过 Composer 和 PhpStormPHPUnit、Composer、PhpStorm

2023-09-06 15:42:40 作者:逗比逗比蹦叉叉

我现在尝试了几个小时来设置 PhpStorm 进行单元测试.无论我做什么,我都会得到这个

I'm now trying for hours to setup PhpStorm for unit testing. Whatever I do, I get this

Process finished with exit code 1
Cannot find PHPUnit in include path ...

PHPUnit 可以(通过命令行)从任何地方访问;我已经设置了正确的包含路径并将 PHPUnit 添加到外部库中.没有机会.

PHPUnit is (via command line) accessible from anywhere; I've set the correct include path and have added PHPUnit to the external libraries. No chance.

有没有可能,还是只能通过 PEAR 进行安装?我在这里解决了所有相关问题,我在 Mac 上,PHPUnit 通过 CLI 顺利运行.

Is it possible at all or does it only work with installations via PEAR? I've worked through all related questions here, am on Mac and PHPUnit is running smoothly via CLI.

推荐答案

Patrick Visma 在 上发布了解决方案http://youtrack.jetbrains.com/issue/WI-13429:

Patrick Visma posted the solution on http://youtrack.jetbrains.com/issue/WI-13429:

在 PHPStorm 中编辑 phpunit.xml 的配置,并像这样设置解释器选项:

Edit the configuration for your phpunit.xml in PHPStorm, and set the Interpreter options like this:

-d auto_prepend_file=/path/to/vendor/autoload.php