Skip to content

Commit

Permalink
MDL-45699 behat: Don't use behat/lib.php functions in core.
Browse files Browse the repository at this point in the history
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')) { ...
  • Loading branch information
stronk7 committed Dec 23, 2014
1 parent db5fb4c commit e9b36ac
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 2 additions & 2 deletions cache/classes/factory.php
Expand Up @@ -126,7 +126,7 @@ public static function instance($forcereload = false) {
// 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();
Expand Down Expand Up @@ -336,7 +336,7 @@ public function create_config_instance($writer = false) {
// 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) {
Expand Down
8 changes: 7 additions & 1 deletion lib/behat/lib.php
Expand Up @@ -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
Expand Down

0 comments on commit e9b36ac

Please sign in to comment.