Using CLI to start test session rather than browser

Now possible because we don't rely on browser session state
to link up state to CLI (recent changes in testsession module).
This commit is contained in:
Ingo Schommer 2014-02-24 22:53:54 +13:00
parent 99423612ca
commit 7f3cc3b6b9
1 changed files with 4 additions and 16 deletions

View File

@ -60,6 +60,8 @@ class SilverStripeContext extends MinkContext implements SilverStripeAwareContex
protected $screenshotPath;
protected $context;
protected $testSessionEnvironment;
/**
@ -71,6 +73,7 @@ class SilverStripeContext extends MinkContext implements SilverStripeAwareContex
public function __construct(array $parameters) {
// Initialize your context here
$this->context = $parameters;
$this->testSessionEnvironment = new \TestSessionEnvironment();
}
public function setDatabase($databaseName) {
@ -127,22 +130,7 @@ class SilverStripeContext extends MinkContext implements SilverStripeAwareContex
);
}
$url = $this->joinUrlParts($this->getBaseUrl(), '/dev/testsession/start');
$url .= '?' . http_build_query($this->getTestSessionState());
$this->getSession()->visit($url);
$page = $this->getSession()->getPage();
$content = $page->getContent();
if(!preg_match('/<!-- +SUCCESS: +DBNAME=([^ ]+)/i', $content, $matches)) {
throw new \LogicException("Could not create a test session. Details below:\n" . $content);
} elseif($matches[1] != $this->databaseName) {
throw new \LogicException("Test session is using the database $matches[1]; it should be using $this->databaseName.");
}
$loginForm = $page->find('css', '#MemberLoginForm_LoginForm');
$this->testSessionEnvironment->startTestSession($this->getTestSessionState());
}
/**