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

Serhii Shliakhov
  • 2,631
  • 3
  • 19
  • 37

1 Answers1

0

You can use getActiveTheme and setActiveTheme

// 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);

may be this should help.

Hardik Satasiya
  • 9,547
  • 3
  • 22
  • 40