Skip to content

Commit

Permalink
Refactor default screen resize into SilverStripeContext
Browse files Browse the repository at this point in the history
  • Loading branch information
Damian Mooyman committed Aug 14, 2014
1 parent 01b129d commit c0801a6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 21 deletions.
15 changes: 0 additions & 15 deletions src/SilverStripe/BehatExtension/Context/BasicContext.php
Expand Up @@ -97,21 +97,6 @@ public function appendErrorHandlerBeforeStep(StepEvent $event)
$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
*
Expand Down
13 changes: 7 additions & 6 deletions src/SilverStripe/BehatExtension/Context/SilverStripeContext.php
Expand Up @@ -62,7 +62,7 @@ class SilverStripeContext extends MinkContext implements SilverStripeAwareContex
protected $context;

protected $testSessionEnvironment;


/**
* Initializes context.
Expand Down Expand Up @@ -205,17 +205,18 @@ public function before(ScenarioEvent $event) {
$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() {
Expand Down Expand Up @@ -350,10 +351,10 @@ public function fillField($field, $value) {
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
);
Expand All @@ -370,7 +371,7 @@ public function clickLink($link) {
if($links) foreach($links as $l) {
if($l->isVisible()) {
$l->click();
return;
return;
}
}
throw new ElementNotFoundException(
Expand Down

2 comments on commit c0801a6

@chillu
Copy link
Member

@chillu chillu commented on c0801a6 Jul 18, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tractorcow Is this commit on the develop branch still required? I'm keen to get rid of that branch, avoid confusion with master or feature branches.

@tractorcow
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, we can drop it. I've removed develop.

Please sign in to comment.