Closed (fixed)
Project:
Drupal core
Version:
7.x-dev
Component:
simpletest.module
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
27 Jun 2014 at 11:52 UTC
Updated:
23 Jan 2020 at 08:56 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
tstoecklerHere we go.
Comment #2
sunThe discovery as well as the loading of both PSR-0 and PSR-4 at the same time could use some profiling/benchmarks.
D7 doesn't have as many tests as D8, but at the same time, D7 has a lot more module directories that need to be scanned (both for discovery and for locating/loading).
Comment #3
tstoecklerNot disagreeing, but just wanted to note that the patch builds on the existing behavior in D7. But yes, it doubles the amount of is_dir() checks on discovery and then adds one file_exists() for PSR-0 class files upon autoloading.
Also note that this only happens on test runs, not on every page request.
Comment #4
donquixote commentedI'd say we should absolutely wait with this until #2260121: PHPUnit Tests namespace of modules is ambiguous with regular runtime namespace (+ Simpletest tests) is decided.
Every API feature we add to D7 has to be maintained forever, so we should not add stuff that will soon be discarded or changed in D8.
Comment #5
donquixote commentedThis is +1 is_dir() per module, and only on test runs.
I think this is survivable.
If a module does not have a tests/src or tests/Drupal/.., then the scan will simply move on. No subdirectories will be visited, because there are none.
Comment #6
dawehnerThe patch worked fine in order to resolve the actual problem.
I'm not sure whether we really need profiling given that we cache the result anyway. A not small Drupal installation with xdebug on was not incredible slow,
when loading the simpletest UI.
Comment #7
fabianx commentedPerformance wise this should be okay,
get_all is really only called at the beginning for discovery.
Code looks good.
Comment #8
David_Rothstein commentedCommitted to 7.x - thanks!
Comment #11
donquixote commentedDid we completely fail to document this anywhere on drupal.org?
I can't find anything!
(searched for "Drupal 7 test classes PSR-4" and "Drupal 7 test classes PSR-0")
Comment #12
opdaviesThere's a reference to it on https://www.drupal.org/docs/7/testing/organizing-your-test-cases#s-where..., but no specific example that I can find.
Comment #13
opdaviesI have it working using PSR-4 with a basic custom module on a plain Drupal 7 installation (no xautoload module or any additional modules). The module is on GitHub (https://github.com/opdavies/drupal7-psr4-autoloading-test-cases) if anyone wants to see it.
This to me definitely seems like it should be documented on https://www.drupal.org/docs/7/testing/organizing-your-test-cases#s-where.... I'm happy to look into updating that page.