Objective

  1. Tests are able to enable $modules, but they are not able to enable $themes.

  2. Right now, explicitly enabling themes is not always required, because all themes are loaded at all times.

  3. #1067408: Themes do not have an installation status changes that entirely, requiring tests to enable themes in the same way they need to enable modules.

Proposed solution

  1. Add public static $themes = array();, using the identical logic and behavior as $modules.

  2. Adjust DUTB::installConfig(array $modules) to accept a first $type parameter.

    Alternatively, rename it to installModuleConfig() and add a new installThemeConfig().

    A $type parameter would be more in line with the underlying ConfigInstaller API + extension system though.

Notes

  1. $themes only declares the list of themes to enable. The default theme still has to be configured manually.

CommentFileSizeAuthor
#7 test.themes.7.patch5.44 KBsun
#1 test.themes.1.patch5.44 KBsun
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

sun’s picture

Status: Active » Needs review
FileSize
5.44 KB

Depends on code introduced in #1067408: Themes do not have an installation status

Also, we need to adjust DUTB::installConfig(array $modules) to either accept a first $type parameter, or rename it to installModuleConfig() + add a separate installThemeConfig(). — Adding a $type parameter would be more in line with the underlying ConfigInstaller API.

sun’s picture

Title: Add list of $themes to enable/install to DrupalUnitTestBase/WebTestBase (like $modules) » Add list of $themes to enable to DrupalUnitTestBase/WebTestBase (like $modules)

Status: Needs review » Needs work

The last submitted patch, 1: test.themes.1.patch, failed testing.

sun’s picture

Status: Needs work » Postponed
sun’s picture

sun’s picture

Issue summary: View changes
Status: Postponed » Active
sun’s picture

Status: Active » Needs review
FileSize
5.44 KB

Status: Needs review » Needs work

The last submitted patch, 7: test.themes.7.patch, failed testing.

sun’s picture

Title: Add list of $themes to enable to DrupalUnitTestBase/WebTestBase (like $modules) » Add DrupalUnitTestBase helper methods to enable/disable themes
Category: Task » Feature request
Status: Needs work » Closed (works as designed)

Thought about this for some time. I no longer think that a $themes facility is a good idea, because it would only encourage bad practices; i.e., testing against a particular theme.

The only use-case for enabling a particular theme would be tests of a theme itself. At this point, none of our themes ship with tests, and I'm not sure whether that is a good/sensible idea in the first place. Even if they would, they can use a base class for their tests.

The only aspect that remotely looks useful are the helper methods for DUTB. But even more so for DUTB, tests should not test against a particular theme, but against the default output only.

In short, it is good that this is "hard to do", because you shouldn't be doing it in the first place.

fgm’s picture

Potential use case : I just had this testing a theme negotiator which ends by asserting that the selected theme is actually enabled. This is a case where the actual theme is not used, but its existence is (via themeHandler->themeExists()).