9 Replies Last post: May 17, 2011 8:06 PM by Nikolay Matveev  
Fredrik Bäckman Newbie 3 posts since
Sep 3, 2010
Currently Being Moderated

Sep 3, 2010 4:31 PM

PHPUnit path can not be resolved

Hi,

I'm getting started with PHP and PhpStorm. Running php scripts and debugging works fine for me.

But I just can't get PHPUnit to work. I've used the standard PEAR installation instructions.

(I'm using Mac Snow Leopard)

I got my PHPUnit installation in /usr/lib/php/PHPUnit.

Like the PhpStorm help suggests I've added /usr/lib/php/PEAR to as content root. But I get the error

message:

Error: (E_WARNING) require_once(PHPUnit/Framework.php): failed to open stream: No such file or directory

PHPUnit is not configured properly

when trying to generate a test class for an existing class.

So I added /usr/lib/php/PHPUnit as content root. I can see the PHPUnit/Framework.php in my project structure.

When I open it, it says

Path 'PHPUnit' not found for every "require" line.

 

I tryed adding the directories to my include_path in php.ini still no effect.

What am I doing wrong? Thanks for any help.

 

regards

Fred

Andriy Bazanov Expert 1,250 posts since
May 28, 2010
Currently Being Moderated
Sep 4, 2010 12:50 PM in response to: Fredrik Bäckman
Re: PHPUnit path can not be resolved
The help suggest just adding the PEAR directory to content root to enable PHPUnit support.

 

 

 

This is 100% correct -- by doing so you have enabled support for PHPUnit code completion and so that PhpStorm can validate / evaluate your code with its own parser.

 

However, when you run PHPUnit test within PhpStorm IDE it just creates a custom file with test instructions/configuration and then runs it in a hidden console using your default (I guess) PHP installation (it will be something like "php run_this_test.php"). This is where your "include_path" kicks in -- as it should contain the path to your PEAR installation. If it's not using default PHP installation (in case you have more than 1 on your system), then (I guess, again) it should use the one specified in "File -> Settings -> PHP".
Kirill Safonov JetBrains 396 posts since
Jul 9, 2009
Currently Being Moderated
Sep 4, 2010 6:18 PM in response to: Fredrik Bäckman
Re: PHPUnit path can not be resolved

Hello Fredrick,

 

Just to complement Andriy's explanation. When you execute PHPUnit tests or generate PHPUnit test class, PhpStorm runs a script with PHP executable taken from File | Settings | PHP | Php home setting, so you need PHPUnit installation to be added to include_path.

Actually, there's no need to add PHPUnit installation as a Content root to get it's classes resolved. Instead, once you configured include_path correctly you open File | Settings | PHP page and click 'Update include paths' button.

 

Anyway, the confusion you found should be fixed: http://youtrack.jetbrains.net/issue/WI-3035.

 

Regards,

Kirill

 

PS Thanks, Andriy!

Dimitrios Kouzis-Loukas Newbie 1 posts since
May 2, 2011
Currently Being Moderated
May 2, 2011 3:38 AM in response to: Fredrik Bäckman
Re: PHPUnit path can not be resolved
Nikolay Matveev JetBrains 674 posts since
Apr 14, 2010
Currently Being Moderated
May 3, 2011 8:07 PM in response to: Dimitrios Kouzis-Loukas
Re: PHPUnit path can not be resolved

Dimitrious,

 

Thanks for sharing!

Mauricia Ragland Newbie 2 posts since
May 14, 2011
Currently Being Moderated
May 14, 2011 12:54 PM in response to: Dimitrios Kouzis-Loukas
Re: PHPUnit path can not be resolved

I've done everything mentioned, but still get the same error in the original post.

What I find weid is that it says its looking for Framework.php, but that file doesn't exist. It's a folder.

phpStorm 2.0.1

Pear 1.9.2

Mauricia Ragland Newbie 2 posts since
May 14, 2011
Currently Being Moderated
May 14, 2011 9:11 PM in response to: Mauricia Ragland
Re: PHPUnit path can not be resolved

Okay, so to be fair I feel I must admit that the fault was all mine.  I did not have PHPUnit installed.  I was using the pear.phpunit.de channel, but was not paying close attention.  It was informing me that PHPUnit was dependent upon xml_rpc2, which I later found to be dependent upon the curl extension.

The following steps got me where I needed to be, plus those explained earlier in this post.

1. Enable the curl extension

2. pear install --alldeps pear/XML_RPC2

3. pear install --alldeps phpunit/PHPUnit

 

FYI

      -This is a WAMP server.

      -phpunit/PHPUnit is from the channel pear.phpunit.de NOT pear.phpunit.net

 

Hope this helps someone else.

Nikolay Matveev JetBrains 674 posts since
Apr 14, 2010
Currently Being Moderated
May 17, 2011 8:06 PM in response to: Mauricia Ragland
Re: PHPUnit path can not be resolved

Mauricia,  Thanks for sharing!

More Like This

  • Retrieving data ...