Defect #240
Relative paths in phpunit.xml files
| Status: | Closed | Start date: | ||
|---|---|---|---|---|
| Priority: | High | Due date: | ||
| Assignee: | % Done: | 100% |
||
| Category: | MakeGood | |||
| Target version: | - | |||
| Tags: | ||||
| Votes: | 1 (View) |
Description
I have this in my phpunit.xml file:
<?xml version="1.0" encoding="UTF-8" ?>
<phpunit bootstrap="bootstrap.php">
...
<filter>
<whitelist>
<directory>../application</directory>
<directory>../library/Abc</directory>
</whitelist>
</filter>
</phpunit>
I get this error when I run the tests:
Fatal error: Uncaught exception 'PHPUnit_Framework_Exception' with message '../application does not exist' in C:\Program Files (x86)\PHP\5.3\PEAR\PHPUnit\Util\Filter.php on line 219
PHPUnit_Framework_Exception: ../application does not exist in C:\Program Files (x86)\PHP\5.3\PEAR\PHPUnit\Util\Filter.php on line 219
Call Stack:
0.0003 333376 1. {main}() C:\Users\Glen\.eclipse\org.eclipse.platform_3.6.1_1416090908\plugins\com.piece_framework.makegood.stagehand_testrunner_1.1.0.v201011141637\resources\php\bin\phpunitrunner.php:0
0.5409 1847696 2. Stagehand_CLIController->run() C:\Users\Glen\.eclipse\org.eclipse.platform_3.6.1_1416090908\plugins\com.piece_framework.makegood.stagehand_testrunner_1.1.0.v201011141637\resources\php\bin\phpunitrunner.php:69
This runs without issue from the command line. I'm guessing PHPUnit is being executed from the wrong directory or something?
Resources
History
Updated by Atsuhiro KUBO over 2 years ago
- Category set to MakeGood
- Assignee set to Atsuhiro KUBO
- Target version set to 1.2.0
- Start date deleted (
11/14/2010)
MakeGood does not specify the current working directory explicitly. Accordingly the current working directory is set to /path/to/eclipse/plugins/com.piece_framework.makegood.stagehand_testrunner_xxx/resources/php/bin. This will cause any problems with tests which depend the current working directory.
To set the current working directory to the project root before launching will fix relative path issues.
Updated by Atsuhiro KUBO over 2 years ago
A workaround is to write chdir(PROJECT_ROOT) into the preload script. See the following example:
test/prepare.php:
... chdir(dirname(__FILE__) . '/..'); ...
Updated by Atsuhiro KUBO over 2 years ago
- Tracker changed from Defect to Feature
- Subject changed from Relative paths in phpunit.xml files to Sets the current working directory to the project root folder before running a test.
Updated by Atsuhiro KUBO over 2 years ago
- Priority changed from Normal to High
Updated by Glen Ainscow over 2 years ago
Atsuhiro,
It should be set to the directory in which the phpunit.xml file is located (in my case /tests).
Glen.
Updated by Atsuhiro KUBO over 2 years ago
- Tracker changed from Feature to Defect
- Subject changed from Sets the current working directory to the project root folder before running a test. to Relative paths in phpunit.xml files
Updated by Atsuhiro KUBO over 2 years ago
- Target version changed from 1.2.0 to 1.3.0
Updated by Atsuhiro KUBO over 2 years ago
- Status changed from New to Assigned
Updated by Atsuhiro KUBO over 2 years ago
- Status changed from Assigned to Feedback
Do you have used PHPUnit 3.4.x?
As of PHPUnit 3.5.0, all paths in a XML file are automatically converted to paths based on the absolute path of the XML file. But this behavior has not been provided by PHPUnit 3.4.x.
Additionally, the working directory for a test run is set to the directory where the launcher script exists since MakeGood does not change the working directory.
We recommend to use PHPUnit 3.5.x. But if you want to use PHPUnit 3.4.x, you can change the working directory explicitly by your preload script. And your tests will work.
Updated by Atsuhiro KUBO over 2 years ago
- Target version deleted (
1.3.0)
Updated by Atsuhiro KUBO over 2 years ago
- Status changed from Feedback to Closed
- % Done changed from 0 to 100