Problem/Motivation

There is no clean way to install / enable themes in a KernelTest similar to what we have for modules in the $modules array. This is making it difficult to carry out certain theme-related tests in subclasses of KernelTestBase.

Proposed resolution

Implement a $themes, enableThemes() and disableThemes() similar to existing $modules, enableModules() and disableModules() functionality.

Remaining tasks

1. A patch
2. Reviews

User interface changes

None

API changes

None

Comments

sun’s picture

I once created #2234613: Add DrupalUnitTestBase helper methods to enable/disable themes, but retracted it (see reasoning over there).

Theoretically, you can call $this->container->get('theme_handler')->enable().

What would be the benefit of dedicated methods on KTB?

almaudoh’s picture

@Sun: Initially I thought it would be good for DX to expose this functionality for themes, but reading the other issue, I think I agree with you. I'll leave this open for awhile for others to chime in.

Theoretically, you can call $this->container->get('theme_handler')->enable().

This fixed the test fails over at #1308152: Add stream wrappers to access extension files. Thanks.

sun’s picture

Status: Active » Closed (duplicate)

Let's re-open #2234613: Add DrupalUnitTestBase helper methods to enable/disable themes in case anyone finds a good reason for adding such methods.