MDL-39478 behat: New constant to detect when the test site is running

Also removing an unused var and method.
This commit is contained in:
David Monllao
2013-05-07 11:12:01 +08:00
parent 081bfdc5ff
commit cfcbc34a61
4 changed files with 24 additions and 26 deletions
+14 -4
View File
@@ -113,16 +113,25 @@ if (!empty($CFG->behat_dataroot) && !empty($CFG->behat_prefix) && file_exists($C
$switchcompletely = !empty($CFG->behat_switchcompletely) && php_sapi_name() !== 'cli';
$builtinserver = php_sapi_name() === 'cli-server';
$behatrunning = defined('BEHAT_RUNNING');
$behatrunning = defined('BEHAT_TEST');
$testenvironmentrequested = $switchcompletely || $builtinserver || $behatrunning;
// Only switch to test environment if it has been enabled.
$testenvironmentenabled = file_exists($CFG->behat_dataroot . '/behat/test_environment_enabled.txt');
if ($testenvironmentenabled && $testenvironmentrequested) {
// Constant used to inform that the behat test site is being used,
// this includes all the processes executed by the behat CLI command like
// the site reset, the steps executed by the browser drivers when simulating
// a user session and a real session when browsing manually to $CFG->behat_wwwroot
// like the browser driver does automatically.
// Different from BEHAT_TEST as only this last one can perform CLI
// actions like reset the site or use data generators.
define('BEHAT_SITE_RUNNING', true);
$CFG->wwwroot = $CFG->behat_wwwroot;
$CFG->passwordsaltmain = 'moodle';
$CFG->originaldataroot = $CFG->dataroot;
$CFG->prefix = $CFG->behat_prefix;
$CFG->dataroot = $CFG->behat_dataroot;
}
@@ -455,8 +464,9 @@ if (!PHPUNIT_TEST or PHPUNIT_UTIL) {
set_error_handler('default_error_handler', E_ALL | E_STRICT);
}
// Acceptance tests needs special output to capture the errors.
if (!empty($CFG->originaldataroot) && !defined('BEHAT_RUNNING')) {
// Acceptance tests needs special output to capture the errors,
// but not necessary for behat CLI command.
if (defined('BEHAT_SITE_RUNNING') && !defined('BEHAT_TEST')) {
require_once(__DIR__ . '/behat/lib.php');
set_error_handler('behat_error_handler', E_ALL | E_STRICT);
}