0

I'm trying to write a test for twig filter. To do that I need to load a theme from a fixture folder
plugins/matchish/myplugin/tests/fixtures/themes/test

Here how I set up the test

class TwigTest extends PluginTestCase {

    public function setUp()
    {
        parent::setUp();

        Config::set('cms.themesPath', __DIR__ . '/../fixtures/themes');
        Config::set('cms.activeTheme', 'test');
        Event::flush('cms.theme.getActiveTheme');
        Theme::resetCache();
    }
...

Now I'm getting an error active theme not found

4

1 回答 1

0

您可以使用getActiveThemesetActiveTheme

// store old code once your testing done it should return to default theme
$oldTheme = Theme::getActiveTheme();
Theme::resetCache();
Theme::setActiveTheme('<theme.code>');

// at last 
Theme::setActiveTheme($oldTheme);

可能这应该有帮助。

于 2019-04-25T09:13:56.687 回答