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.
The tests for the tracker, profile and search modules all call drupalEnableModule() directly, rather than passing the name of modules to be enabled as a parameter to parent::setUp().
Since I'm responsible for introducing this non-standard code in two of these tests, it's also my job to provide a fix, so here it is.
Comment | File | Size | Author |
---|---|---|---|
#11 | remove_drupalModuleEnable.patch | 7.62 KB | floretan |
#3 | remove_drupalModuleEnable.patch | 6.43 KB | floretan |
drupalModuleEnable_misuse.patch | 2.31 KB | floretan | |
Comments
Comment #1
boombatower CreditAttribution: boombatower commentedPatch looks good. All three tests pass before and after the patch.
The changes also make the tests more consistent and use the setUp method correctly.
Comment #2
Dries CreditAttribution: Dries commentedShould we document this 'common pattern' in the PHPdoc of drupalModuleEnable()?
I've made the same 'mistake' for some of my tests ... I didn't realize their was a pattern until I saw this issue.
Comment #3
floretan CreditAttribution: floretan commentedAfter some more investigations, I found that we don't really need drupalModuleEnable(). Here are my reasons:
DrupalWebTestCase::setUp()
doesn't even call drupalModuleEnable() to enable modules.DrupalWebTestCase::_modules
is never used outside of drupalModuleEnable/Disable(). It could go too.Here's a patch to remove drupalModuleEnable(), drupalModuleDisable() and the _module property. That should keep good developers like Dries from inadvertently using "non-standard" patterns :-)
Comment #4
Damien Tournoud CreditAttribution: Damien Tournoud commentedThat's funny, I made the exact same point in #260486: Weird 'phantom' errors after running tests, but with a slightly different rationale. I didn't even realized that
DrupalWebTestCase::setUp()
doesn't even calldrupalModuleEnable()
to enable modules.Comment #5
boombatower CreditAttribution: boombatower commentedBeen talking about this for sometime, not sure why it wasn't ever done.
Comment #6
boombatower CreditAttribution: boombatower commentedComment #7
catchI've removed drupalModuleEnable() from the documentation at http://drupal.org/node/265762 on the assumption this'll go in, and that if it doesn't for some reason, it's unlikely to remain a public API function.
Comment #8
Dries CreditAttribution: Dries commentedI applied this patch, and tried running all the SimpleTests twice. For some reason, they don't seem to complete anymore. The tests stop running, or so it seems. No SimpleTest summary was shown at the end so I suspect something crashed along the way. The last bit shown on the screen was (I'm using the command line script):
I un-applied the patch, and ran all SimpleTests twice again. Both times, the tests completed and a summary was shown.
Comment #9
catchI'm getting this: Fatal error: Call to undefined method XMLRPCValidator1Test::drupalModuleEnable() in xmlrpc.test on line 17
Running everything except XMLRPC works fine so it looks like that one's just left over.
Comment #11
floretan CreditAttribution: floretan commentedMy bad, I modified xmlrpc.test but accidentally forgot to include it in the patch.
Comment #12
catchTest all run now, so this seems fine.
Comment #13
Dries CreditAttribution: Dries commentedGreat. Committed to CVS HEAD. Thanks flobruit.
Comment #14
boombatower CreditAttribution: boombatower commentedI assume this is fixed?
Comment #15
Anonymous (not verified) CreditAttribution: Anonymous commentedAutomatically closed -- issue fixed for two weeks with no activity.