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.

Issue fork token-3040520

Command icon 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:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

pfrenssen created an issue. See original summary.

pfrenssen’s picture

Status: Active » Needs review
FileSize
5.14 KB
amarphule’s picture

#2 Patch works for me on D8.6.15, php-7.3, mysql-5.7.

idebr’s picture

FileSize
9.61 KB
Berdir’s picture

idebr’s picture

Status: Needs work » Needs review
FileSize
504 bytes
10.1 KB

#5 Updated \Drupal\Tests\token\Functional\TokenMenuUiContentModerationTest as well

idebr’s picture

Title: Make all $modules properties protected in tests » [PP-1] Make all $modules properties protected in tests
Issue summary: View changes
Status: Needs review » Postponed
Related issues: +#2822382: Make every $modules property protected on classes extending BrowserTestBase and KernelTestBase
jibran’s picture

Title: [PP-1] Make all $modules properties protected in tests » Make all $modules properties protected in tests
Status: Postponed » Active
ngkoutsaik’s picture

Assigned: Unassigned » ngkoutsaik
ngkoutsaik’s picture

Hi,

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.

ngkoutsaik’s picture

Assigned: ngkoutsaik » Unassigned
Status: Active » Needs review

Matroskeen made their first commit to this issue’s fork.

Matroskeen’s picture

Status: Needs review » Reviewed & tested by the community

First 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.

TR’s picture

D8 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.

Berdir’s picture

Status: Reviewed & tested by the community » Needs work

Agreed, 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.

beatrizrodrigues’s picture

Assigned: Unassigned » beatrizrodrigues

I'll work on changing the left tests with occurrence of public visibility and I will also update the info.yml file as @Berdir suggested.

beatrizrodrigues’s picture

Assigned: beatrizrodrigues » Unassigned
Status: Needs work » Needs review

I 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.

TR’s picture

All of these protected static $modules declarations should use the same documentation comment:

  /**
   * {@inheritdoc}
   */

Right now, most of them don't, and what they use is a combination of various custom comments.

lucienchalom’s picture

Status: Needs review » Needs work

I 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

beatrizrodrigues’s picture

Assigned: Unassigned » beatrizrodrigues

Will work on that

beatrizrodrigues’s picture

Assigned: beatrizrodrigues » Unassigned
Status: Needs work » Needs review

You 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.

TR’s picture

Status: Needs review » Reviewed & tested by the community

The 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.

danflanagan8’s picture

Priority: Minor » Normal

Big +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.

  • Berdir committed 1d1b2f7 on 8.x-1.x authored by Matroskeen
    Issue #3040520 by beatrizrodrigues, Matroskeen, idebr, pfrenssen,...
Berdir’s picture

Status: Reviewed & tested by the community » Fixed

Merged, thanks.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.