PhpUnit 在 PhpStorm 中失败,在 Symfony 2 项目中退出代码 255 [英] PhpUnit failing in PhpStorm w/ exit code 255 in Symfony 2 project

查看:14
本文介绍了PhpUnit 在 PhpStorm 中失败,在 Symfony 2 项目中退出代码 255的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法在 PhpStorm 的 Symfony 项目中使用 phpunit - phpunit -c app 在 OSX 终端中运行良好.

I'm having trouble getting phpunit working inside of a Symfony project in PhpStorm - phpunit -c app works fine in the OSX terminal.

这里是错误:

Unable to attach test reporter to test framework of test framework quit unexpectedly
/Applications/MAMP/bin/php/php5.4.4/bin/php/private/var/folders/4l/hw8g4qlj6nnc37lfkc6hcj7w0000gn/T/ide-phpunit.php --bootstrap
/Users/greg/Repos/MyApp/app/bootstrap.php.cache --configuration    
/Users/greg/Repos/MyApp/app/phpunit.xml.dist
MyAppMyBundleTestsControllerMyControllerTest 
/Users/greg/Repos/MyApp/src/HvH/MyBundle/Tests/Controller/MyControllerTest.php

Testing started at 11:45 AM ...

Process finished with exit code 255

这是 PHP 日志中的错误:

Here is the error from the PHP log:

Fatal error: Uncaught exception 'InvalidArgumentException' with message 'The "app/" directory does not exist.' in /Users/greg/Repos/MyApp/vendor/symfony/symfony/src/Symfony/Component/Finder/Finder.php:650

推荐答案

我遇到了同样的问题,并在文档中找到了以下解决方案:http://symfony.com/doc/current/book/testing.html#您的第一个功能测试

I ran into the same issue and found the following solution in the documentation: http://symfony.com/doc/current/book/testing.html#your-first-functional-test

要运行您的功能测试,WebTestCase 类会引导你的应用程序的内核.在大多数情况下,这会自动发生.但是,如果您的内核位于非标准目录中,则需要修改您的 phpunit.xml.dist 文件以设置 KERNEL_DIR 环境变量到您的内核目录:

To run your functional tests, the WebTestCase class bootstraps the kernel of your application. In most cases, this happens automatically. However, if your kernel is in a non-standard directory, you'll need to modify your phpunit.xml.dist file to set the KERNEL_DIR environment variable to the directory of your kernel:

<phpunit>
    <!-- ... -->
    <php>
        <server name="KERNEL_DIR" value="/path/to/your/app/" />
    </php>
    <!-- ... -->
</phpunit>

因此请检查您的 phpunit.xml.dist 配置文件并尝试将绝对路径添加到您的应用程序目录.

So check your phpunit.xml.dist configuration file and try to add the absolute path to your app-directory.

希望有帮助.

这篇关于PhpUnit 在 PhpStorm 中失败,在 Symfony 2 项目中退出代码 255的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆