Needs work
Project:
Drupal core
Version:
main
Component:
extension system
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
18 Aug 2023 at 14:42 UTC
Updated:
4 Jun 2026 at 04:10 UTC
Jump to comment: Most recent
Currently there is no good place for test modules for core tests.
There are currently modules in core/tests/Drupal/Tests/Core/Extension/modules/, but this causes confusion with nested PSR-4 directories.
For now I want to use this for #3381785: Add kernel tests for hook system and #3379488: Add kernel tests for event system.
n/a
Establish core/tests/$type as the canonical place:
core/tests/modules/ for modules.
core/tests/themes/ for themes.
core/tests/profiles/ for profiles?
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
donquixote commentedI think this needs some kind of test, but not sure yet how.
We can add a proof-of-concept module and have a test to discover it.
Will this be enough? Is it necessary?
Comment #4
donquixote commentedInstead of a dedicated test, we could use the two issues I mentioned as proof-of-concept.
If these work, we know that the change is ok.
Comment #5
smustgrave commentedI love the idea! If committers agree think we should open a follow up to move the existing modules to the new directory.
Comment #6
donquixote commentedJust as a note:
Currently the modules in
core/tests/Drupal/Tests/Core/Extension/modules/, incore/tests/Drupal/Tests/Core/Database/fixtures/core/modules/and incore/tests/fixtures/are not found by ExtensionDiscovery.They are used for unit tests where we have to manually add these paths.
Moving them to a place where they are discovered _could_ have side effects that we need to watch out for.
I don't see any name clashes with test modules in core/modules/**/tests/, so I guess it will be fine.
Comment #7
xjmI think this addition should have either testing topic maintainer or FM review (tagged both, but really just one or the other would do). Thanks!
Comment #8
larowlanThis looks reasonable to me, and is consistent with how we store test modules for core modules.
I have one concern regarding the weight, specifically that we have core/modules at weight 0, ie explicitly the lowest in the priority. This is for example to allow a contrib version of a core module (e.g. CKEditor4, RDF) to take precedence over core when both exist (such as towards the end of Drupal 9).
Adding this new directory at weight 6 means it would take precedence over the other locations. I think instead it should probably be given weight -1 and added before the core directory. So that it gets the lowest precedence.
But in terms of the concept, I think this makes sense.
Is there an existing module in core/tests/Drupal/Tests/Core/Extension/modules/ we can move as part of this issue to provide implicit test coverage?
This will also need a change record and a followup to move any other existing modules.
Comment #10
nicxvan commentedComment #11
mstrelan commentedRelated #3534377: Consider moving test modules out of system module, unless they relate to system.module