Can I use $ProjectFileDir$ in PHPUnit run configurations?

Hi,

In a series of projects I'm working on, the "Custom Working Directory" field in the PHPUnit Run Configuration dialogue needs to be set to the current project's root dir.

Currently, I'm setting this each time I create a new run configuration, and it varies from project to project. I've tried using $ProjectFileDir$ in this field, but it gives me an error saying it cannot be found.

Am I doing something wrong? Or is this variable not available for this field?

Thanks,

- N

3 comments
Comment actions Permalink

Hello Nils,

Currently, I'm setting this each time I create a new run configuration, and it varies from project to project.

You can configure this field once for default run configuration template in every project:

default_run_configuration.png

Also, why do you need to set up working directory to the project root?

Thank you for feedback!

0
Comment actions Permalink

Hi,

Thanks for your response.

If I omit the "Current Working Directory" pointing to the project root, includes fail to load.

My PHP include path contains '.', which I assumed would assuage this issue, however, it seems as though the PhpStorm test runner is run from the directory including my tests, rather than the project root.

e.g.

Project path: /home/projects/myProject/
Current test folder: /home/projects/myProject/Tests/Unit/ApplicationModule1/

So when I create a run configuration for "Run all tests in directory" and select the above directory, the includes fail, since the "getcwd()" is actually the test directory and not the project root.

Since I often run tests on a per-directory basis (@group annotations have not been added in this code base, and would take prohibitively long to do so) I need to set the "Custom Working Directory" for each run configuration.

This happens across multiple projects, so saving a "default" value would only slightly alleviate the issue.

What would be great is to have access to the $ProjectFileDir$ variable in this field, so that I can use that as the PHPUnit Run Configuration default.

Does that make sense? Am I missing something that would solve this issue for me?

Many thanks,

- N

0
Comment actions Permalink

Nils,

My PHP include path contains '.', which I assumed would assuage this issue

No, having '.' in include path is OK (see http://www.php.net/manual/en/ini.core.php#ini.include-path).

This happens across multiple projects, so saving a "default" value would only slightly alleviate the issue.

What would be great is to have access to the $ProjectFileDir$ variable in this field, so that I can use that as the PHPUnit Run Configuration default.

What is difference between adding $ProjectFileDir$ or the actual path to the project directory in the default run configuration? We haven't cross-project defaults anyway. You can use project icon in the path chooser to quickly select path to the project.
project_root_shortcut.png

Thank you for feedback!

0

Please sign in to leave a comment.