How to setup PHPUnit for Intellij IDEA 13.1 on Ubuntu 13.10?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-13 04:35:46

问题


I'm developing a PHP5 program using IDEA 13.1. Of course I want to cover my code using some Unit tests. I installed phpunit via aptitude and upgraded it to 4.0.11 using pear.

Somehow IDEA seems unable to detect the installed PHPUnit... The class PHPUnit_Framework_TestCase is marked as undefined. The documentation on https://www.jetbrains.com/idea/webhelp/enabling-phpunit-support.html wants me to include either the pear directory (which does not exist) or the phpunit.phar (which does not exist, either).

So far most things went smooth with IDEA so I'm surprised that something as fundamental as setting up PHPUnit does not work :-(


回答1:


Ok, after some fiddling around I got to a working solution. I downloaded phpunit-lts.phar from phpunit.de and put it directly into the project (along with the other files... meh).

Do not use the most current version (4.0 as of 21st of march 2014) of PHPUnit! Versions beyond 3.7 (or 3.8, as it seems) are not supported by IDEA or PHPStorm. You will get

PHP Fatal error:  Class IDE_PHPUnit_Framework_TestListener contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (PHPUnit_Framework_TestListener::addRiskyTest) in /tmp/ide-phpunit.php on line 504

So do yourself a favor and stick to the LTS version for now.




回答2:


Another solution: Set

"phpunit/phpunit": "3.7"

in composer.json

and run

composer update 

Then the issue will be resolved.



来源:https://stackoverflow.com/questions/22531584/how-to-setup-phpunit-for-intellij-idea-13-1-on-ubuntu-13-10

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!