Closed (fixed)
Project:
PHPUnit
Version:
5.x-0.1-alpha1
Component:
Code
Priority:
Critical
Category:
Bug report
Assigned:
Reporter:
Created:
13 Mar 2009 at 05:49 UTC
Updated:
3 Jan 2014 at 00:07 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
chop commentedHere's a patch that ensures we're in the correct working directory when using the command line test runner to run a DrupalTest test case or a DrupalTest test suite.
Comment #2
chop commentedOK, again, nice response from all the hordes of PHPUnit users. I guess I'll press on talking to myself. At least it helps me keep track of what I'm doing here.
I've created a new patch addressing this issue, to replace the previous patch in Comment #1. In the new patch, I realised that the setUp and tearDown methods are run repeatedly during test execution. In tha case of the DrupalTest_TestCase::setUp and DrupalTest_TestCase::tearDown the methods are run once for each test. For DrupalTest_TestSuite::setUp and DrupalTest_TestSuite::tearDown the methods are run once for each execution of the suite. So knowing this, why are we going to check on the current working directory every time they're run.
This new patch ensures that the current working directory is checked and changed less often and only when necessary.
Apply it instead of the previous patch and post a comment with any problems or suggestions.
Comment #3
chop commentedI've tested the patch from Comment #2 - phpunit-testsuite-cwd.patch as thoroughly as I can and have found to my chagrin that it does nothing to reduce the number of calls to
chdir(). This was the goal of the changes I made in this second patch, so it is a failure in that respect. It seems that we still find ourselves moving between the working directory where the initial call to PHPUnit was made and the Drupal root path where Drupal expects you to be when executing Drupal functions, just as often as before.This is mainly because the DrupalTest_TestSuite::tearDown() and DrupalTest_TestCase::tearDown() method will always put you back where you started, which is just what we want it to do as it turns out. I cannot see a way around this. In fact, when I consider it, I don't think we need to find a way around it. I guess it is really an intended consequence of setting up the environment for the Drupal test and then returning it to normal on the completion of the test.
So, it is back to the patch from Comment #1 - phpunit-testsuite-cwd.patch I'm afraid.
Comment #4
chop commentedApplied patch to CVS after a month use locally.