phpunit - 警告 : "Cannot find file '/3' locally. To fix it set server name by environment variable PHP_IDE_CONFIG and restart debug session."

标签 phpunit phpstorm xdebug

每次我在使用调试进行单元测试时单步进入该方法 (prepareStatusFilterQuery()) 时,我都会收到警告,并且调试器不会单步进入该方法。警告:

Cannot find file '/3' locally. To fix it set server name by environment variable PHP_IDE_CONFIG and restart debug session.

除此情况之外,调试器工作正常。

enter image description here

最佳答案

当您尝试单步执行模拟对象的代码时,就会发生这种情况。

没有解决方案,因为模拟对象是在测试执行期间创建的类的实例。

PHPUnit MockObjects 使用 reflectiongather information关于您要求它模拟的类(class)( the namesarguments of the public methods )然后它 generates新类(扩展模拟类)的 PHP 代码和 runs it using eval() .

调试器实际上正在单步执行该方法,但 PhpStorm 无法显示源代码,因为没有源代码。继续使用“Step Into”命令,在某个时刻,控件将返回到(PHPUnit 的)代码,其源代码是从文件加载的,PhpStorm 可以找到它。

关于phpunit - 警告 : "Cannot find file '/3' locally. To fix it set server name by environment variable PHP_IDE_CONFIG and restart debug session.",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41163813/

相关文章:

cakephp-2.0 - 断点cakephp上的phpstorm xdebug eval fatal error

php - 调试不启动

java - PhpStorm 中的数据库连接导致 java.rmi.ConnectException : Connection refused to host: 127. 0.0.1

postgresql - 通过 PhpStorm 连接到 PostgreSQL

php - 如何在 WSL 上使用 Xdebug + PhpStorm 调试 Symfony 4?

symfony - 运行测试后如何删除/缓存 Symfony 内核的目录?

phpstorm - 键盘语言更改在 Windows 7 上的 PhpStorm 中不起作用

configuration - phpunit 默认测试目录(用于 travis 集成)

php - 在 PHPUnit 中设置白名单

php - 如何模拟 laravel 辅助函数请求