Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
While investigating how some things where suppose to work in ModuleHandler and what things it supported I was unable to find any tests. It seems that the testing of module handler is handled by all our other tests using it but there are no explicit tests.
Still a work in progress but this has ~41% line coverage and ~80% function coverage of ModuleHandler.
Comment | File | Size | Author |
---|---|---|---|
#4 | 2252991-modulehandler-phpunit-tests-4.patch | 26.01 KB | neclimdul |
#4 | 2252991-interdiff-4.txt | 2.24 KB | neclimdul |
Comments
Comment #1
neclimdul80% coverage. I'm not sure the other code can be effectively tested in unit tests. I'm sure they can but they're going to request a lot of mocking and in some cases knowledge of code I'm not familiar with. This seems enough to get a unit test class into code.
Comment #2
neclimdulComment #3
dawehnerNice work!
Does phpunit tests run in a particular order? Can we do a !function_exists before the load call?
Should we ensure that load is called with the proper argument?
On top of that I wonder whether we could also provide a similar test as well: add a module, call reload and ensure it is loaded.
We do have a couple of tests where this constant is defined inside the test itself, so maybe open a follow up to clean this up.
Comment #4
neclimdul1) I think so but seems like a valid test. At worst it keeps us from accidentally breaking it in the future which is still good.
2) Yes and it doesn't hurt. We actually want to ensure all modules are "loaded" on second reload. @see interdiff
3) Yeah, not my favourite part of the patch. I've moved this next to the other goofy bootstrap constant. I'll open the follow up.
Comment #6
dawehnerThis is a really nice improvement and we can always extend in the future if the code is written properly.
Nice catch!
Comment #7
neclimdulFollow ups #2270323: Remove DRUPAL_ROOT constant redefinitions from unit tests #2270331: Provide DRUPAL_ROOT accessor on objects to allow better phpUnit unit tests
Comment #9
neclimdul4: 2252991-modulehandler-phpunit-tests-4.patch queued for re-testing.
Comment #10
neclimdulback to rtbc
Comment #11
alexpottHidden is no longer need for test modules. Fixed during commit.
Committed 3d5560b and pushed to 8.x. Thanks!