Closed (won't fix)
Project:
Drupal core
Version:
8.1.x-dev
Component:
phpunit
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
11 Jul 2014 at 22:21 UTC
Updated:
4 Jul 2016 at 17:41 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
sunComment #2
andypostnot sure route name is passed...
also '@' check_plain() is removed, are you sure that all data secure?
why this is used?
Comment #3
sunReverted change to SpecialAttributesRouteSubscriber. (@Crell raised concerns in IRC.)
Comment #4
sunFWIW, there happens to be an existing issue for the changes reverted in #3: #2051877: Log error when people use invalid route parameters
Comment #5
sun#2.2 is indeed the only difference between the current PHPUnit bootstrap.php in HEAD and TestDiscovery. Trying to dissect the situation for myself, and verbosely:
TestDiscoveryretrieves the list of available extensions fromExtensionDiscovery, which scans in the current (single) site directory only. (by default,/sites/default)The current bootstrap.php scans the
/sitesdirectory itself for site subdirectories, and includes extensions from all site directories.I'm not sure how to address that yet, and also, whether we need to address it in the first place. Running tests from all site directories may work for pure unit tests, but as soon as we're going to run web/acceptance/BDD tests via PHPUnit, Drupal core's multi-site path discovery will kick in → A module located in a site-specific directory cannot be installed in the test, because it is not found to begin with.
run-tests.shresolves that issue via the--urlcommand line option, which causes the script to create a fakeRequestfor the specified base URL, which in turn is used to discover the site-specific directory. If--urlis omitted, then/sites/defaultis used (but web tests will not work, unless Drupal is served directly onhttp://localhost).I just performed a quick test, and it appears to be possible to pass custom options to
phpunitwithout causing it to break. A value that follows a long option (e.g.,--url http://...) seems to be interpreted as the option's value and not as a separate argument to phpunit itself.So theoretically, it might be possible to re-implement the site directory negotiation for phpunit. Whether that's a good idea is a different question, of course.
Comment #6
tstoecklerMaybe not as part of this issue, but this hints to me that that class should be in \Drupal\Core.
Patch itself looks good.
Comment #7
mile23An OOP solution would be better of course. A solution that all systems could leverage would be ideal.
You mean DrupalKernel::getSitePath() of course. :-)
That is, soon this bootstrap script will require a kernel object with a container.
Which is bad.
Really \Drupal\Tests, which means SimpleTest can't get it. :-) That's one reason this script is lean and mean and functional.
Comment #8
mile23So
Drupal\Core\Extension\ExtensionDiscoveryhas reduced its dependencies, and you can (almost) inject the site path (see: #2605654: Modify Drupal\Core\Extension\ExtensionDiscovery to allow for scanning multiple file systems, enabling vfsStream testing).Here are two patches:
The small one is a POC and changes
core/tests/bootstrap.phpto useExtensionDiscovery. It will fail, becausecore/includes/bootstrap.incis a dependency ofExtensionDiscovery, and many tests make stub definitions of functions declared inbootstrap.inc, so there will be errors. Also there are failures related to the issue linked above.The large one changes many of these tests and their code in order to make some of them pass. This is a WIP. It touches a lot of code, so it might not be RC-able, but it should be. It includes the changes in #2605654: Modify Drupal\Core\Extension\ExtensionDiscovery to allow for scanning multiple file systems, enabling vfsStream testing patch #2, so a re-roll might be necessary at some point.
In my opinion this issue is a bug report, because we had false passes on a number of tests before making this change in dependencies. The best example of this is
UpdateRegistryTestwhich uses vfsStream to mock a whole Drupal filesystem. If you run the test in isolation, ExtensionDiscovery only runs once, which hides its static problems.Comment #12
mile23After #2499239: Use test suite classes to discover different test types under phpunit, allow contrib harmony with run-tests I'm calling this CWF, since the new behavior for the phpunit tool is to use
TestDiscovery::scanDirectory()to find tests per testsuite. (This issue was originally about usingTestDiscoveryinbootstrap.php.)bootstrap.phpstill uses its own functions to discover extensions, which is fine because we want to be able to testExtensionDiscoveryin isolation.As always: Re-open if you disagree.