FIX: Perform error checking on testsession/start.

This fix improves the robustness of the behat tests, ensuring that the testsession has actually
been successfully started before the test kicks off. Although it doesn't fix anything that
wasn't previously broken, it makes environment set-up errors a bit easier to figure out.

It looks for a new status comment in the result of testsession, that is also being added to the
module.
This commit is contained in:
Sam Minnee 2013-06-07 11:19:42 +12:00
parent f18ec15dac
commit 790d086def
1 changed files with 14 additions and 0 deletions

View File

@ -148,6 +148,20 @@ class SilverStripeContext extends MinkContext implements SilverStripeAwareContex
$url .= '?' . http_build_query($params);
$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);
} else if($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');
}
/**