Closed (fixed)
Project:
Drupal core
Version:
8.0.x-dev
Component:
phpunit
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
19 May 2014 at 15:13 UTC
Updated:
12 Sep 2014 at 06:50 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
jhedstromThis no longer completely applies.
Comment #2
sunDRUPAL_ROOT should not have been added to the PHPUnit bootstrap.php.
I don't understand why it was added, and even added to a section that clearly states that constants should be removed...?
The globally defined constants are tampering the environment of all tests, which is bad.
Comment #3
neclimdulI agree, you should be concerned. But we already do that because we don't force phpUnit tests to run tests in process isolation, we just do it in the tests files. Technically that's worse because it means we can accidentally rely on run order for tests to work. This just puts it up front and consistent.
Comment #4
alansaviolobo commentedComment #5
neclimdulComment #6
dawehnerDo we have a @TODO/issue to remove this globalness, for example in the phpunit bootstrap?
I guess this could be moved to \Drupal without any problems? Not sure about early installer though, tbh.
Comment #7
sunDue to recent work on PHPUnit, I now agree with this change/cleanup. I don't see a way around avoiding
DRUPAL_ROOTin the phpunit bootstrap.php either.In fact, meanwhile I believe that an
APP_ROOTconstant like this should actually be supplied universally, centrally, and standardized by Composer's autoloader (which deals with many similar band-aid material like PHP INI settings anyway already). The constant is not really Drupal-specific; it simply points to the base/root directory of the application. I'll try to create an issue for that.That said, note that there are some unit tests in HEAD that try to avoid
DRUPAL_ROOTand thus use excessive relative directory name traversals à ladirname(dirname(dirname(__DIR__)))or__DIR__ . '/../../../../'to locate test fixtures. Would be great to adjust those accordingly here?Comment #8
dawehnerInstead of using DRUPAL_ROOT we should now use $container->getParameter('app.root'), so we no longer need this workaround.
This is really just a start for now.
Comment #9
sun@dawehner: Please note the issue title - this issue is about phpunit tests only. There is no container in unit tests.
Can you create a separate issue for #8? (the proposal is questionable, but not to be discussed here)
Comment #11
dawehnerOkay.
Comment #12
sunRe-rolled against HEAD. No change, so RTBC.
Comment #13
sunCorrecting slightly misleading issue title.
Comment #14
webchickCommitted and pushed to 8.x. Thanks!