Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PhpStorm PhpUnit via phar autocomplete not working

I have PHPStorm 8.0.1.

PHPUnit is installed via PHAR archive like:

wget https://phar.phpunit.de/phpunit.phar
chmod +x phpunit.phar
sudo mv phpunit.phar /usr/bin/phpunit

PHPUnit works via cli:

user@pc:/usr/bin$ cd ~
user@pc:~$ phpunit --version
PHPUnit 4.3.5 by Sebastian Bergmann.

I followed the instructions from JetBrains website https://www.jetbrains.com/phpstorm/webhelp/enabling-phpunit-support.html#d298258e897

In PHPStorm File->Settings tab PHP/PHPUnit the radio button Path to phpunit.phar is checked and value is set to /usr/bin/phpunit

I have a file with a test defined like:

class MyTest extends PHPUnit_Framework_TestCase {
...

At this point PHPStorm marks Undefined class PHPUnit_Framework_TestCase

I've restarted PHPStorm and Computer, but still have the same problem.

I've also tried adding /usr/bin to include path (right click on external libraries in project view, and choose option Configure PHP include paths) without success.

Here's the config for PHPStorm Settings, tab PHP (if it matters):

PHP Language level: 5.5 (finally, generators, etc.)
Interpreter: PHP 5.5 (5.5.9-1ubuntu4.5)
Include path is empty
like image 326
YomY Avatar asked Dec 02 '14 08:12

YomY


1 Answers

In order to have a PHAR archive indexed by the IDE it has to have a .phar extension (that's a requirement).

The easiest solution is to place phpunit.phar somewhere in your project (usually it would be PROJECT_ROOT/vendor/ folder).

If having local copy inside the project folder is not desired (for whatever reason; although Composer and other similar kind of tools (bower/npm/etc) are primarily aimed at keeping dependency stuff/packages locally), you may use symbolic links:

  • either create a symbolic link to that file locally (e.g. PROJECT_ROOT/phpunit.phar --> /usr/bin/phpunit)
  • or place a full copy (or such symbolic link) in a separate folder outside of the project and then reference it via PhpStorm's Settings | PHP | Include Paths functionality.
like image 176
LazyOne Avatar answered Oct 21 '22 18:10

LazyOne