MDL-40852 behat: Wrong URLs detection
This commit is contained in:
@@ -59,6 +59,11 @@ class behat_hooks extends behat_base {
|
||||
*/
|
||||
protected static $lastbrowsersessionstart = 0;
|
||||
|
||||
/**
|
||||
* @var For actions that should only run once.
|
||||
*/
|
||||
protected static $initprocessesfinished = false;
|
||||
|
||||
/**
|
||||
* Gives access to moodle codebase, ensures all is ready and sets up the test lock.
|
||||
*
|
||||
@@ -161,6 +166,15 @@ class behat_hooks extends behat_base {
|
||||
// Start always in the the homepage.
|
||||
$this->getSession()->visit($this->locate_path('/'));
|
||||
|
||||
// Checking that the root path is a Moodle test site.
|
||||
if (self::is_first_scenario()) {
|
||||
$notestsiteexception = new Exception('The base URL (' . $CFG->wwwroot . ') is not a behat test site, ' .
|
||||
'ensure you started the built-in web server in the correct directory');
|
||||
$this->find("xpath", "//head/child::title[normalize-space(.)='Acceptance test site']", $notestsiteexception);
|
||||
|
||||
self::$initprocessesfinished = true;
|
||||
}
|
||||
|
||||
// Closing JS dialogs if present. Otherwise they would block this scenario execution.
|
||||
if ($this->running_javascript()) {
|
||||
try {
|
||||
@@ -335,4 +349,12 @@ class behat_hooks extends behat_base {
|
||||
return preg_replace("/(\n)+/s", "\n", $notags);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the first scenario of the suite is running
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected static function is_first_scenario() {
|
||||
return !(self::$initprocessesfinished);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user