Merge pull request #67 from tractorcow/pulls/refactor-resize

Refactor default screen resize into SilverStripeContext
This commit is contained in:
Ingo Schommer 2014-09-02 08:47:31 +12:00
commit 16d5a0099b
2 changed files with 7 additions and 21 deletions

View File

@ -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
*

View File

@ -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(