From c0801a63efdf0b67ad44fd43a69d453e79fbafc0 Mon Sep 17 00:00:00 2001 From: Damian Mooyman Date: Thu, 14 Aug 2014 16:21:31 +1200 Subject: [PATCH] Refactor default screen resize into SilverStripeContext --- .../BehatExtension/Context/BasicContext.php | 15 --------------- .../Context/SilverStripeContext.php | 13 +++++++------ 2 files changed, 7 insertions(+), 21 deletions(-) diff --git a/src/SilverStripe/BehatExtension/Context/BasicContext.php b/src/SilverStripe/BehatExtension/Context/BasicContext.php index 716ea7a..6156418 100644 --- a/src/SilverStripe/BehatExtension/Context/BasicContext.php +++ b/src/SilverStripe/BehatExtension/Context/BasicContext.php @@ -97,21 +97,6 @@ JS; $this->getSession()->executeScript($javascript); } - /** - * @BeforeStep ~@resizes&&~@modal - * - * Resize the window to maximum size, unless the step will resize itself - */ - public function maximiseWindowBeforeStep(StepEvent $event) { - $driver = $this->getSession()->getDriver(); - if($screenSize = getenv('BEHAT_SCREEN_SIZE')) { - list($screenWidth, $screenHeight) = explode('x', $screenSize); - $driver->resizeWindow((int)$screenWidth, (int)$screenHeight); - } else { - $driver->resizeWindow(1024, 768); - } - } - /** * @AfterStep ~@modal * diff --git a/src/SilverStripe/BehatExtension/Context/SilverStripeContext.php b/src/SilverStripe/BehatExtension/Context/SilverStripeContext.php index 02cf0e8..fce6d9f 100644 --- a/src/SilverStripe/BehatExtension/Context/SilverStripeContext.php +++ b/src/SilverStripe/BehatExtension/Context/SilverStripeContext.php @@ -62,7 +62,7 @@ class SilverStripeContext extends MinkContext implements SilverStripeAwareContex protected $context; protected $testSessionEnvironment; - + /** * Initializes context. @@ -205,17 +205,18 @@ class SilverStripeContext extends MinkContext implements SilverStripeAwareContex $this->testSessionEnvironment->loadFixtureIntoDb($fixtureFile); } - if($screenSize = getenv('BEHAT_SCREEN_SIZE')) { list($screenWidth, $screenHeight) = explode('x', $screenSize); $this->getSession()->resizeWindow((int)$screenWidth, (int)$screenHeight); + } else { + $this->getSession()->resizeWindow(1024, 768); } } /** * Returns a parameter map of state to set within the test session. * Takes TESTSESSION_PARAMS environment variable into account for run-specific configurations. - * + * * @return array */ public function getTestSessionState() { @@ -350,10 +351,10 @@ class SilverStripeContext extends MinkContext implements SilverStripeAwareContex if($fields) foreach($fields as $field) { if($field->isVisible()) { $field->setValue($value); - return; + return; } } - + throw new ElementNotFoundException( $this->getSession(), 'form field', 'id|name|label|value', $field ); @@ -370,7 +371,7 @@ class SilverStripeContext extends MinkContext implements SilverStripeAwareContex if($links) foreach($links as $l) { if($l->isVisible()) { $l->click(); - return; + return; } } throw new ElementNotFoundException(