From e85cbf80c5ad0c4dc271784edcfb1c1787aaa752 Mon Sep 17 00:00:00 2001 From: Sam Georges Date: Tue, 29 Jul 2014 17:44:24 +1000 Subject: [PATCH] Fixes unit tests --- app/config/testing/cms.php | 21 +++++++++++++++++---- modules/cms/classes/Theme.php | 15 +++++++++------ tests/unit/cms/classes/ControllerTest.php | 4 +--- 3 files changed, 27 insertions(+), 13 deletions(-) diff --git a/app/config/testing/cms.php b/app/config/testing/cms.php index caa73b460..ed586eb9a 100644 --- a/app/config/testing/cms.php +++ b/app/config/testing/cms.php @@ -2,6 +2,17 @@ return array( + /* + |-------------------------------------------------------------------------- + | Specifies the default CMS theme + |-------------------------------------------------------------------------- + | + | This parameter value can be overridden by the CMS back-end settings. + | + */ + + 'activeTheme' => 'test', + /* |-------------------------------------------------------------------------- | Plugins directory @@ -66,14 +77,16 @@ return array( /* |-------------------------------------------------------------------------- - | Specifies the default CMS theme + | Determines if a friendly error page should be used. |-------------------------------------------------------------------------- | - | This parameter value can be overridden by the CMS back-end settings. + | If this value is set to true, a friendly error page is used when an + | exception is encountered. You must create a CMS page with route "/error" + | to set the contents of this page. Otherwise the default error page is shown. | */ - 'activeTheme' => 'test', + 'customErrorPage' => true, /* |-------------------------------------------------------------------------- @@ -88,7 +101,7 @@ return array( */ 'enableAssetCache' => false, - + /* |-------------------------------------------------------------------------- | Disables Twig caching for unit tests diff --git a/modules/cms/classes/Theme.php b/modules/cms/classes/Theme.php index 440c98bdf..56b65e686 100644 --- a/modules/cms/classes/Theme.php +++ b/modules/cms/classes/Theme.php @@ -6,6 +6,7 @@ use Lang; use Cache; use Event; use Config; +use DbDongle; use October\Rain\Support\Yaml; use System\Models\Parameters; use System\Classes\SystemException; @@ -97,13 +98,15 @@ class Theme $paramKey = 'cms::theme.active'; $activeTheme = Config::get('cms.activeTheme'); - $dbResult = Parameters::findRecord($paramKey) - ->remember(1440, $paramKey) - ->pluck('value') - ; + if (DbDongle::hasDatabase()) { + $dbResult = Parameters::findRecord($paramKey) + ->remember(1440, $paramKey) + ->pluck('value') + ; - if ($dbResult !== null) - $activeTheme = $dbResult; + if ($dbResult !== null) + $activeTheme = $dbResult; + } $apiResult = Event::fire('cms.activeTheme', [], true); if ($apiResult !== null) diff --git a/tests/unit/cms/classes/ControllerTest.php b/tests/unit/cms/classes/ControllerTest.php index 34d06f5a4..121df73a5 100644 --- a/tests/unit/cms/classes/ControllerTest.php +++ b/tests/unit/cms/classes/ControllerTest.php @@ -1,7 +1,7 @@ load('apitest'); $controller = new Controller($theme); @@ -26,7 +25,6 @@ class ControllerTest extends TestCase /* * Test the theme 404 page */ - $theme = new Theme(); $theme->load('test'); $controller = new Controller($theme);