From b6194c304d569c589871bc3f60836967bea197c2 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Wed, 23 Oct 2013 14:29:24 +0200 Subject: [PATCH 1/4] Default CMSMain to Versioned::reading_stage("Stage") Regression caused by https://github.com/silverstripe/silverstripe-framework/pull/2585 --- code/controllers/CMSMain.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/code/controllers/CMSMain.php b/code/controllers/CMSMain.php index 860ea61d..c1d9c9eb 100644 --- a/code/controllers/CMSMain.php +++ b/code/controllers/CMSMain.php @@ -55,6 +55,8 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr } parent::init(); + + Versioned::reading_stage("Stage"); Requirements::css(CMS_DIR . '/css/screen.css'); Requirements::customCSS($this->generatePageIconsCss()); From ab4b72d4864bbab57c80982f3ffe66009ff90ae4 Mon Sep 17 00:00:00 2001 From: Sam Minnee Date: Thu, 13 Feb 2014 18:54:44 +1300 Subject: [PATCH 2/4] FIX: Fixed testing of theme switching. The previous theme test relied on the existence of the tutorial theme, which has been removed. I'ved added a couple of behat rules for scaffolding fake themes, and altered the test to use these. --- .../features/bootstrap/FeatureContext.php | 3 ++ .../Cms/Test/Behaviour/ThemeContext.php | 47 +++++++++++++++++++ tests/behat/features/settings-main.feature | 11 +++-- 3 files changed, 57 insertions(+), 4 deletions(-) create mode 100644 tests/behat/features/bootstrap/SilverStripe/Cms/Test/Behaviour/ThemeContext.php diff --git a/tests/behat/features/bootstrap/FeatureContext.php b/tests/behat/features/bootstrap/FeatureContext.php index 371d0986..2dce078e 100644 --- a/tests/behat/features/bootstrap/FeatureContext.php +++ b/tests/behat/features/bootstrap/FeatureContext.php @@ -36,6 +36,9 @@ class FeatureContext extends \SilverStripe\Framework\Test\Behaviour\FeatureConte $fixtureContext->setFixtureFactory($this->getFixtureFactory()); $this->useContext('FixtureContext', $fixtureContext); + // Add extra contexts with more steps + $this->useContext('ThemeContext', new \SilverStripe\Cms\Test\Behaviour\ThemeContext($parameters)); + // Use blueprints which auto-publish all subclasses of SiteTree $factory = $fixtureContext->getFixtureFactory(); foreach(\ClassInfo::subclassesFor('SiteTree') as $id => $class) { diff --git a/tests/behat/features/bootstrap/SilverStripe/Cms/Test/Behaviour/ThemeContext.php b/tests/behat/features/bootstrap/SilverStripe/Cms/Test/Behaviour/ThemeContext.php new file mode 100644 index 00000000..511283b9 --- /dev/null +++ b/tests/behat/features/bootstrap/SilverStripe/Cms/Test/Behaviour/ThemeContext.php @@ -0,0 +1,47 @@ +[^"]+)"/ + */ + public function stepCreateTheme($theme) { + if(!preg_match('/^[0-9a-zA-Z_-]+$/', $theme)) throw new \InvalidArgumentException("Bad theme '$theme'"); + + if(!file_exists(BASE_PATH . '/themes/' . $theme)) mkdir(BASE_PATH . '/themes/' . $theme); + if(!file_exists(BASE_PATH . '/themes/' . $theme . '/templates')) mkdir(BASE_PATH . '/themes/' . $theme . '/templates'); + } + + /** + * Create a template within a test theme + * + * @Given /^a template "(?