[英]PHPStorm 8 + PHPUnit 4.2.6 Error
I can't make PHPUnit 4.2.6 to work with PHPStorm 8 . 我无法使PHPUnit 4.2.6与PHPStorm 8一起使用 。
PHPUnit is loaded as phar inside PHPStorm 8 settings. PHPUnit在PHPStorm 8设置中作为phar加载。
Whenever i try to run unit test in PHPStorm i get this error: 每当我尝试在PHPStorm中运行单元测试时,我都会收到此错误:
Parse error: syntax error, unexpected '}' in /private/var/folders/qh/xjz1kr297v34pl6zy70_2rl00000gn/T/ide-phpunit.php(171) : eval()'d code on line 1
Call Stack:
0.0006 344584 1. {main}() /private/var/folders/qh/xjz1kr297v34pl6zy70_2rl00000gn/T/ide-phpunit.php:0
0.0007 344880 2. IDE_PHPUnit_Loader::init() /private/var/folders/qh/xjz1kr297v34pl6zy70_2rl00000gn/T/ide-phpunit.php:194
Warning: require_once(PHPUnit/Runner/Version.php): failed to open stream: No such file or directory in /private/var/folders/qh/xjz1kr297v34pl6zy70_2rl00000gn/T/ide-phpunit.php on line 49
When i looked into "ide-phpunit.php", i found that it tries to eval invalid code, because of invalid "substr" function usage. 当我查看“ide-phpunit.php”时,我发现它试图评估无效代码,因为无效的“substr”函数用法。
So my question is, if someone managed to make PHPUnit 4.2.6 work with PHPStorm 8? 所以我的问题是,如果有人设法使PHPUnit 4.2.6与PHPStorm 8一起工作?
Here is how to "unhack" the IDE to run with phpnunit.phar (4x+) nicely on windows and linux! 这里是如何“解开”IDE与phpnunit.phar(4x +)在Windows和Linux上运行良好!
:\\Program Files (x86)\\JetBrains\\PhpStorm 8.0.3\\plugins\\php\\lib
. :\\Program Files (x86)\\JetBrains\\PhpStorm 8.0.3\\plugins\\php\\lib
。 scripts/phpunit.php
. scripts/phpunit.php
。 PHPUnit/…
require statements, so autoloader can do its job instead of using hardcoded values. PHPUnit/…
require语句,因此自动加载器可以完成其工作而不是使用硬编码值。 public static function init()
method. public static function init()
方法。 Hope this helps some of you out there. 希望这可以帮助你们中的一些人。 I will post the information to their forums as well.
我也会将这些信息发布到他们的论坛。
I got the exact same error, and fixed it like this: 我得到了完全相同的错误,并修复如下:
Installed phpunit using: composer global require phpunit/phpunit
安装phpunit使用:
composer global require phpunit/phpunit
Goto phpstorm settings: PHPUnit 转到phpstorm设置:PHPUnit
Select "Use custom autoloader" 选择“使用自定义自动加载器”
C:\\Users\\[username]\\AppData\\Roaming\\Composer\\vendor\\autoload.php
C:\\Users\\[username]\\AppData\\Roaming\\Composer\\vendor\\autoload.php
/home/[username]/.composer/vendor/autoload.php
/home/[username]/.composer/vendor/autoload.php
PhpStorm generates special temporary "wrapping" to execute the tests and get the output in the form it understands better. PhpStorm生成特殊的临时“包装”来执行测试并以更好理解的形式获得输出。 In your case it's
/private/var/folders/qh/xjz1kr297v34pl6zy70_2rl00000gn/T/ide-phpunit.php
. 在你的情况下,它是
/private/var/folders/qh/xjz1kr297v34pl6zy70_2rl00000gn/T/ide-phpunit.php
。 Since the error says there is a syntax error, the first thing you should try is deleting it, on the next run the IDE will create the new one, hopefully without that problem. 由于错误显示存在语法错误,因此首先应该尝试删除它,在下次运行时IDE将创建新的,希望没有这个问题。
If that doesn't help, as suggested in the comments, try downgrading the PHPUnit a few versions back, see if that helps. 如果这没有帮助,正如评论中所建议的那样,尝试将PHPUnit降级几个版本,看看是否有帮助。 Alternatively try reinstalling the PhpStorm.
或者尝试重新安装PhpStorm。 If that doesn't work, you have better chances of finding an answer by reporting an issue to the dev team.
如果这不起作用,您可以通过向开发团队报告问题来更好地找到答案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.