Closed (fixed)
Project:
Drupal core
Version:
11.x-dev
Component:
system.module
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
24 Apr 2019 at 06:02 UTC
Updated:
13 Aug 2025 at 01:09 UTC
Jump to comment: Most recent
Comments
Comment #2
claudiu.cristeaComment #3
larowlanNote we could move the bulk of these into
\Drupal\Tests\Component\Version\ConstraintTest::providerIsCompatibleComment #14
mstrelan commentedThis was originally added 11 years ago in #211747: Allow specifying version information as part of module dependencies. I approached this first by doing the least possible to convert from a Functional test to a Kernel test.
Before
Time: 00:44.311, Memory: 12.00 MB
After:
Time: 00:00.909, Memory: 12.00 MB
Before refactoring further I wonder if it's worth just committing this for the massive speed boost and then discussing the following.
I think started investigating how it works and wish I had never seen this. The test has an array of dependency strings. Every odd numbered dependency is valid and every even numbered dependency is invalid. This is stored in state. There is a hook
\Drupal\system_test\Hook\SystemTestHooks::systemInfoAlterthat shifts the first constraint off the list and alters the info for themodule_testmodule. The test then loops through the dependency strings, loads the modules form which invokes the hook, and checks if the checkbox to enable module_test is disabled or not.So I began to wonder what it is we're actually trying to test. Is this the syntax of the version strings? Is it that the checkbox is disabled for incompatible modules? In #3 @larowlan mentioned we could probably just add most of these to
\Drupal\Tests\Component\Version\ConstraintTest::providerIsCompatible. But when I stepped through the code it seems it might be more appropriate to expand\Drupal\Tests\Core\Extension\DependencyTest::testIsCompatible. The test essentially boils down to the value of$incompatiblein this snippet:Comment #15
mstrelan commentedI also tried using a provider but it's quite a lot slower:
So I've reverted that, but made some tweaks to remove some hacks like the static variable and the array_shift. It means state is only set in the test and not also in the hook, which makes it easier to understand the even/odd logic.
Comment #16
mstrelan commentedComment #17
smustgrave commentedSeems like a good refactor to me. Still asserting that things are disabled as before. See no issue.
Comment #19
catchHad a quick look at the issue, I think it was actually added 16 years ago? Looks like the cvs commit happened in 2009.
Let's definitely open a follow-up to discuss whether we should remove the test altogether or if it can be simplified further.
Committed/pushed to 11.x, thanks!
Comment #21
mstrelan commentedYou're right, it was 16 years ago, it was the last updated date on the issue that was 11 years ago.
Follow up #3538668: Decide the fate of Drupal\Tests\system\Kernel\Module\ModulesListFormTest