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

2

0

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 :-(

Otto answered 20/3, 2014 at 11:29 Comment(0)
O
0

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.

Otto answered 21/3, 2014 at 8:3 Comment(4)
This issue has been fixed: WI-21666 Will be available in nearest updates.Ribal
If I read the youtrack issue correctly this will only make IDEA compatible with v3.8. Any estimate for compliance with 4.0?Otto
You can see Fix version is EAP 136.1255 It is available for PHPStorm already. I guess for IntelliJ IDEA it will appear in the next 13.1 EAPRibal
I have a workaround, especially for people still on older versions: https://mcmap.net/q/500186/-intellij-idea-won-39-t-run-phpunit-4-0-testsIllegal
L
0

Another solution: Set

"phpunit/phpunit": "3.7"

in composer.json

and run

composer update 

Then the issue will be resolved.

Leninist answered 5/5, 2014 at 11:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.