Skip to content

Commit

Permalink
Merge pull request #63 from stof/improve_reset
Browse files Browse the repository at this point in the history
Improve driver reset
  • Loading branch information
stof committed May 2, 2014
2 parents 12ac773 + 912e74d commit 1ac49bc
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/Behat/Mink/Driver/BrowserKitDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,18 +122,18 @@ public function isStarted()
*/
public function stop()
{
$this->client->restart();
$this->reset();
$this->started = false;
$this->forms = array();
$this->serverParameters = array();
}

/**
* {@inheritdoc}
*/
public function reset()
{
$this->client->getCookieJar()->clear();
// Restarting the client resets the cookies and the history
$this->client->restart();
$this->forms = array();
$this->serverParameters = array();
}

Expand Down Expand Up @@ -166,10 +166,7 @@ public function getCurrentUrl()
}

if ($request === null) {
// If no request exists, return the current
// URL as null instead of running into a
// "method on non-object" error.
return null;
throw new DriverException('Unable to access the request before visiting a page');
}

return $request->getUri();
Expand Down Expand Up @@ -486,6 +483,7 @@ public function click($xpath)

if ('a' === $tagName) {
$this->client->click($node->link());
$this->forms = array();
} elseif ($this->canSubmitForm($crawlerNode)) {
$this->submit($node->form());
} elseif ($this->canResetForm($crawlerNode)) {
Expand Down Expand Up @@ -893,7 +891,7 @@ private function getCrawler()
$crawler = $this->client->getCrawler();

if (null === $crawler) {
throw new DriverException('Crawler can\'t be initialized. Did you started driver?');
throw new DriverException('Unable to access the response content before visiting a page');
}

return $crawler;
Expand Down

0 comments on commit 1ac49bc

Please sign in to comment.