MDL-45699 behat: Don't use behat/lib.php functions in core.

behat/lib.php script should not be usually included, neither any of its functions
used within mooodle code at all. It's for exclusive use of behat and
moodle setup.php. For places requiring a different/special behavior
needing to check if are being run  as part of behat tests, use:
    if (defined('BEHAT_SITE_RUNNING')) { ...
This commit is contained in:
Eloy Lafuente (stronk7) 2014-12-23 12:29:44 +01:00
parent cb878d027b
commit c0d8831ae7
2 changed files with 9 additions and 3 deletions

View File

@ -126,7 +126,7 @@ class cache_factory {
// situation. It will use disabled alternatives where available.
require_once($CFG->dirroot.'/cache/disabledlib.php');
self::$instance = new cache_factory_disabled();
} else if ((defined('PHPUNIT_TEST') && PHPUNIT_TEST) || behat_is_test_site()) {
} else if ((defined('PHPUNIT_TEST') && PHPUNIT_TEST) || defined('BEHAT_SITE_RUNNING')) {
// We're using the test factory.
require_once($CFG->dirroot.'/cache/tests/fixtures/lib.php');
self::$instance = new cache_phpunit_factory();
@ -336,7 +336,7 @@ class cache_factory {
// The class to use.
$class = 'cache_config';
// Are we running tests of some form?
$testing = (defined('PHPUNIT_TEST') && PHPUNIT_TEST) || behat_is_test_site();
$testing = (defined('PHPUNIT_TEST') && PHPUNIT_TEST) || defined('BEHAT_SITE_RUNNING');
// Check if this is a PHPUnit test and redirect to the phpunit config classes if it is.
if ($testing) {

View File

@ -17,7 +17,13 @@
/**
* Behat basic functions
*
* It does not include MOODLE_INTERNAL because is part of the bootstrap
* It does not include MOODLE_INTERNAL because is part of the bootstrap.
*
* This script should not be usually included, neither any of its functions
* used, within mooodle code at all. It's for exclusive use of behat and
* moodle setup.php. For places requiring a different/special behavior
* needing to check if are being run as part of behat tests, use:
* if (defined('BEHAT_SITE_RUNNING')) { ...
*
* @package core
* @category test