From 41cdc87eaef0cac888b8993a7e3c6bee6dd65f3a Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Wed, 19 Mar 2014 08:42:23 +1300 Subject: [PATCH] Import DB and fixtures as a separate step Usually triggered by manual test session environment runs --- .../Context/SilverStripeContext.php | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/SilverStripe/BehatExtension/Context/SilverStripeContext.php b/src/SilverStripe/BehatExtension/Context/SilverStripeContext.php index bcac52e..2c1b373 100644 --- a/src/SilverStripe/BehatExtension/Context/SilverStripeContext.php +++ b/src/SilverStripe/BehatExtension/Context/SilverStripeContext.php @@ -130,7 +130,25 @@ class SilverStripeContext extends MinkContext implements SilverStripeAwareContex ); } - $this->testSessionEnvironment->startTestSession($this->getTestSessionState()); + $state = $this->getTestSessionState(); + $this->testSessionEnvironment->startTestSession($state); + + // Optionally import database + if(!empty($state['importDatabasePath'])) { + $this->testSessionEnvironment->importDatabase( + $state['importDatabasePath'], + !empty($state['requireDefaultRecords']) ? $state['requireDefaultRecords'] : false + ); + } else if(!empty($state['requireDefaultRecords']) && $state['requireDefaultRecords']) { + $this->testSessionEnvironment->requireDefaultRecords(); + } + + // Fixtures + $fixtureFile = (!empty($params['fixture'])) ? $params['fixture'] : null; + if($fixtureFile) { + $this->testSessionEnvironment->loadFixtureIntoDb($fixtureFile); + } + if($screenSize = getenv('BEHAT_SCREEN_SIZE')) { list($screenWidth, $screenHeight) = explode('x', $screenSize);