From ab4b72d4864bbab57c80982f3ffe66009ff90ae4 Mon Sep 17 00:00:00 2001 From: Sam Minnee Date: Thu, 13 Feb 2014 18:54:44 +1300 Subject: [PATCH] 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 "(?