Use Config nesting in SapphireTest::useTestTheme()

Using the Config nesting functionality to restore variables
This commit is contained in:
Daniel Hensby 2014-05-02 15:25:31 +01:00
parent 612a096765
commit 5298371282

View File

@ -895,13 +895,13 @@ class SapphireTest extends PHPUnit_Framework_TestCase {
* @param $callback Closure
*/
protected function useTestTheme($themeBaseDir, $theme, $callback) {
Config::nest();
global $project;
$manifest = new SS_TemplateManifest($themeBaseDir, $project, true, true);
SS_TemplateLoader::instance()->pushManifest($manifest);
$origTheme = Config::inst()->get('SSViewer', 'theme');
Config::inst()->update('SSViewer', 'theme', $theme);
$e = null;
@ -911,7 +911,8 @@ class SapphireTest extends PHPUnit_Framework_TestCase {
// Remove all the test themes we created
SS_TemplateLoader::instance()->popManifest();
Config::inst()->update('SSViewer', 'theme', $origTheme);
Config::unnest();
if ($e) throw $e;
}