Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment #1
sunI 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?
Comment #2
almaudoh CreditAttribution: almaudoh commented@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.
This fixed the test fails over at #1308152: Add stream wrappers to access extension files. Thanks.
Comment #3
sunLet's re-open #2234613: Add DrupalUnitTestBase helper methods to enable/disable themes in case anyone finds a good reason for adding such methods.