Problem/Motivation

What is TestSetupTrait::$originalProfile for?

It is only ever set by TestBase::prepareEnvironment() before the test is run. This is presumably so that it can be restored after the test is finished. However, this never happens.

It is also used by FunctionalTestSetupTrait to populate some config for the fixture site. Currently ['conf']['simpletest.settings']['parent_profile’] (will change in #3080482: Decouple FunctionalTestSetupTrait from the simpletest module).

This config is then used to manipulate extension discovery in ExtensionDiscovery and ModuleExtensionList.

This complexity seems to only be needed to support the use case of WebTestBase tests when run from the Simpletest UI, in order to restore the original profile to the parent site’s configuration.

If we are removing the simpletest module from core, as in #3057420: [meta] How to deprecate Simpletest with minimal disruption, then we need to remove these unneeded subroutines.

If we’re keeping the simpletest module, then we need to fix the usage of this variable and figure out whether it meets all our use-cases.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

CommentFileSizeAuthor
#8 3081501_8.patch5.51 KBmile23
#7 3081501_7.patch13.74 KBmile23

Comments

Mile23 created an issue. See original summary.

mile23’s picture

Status: Active » Postponed

I'm filing this for 8.8.x, but it might well be more appropriate and easier to answer in 9.x.

Also, it's postponed on #3080482: Decouple FunctionalTestSetupTrait from the simpletest module

wim leers’s picture

I also noticed the pointlessness of $originalProfile while working on #2352949: Deprecate using Classy as the default theme for the 'testing' profile!

+1 to removing it.

mile23’s picture

catch’s picture

Status: Postponed » Active
mile23’s picture

Related issue trying to iron out why we have the install_profile setting/config.

mile23’s picture

Status: Active » Needs review
StatusFileSize
new13.74 KB

This is essentially the patch from #3080482-18: Decouple FunctionalTestSetupTrait from the simpletest module. That's comment #18. And as @alexpott says in #19:

But I'm not convinced that that is the way to go here. At the moment tests that need this kind of have two profiles (at least for searching for modules) and this would mean that now they only have one. Which means that we've changed the underlying behaviour. On the other hand, this means that the test is way more like a real installation as that can only have a single profile.

I think this is mostly right in that people think they have two profiles when they're writing the test. The thing is: They really don't. This just makes it less magical and more obvious.

mile23’s picture

StatusFileSize
new5.51 KB

Let's try that again, this time after a rebase... (After #2982680: Add composer-ready project templates to Drupal core was committed, woohoo!)

wim leers’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +Needs release manager review

I'm inclined to agree with

This just makes it less magical and more obvious.

… but this does seem like it could break some really obscure tests. So tagging for release manager review.

wim leers’s picture

Status: Reviewed & tested by the community » Needs review
Issue tags: -Needs release manager review +Needs subsystem maintainer review, +Needs change record

Actually, that was probably premature. A subsystem maintainer is more likely to be able to thoroughly and efficiently assess the impact of this change.

Also, I think this needs a change record.

Sorry, @Mile23!

alexpott’s picture

As a subsystem maintainer +1

I think this is mostly right in that people think they have two profiles when they're writing the test. The thing is: They really don't. This just makes it less magical and more obvious.

Also I disagree that we need a CR here as there is nothing for someone to change - $originalProfile is set by the system and not the test developer. If this does cause a test failure then you're probably not testing what you think you're testing. Also note core almost certainly has the most complex set of install profile tests anywhere and this change does not cause us to have to change any tests.

wim leers’s picture

See, that's exactly why I wanted a subsystem maintainer to review this — because I don't know enough about this to assess whether it's truly RTBC-worthy or not :) Thanks, @alexpott!

wim leers’s picture

Status: Needs review » Reviewed & tested by the community

Given #11 which addresses my reasons for in-RTBC'ing in #10, I'm now comfortable RTBC'ing this like I did in #9 :)

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed 4e3cc12 and pushed to 8.8.x. Thanks!

+++ b/core/lib/Drupal/Core/DrupalKernel.php
@@ -774,15 +774,6 @@ protected function moduleData($module) {
-      // If a module is within a profile directory but specifies another
-      // profile for testing, it needs to be found in the parent profile.
-      $parent_profile = Settings::get('test_parent_profile');
-      if ($parent_profile && !isset($profiles[$parent_profile])) {
-        // In case both profile directories contain the same extension, the
-        // actual profile always has precedence.
-        $profiles = [$parent_profile => $all_profiles[$parent_profile]] + $profiles;
-      }
-

<3 This makes me happy. One less way of doing super strange low-level things.

diff --git a/core/lib/Drupal/Core/Extension/ModuleExtensionList.php b/core/lib/Drupal/Core/Extension/ModuleExtensionList.php
index 71fdb4f401..60b08cc8b5 100644
--- a/core/lib/Drupal/Core/Extension/ModuleExtensionList.php
+++ b/core/lib/Drupal/Core/Extension/ModuleExtensionList.php
@@ -4,7 +4,6 @@
 
 use Drupal\Core\Cache\CacheBackendInterface;
 use Drupal\Core\Config\ConfigFactoryInterface;
-use Drupal\Core\Site\Settings;
 use Drupal\Core\State\StateInterface;
 use Drupal\Core\StringTranslation\StringTranslationTrait;
 

Removed unused use on commit.

  • alexpott committed 4e3cc12 on 8.8.x
    Issue #3081501 by Mile23, Wim Leers, alexpott: Remove TestSetupTrait::$...

Status: Fixed » Closed (fixed)

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