Postponed on #2822382: Make every $modules property protected on classes extending BrowserTestBase and KernelTestBase
The $modules
property can be used in tests to declare the modules that should be enabled in the tests. This is a protected property in Drupal 8 (ref #2814035: Make $modules property protected on BrowserTestBase and KernelTestBase), but we have a number of tests that make this property public. Let's make them all protected.
Note that in the legacy Simpletest tests this property should remain public, it should only be changed in PHPUnit based tests.
Comment | File | Size | Author |
---|---|---|---|
#10 | make_modules_protected-3040520-10.patch | 9.66 KB | ngkoutsaik |
Issue fork token-3040520
Show commands
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 #2
pfrenssenComment #3
amarphule CreditAttribution: amarphule at DevsAdda for DevsAdda commented#2 Patch works for me on D8.6.15, php-7.3, mysql-5.7.
Comment #4
idebr CreditAttribution: idebr at ezCompany commentedNew patch now that #3061605: Convert simpletest tests to phpunit/browser tests has been committed.
Comment #5
BerdirPer #3065121: Menu changes from node form leak into live site when creating draft revision
Comment #6
idebr CreditAttribution: idebr at ezCompany commented#5 Updated \Drupal\Tests\token\Functional\TokenMenuUiContentModerationTest as well
Comment #7
idebr CreditAttribution: idebr at iO commentedI guess this issue is now postponed on #2822382: Make every $modules property protected on classes extending BrowserTestBase and KernelTestBase
Comment #8
jibranComment #9
ngkoutsaik CreditAttribution: ngkoutsaik at Agiledrop - Your Trusted Drupal Teammates commentedComment #10
ngkoutsaik CreditAttribution: ngkoutsaik at Agiledrop - Your Trusted Drupal Teammates commentedHi,
Thanks for the patch. I reviewed the patch, however, it could not be applied. Rerolling also did not seem to work. It seems something did not go well with the diff.
So I went ahead and made a new patch against the latest branch. I tested this on my local machine and it applied cleanly.
Please let me know If I missed anything.
Comment #11
ngkoutsaik CreditAttribution: ngkoutsaik at Agiledrop - Your Trusted Drupal Teammates commentedComment #14
MatroskeenFirst of all, I opened a merge request so it's easier to review and commit.
Then, I noticed one more occurrence of public visibility in
\Drupal\Tests\token\Functional\TokenMenuUiContentModerationTest
and was trying to fix it in the next commit. Turns out, #2822382: Make every $modules property protected on classes extending BrowserTestBase and KernelTestBase wasn't cherry-picked into 8.9.x, so it seems we have to leave TokenMenuUiContentModerationTest as-is until we support Drupal 8. I've reverted my commit, so now the merge request is equal to the last patch...... which looks good to me, so marking as RTBC.
Comment #15
TR CreditAttribution: TR commentedD8 is end-of-life on 2 November, so at this point in time instead of a partial solution that works for D8 (along with a necessary follow-up later on) I recommend waiting a few weeks then re-rolling this to change *all* instances at once when we don't have to worry about D8 anymore.
Comment #16
BerdirAgreed, I'm OK with breaking D8 compatibility now, we do then also need to update the .info.yml to clarify that we require 9.0.
Comment #17
beatrizrodriguesI'll work on changing the left tests with occurrence of public visibility and I will also update the info.yml file as @Berdir suggested.
Comment #18
beatrizrodriguesI hope it fits. I found no other occurrences of public visibility in the module and I changed the core_version_requirement key to require Drupal 9 or newer versions.
Comment #19
TR CreditAttribution: TR commentedAll of these protected static $modules declarations should use the same documentation comment:
Right now, most of them don't, and what they use is a combination of various custom comments.
Comment #20
lucienchalom CreditAttribution: lucienchalom at CI&T commentedI found 3 public static $modules in the files:
/tests/src/Kernel/LanguageTest.php
/tests/src/Kernel/ValidateD6MigrationStateTest.php
/tests/src/Kernel/ValidateD7MigrationStateTest.php
I am not sure if those are legacy Simpletest tests?
Besides, no new CS where added, and all the $modules are documented as asked in #19.
But as we are working on these lines, may I ask for splitting these arrays when they go beyond 80 characters?
Thank you
Comment #21
beatrizrodriguesWill work on that
Comment #22
beatrizrodriguesYou were right, this was not legacy test, so I made the $modules protected there too. I also followed you suggestion and split the array. Hope it fits.
Comment #23
TR CreditAttribution: TR commentedThe patch fixes the visibility for all uses of the $modules property, as well as fixing all the documentation comments for the $modules property, as well as fixing the array wrapping coding standards for this property.
Comment #24
danflanagan8Big +1 for this. I'm working on getting a contrib module of mine ready for D10 and this issue is a blocker. I think this warrants at least Normal priority.
Comment #26
BerdirMerged, thanks.