mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 08:26:37 +02:00
Merge branch 'MDL-39686_master' of git://github.com/dmonllao/moodle
This commit is contained in:
commit
e6302a3c75
2 changed files with 27 additions and 0 deletions
|
@ -54,6 +54,11 @@ use Behat\Behat\Event\SuiteEvent as SuiteEvent,
|
|||
*/
|
||||
class behat_hooks extends behat_base {
|
||||
|
||||
/**
|
||||
* @var Last browser session start time.
|
||||
*/
|
||||
protected static $lastbrowsersessionstart = 0;
|
||||
|
||||
/**
|
||||
* Gives access to moodle codebase, ensures all is ready and sets up the test lock.
|
||||
*
|
||||
|
@ -102,6 +107,12 @@ class behat_hooks extends behat_base {
|
|||
}
|
||||
// Avoid parallel tests execution, it continues when the previous lock is released.
|
||||
test_lock::acquire('behat');
|
||||
|
||||
// Store the browser reset time if reset after N seconds is specified in config.php.
|
||||
if (!empty($CFG->behat_restart_browser_after)) {
|
||||
// Store the initial browser session opening.
|
||||
self::$lastbrowsersessionstart = time();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -138,6 +149,15 @@ class behat_hooks extends behat_base {
|
|||
$user = $DB->get_record('user', array('username' => 'admin'));
|
||||
session_set_user($user);
|
||||
|
||||
// Reset the browser if specified in config.php.
|
||||
if (!empty($CFG->behat_restart_browser_after) && $this->running_javascript()) {
|
||||
$now = time();
|
||||
if (self::$lastbrowsersessionstart + $CFG->behat_restart_browser_after < $now) {
|
||||
$this->getSession()->restart();
|
||||
self::$lastbrowsersessionstart = $now;
|
||||
}
|
||||
}
|
||||
|
||||
// Start always in the the homepage.
|
||||
$this->getSession()->visit($this->locate_path('/'));
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue