mirror of
https://github.com/silverstripe/silverstripe-behat-extension
synced 2024-10-22 17:05:32 +02:00
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:
parent
f18ec15dac
commit
790d086def
@ -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');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user