mirror of
https://github.com/wintercms/winter.git
synced 2024-06-28 05:33:29 +02:00
Fixes unit tests so they pass
This commit is contained in:
parent
d78dadafd0
commit
1c4706bbbb
@ -32,10 +32,19 @@ class Theme
|
||||
*/
|
||||
protected $configCache = null;
|
||||
|
||||
/**
|
||||
* @var mixed Active theme cache in memory
|
||||
*/
|
||||
protected static $activeThemeCache = false;
|
||||
|
||||
/**
|
||||
* @var mixed Edit theme cache in memory
|
||||
*/
|
||||
protected static $editThemeCache = false;
|
||||
|
||||
const ACTIVE_KEY = 'cms::theme.active';
|
||||
const EDIT_KEY = 'cms::theme.edit';
|
||||
|
||||
/**
|
||||
* Loads the theme.
|
||||
*/
|
||||
@ -102,12 +111,11 @@ class Theme
|
||||
if (self::$activeThemeCache !== false)
|
||||
return self::$activeThemeCache;
|
||||
|
||||
$paramKey = 'cms::theme.active';
|
||||
$activeTheme = Config::get('cms.activeTheme');
|
||||
|
||||
if (DbDongle::hasDatabase()) {
|
||||
$dbResult = Parameters::findRecord($paramKey)
|
||||
->remember(1440, $paramKey)
|
||||
$dbResult = Parameters::findRecord(self::ACTIVE_KEY)
|
||||
->remember(1440, self::ACTIVE_KEY)
|
||||
->pluck('value')
|
||||
;
|
||||
|
||||
@ -137,12 +145,8 @@ class Theme
|
||||
*/
|
||||
public static function setActiveTheme($code)
|
||||
{
|
||||
self::$activeThemeCache = false;
|
||||
self::$editThemeCache = false;
|
||||
|
||||
$paramKey = 'cms::theme.active';
|
||||
Parameters::set($paramKey, $code);
|
||||
Cache::forget($paramKey);
|
||||
self::resetCache();
|
||||
Parameters::set(self::ACTIVE_KEY, $code);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -247,4 +251,16 @@ class Theme
|
||||
|
||||
return URL::asset('themes/'.$this->getDirName().$previewPath);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets any memory or cache involved with the active or edit theme.
|
||||
* @return void
|
||||
*/
|
||||
public static function resetCache()
|
||||
{
|
||||
self::$activeThemeCache = false;
|
||||
self::$editThemeCache = false;
|
||||
Cache::forget(self::ACTIVE_KEY);
|
||||
Cache::forget(self::EDIT_KEY);
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ class ThemeTest extends TestCase
|
||||
{
|
||||
Config::set('cms.activeTheme', 'test');
|
||||
Event::flush('cms.activeTheme');
|
||||
Theme::resetCache();
|
||||
}
|
||||
|
||||
protected function countThemePages($path)
|
||||
|
Loading…
x
Reference in New Issue
Block a user