mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 16:32:18 +02:00
MDL-43213 fix init regression and remove $checkphp parameter
This commit is contained in:
parent
a0e1168751
commit
9bb80d2005
@ -101,24 +101,6 @@ require("$CFG->dirroot/lib/setup.php");
|
||||
|
||||
raise_memory_limit(MEMORY_HUGE);
|
||||
|
||||
// Check that the directory does not contains other things.
|
||||
if (!file_exists("$CFG->behat_dataroot/behattestdir.txt")) {
|
||||
if ($dh = opendir($CFG->behat_dataroot)) {
|
||||
while (($file = readdir($dh)) !== false) {
|
||||
if ($file === 'behat' or $file === '.' or $file === '..' or $file === '.DS_Store') {
|
||||
continue;
|
||||
}
|
||||
behat_error(BEHAT_EXITCODE_CONFIG, '$CFG->behat_dataroot directory is not empty, ensure this is the directory where you want to install behat test dataroot');
|
||||
}
|
||||
closedir($dh);
|
||||
unset($dh);
|
||||
unset($file);
|
||||
}
|
||||
|
||||
// Now we create dataroot directory structure for behat tests.
|
||||
testing_initdataroot($CFG->behat_dataroot, 'behat');
|
||||
}
|
||||
|
||||
require_once($CFG->libdir.'/adminlib.php');
|
||||
require_once($CFG->libdir.'/upgradelib.php');
|
||||
require_once($CFG->libdir.'/clilib.php');
|
||||
|
@ -100,10 +100,9 @@ class behat_command {
|
||||
* It checks behat dependencies have been installed and runs
|
||||
* the behat help command to ensure it works as expected
|
||||
*
|
||||
* @param bool $checkphp Extra check for the PHP version
|
||||
* @return int Error code or 0 if all ok
|
||||
*/
|
||||
public static function behat_setup_problem($checkphp = false) {
|
||||
public static function behat_setup_problem() {
|
||||
global $CFG;
|
||||
|
||||
$clibehaterrorstr = "Behat dependencies not installed. Ensure you ran the composer installer. " . self::DOCS_URL . "#Installation\n";
|
||||
|
@ -196,7 +196,7 @@ class behat_util extends testing_util {
|
||||
}
|
||||
|
||||
// Checks the behat set up and the PHP version.
|
||||
if ($errorcode = behat_command::behat_setup_problem(true)) {
|
||||
if ($errorcode = behat_command::behat_setup_problem()) {
|
||||
exit($errorcode);
|
||||
}
|
||||
|
||||
@ -230,7 +230,7 @@ class behat_util extends testing_util {
|
||||
}
|
||||
|
||||
// Checks the behat set up and the PHP version, returning an error code if something went wrong.
|
||||
if ($errorcode = behat_command::behat_setup_problem(true)) {
|
||||
if ($errorcode = behat_command::behat_setup_problem()) {
|
||||
return $errorcode;
|
||||
}
|
||||
|
||||
|
@ -211,6 +211,7 @@ function behat_check_config_vars() {
|
||||
}
|
||||
if (!file_exists($CFG->behat_dataroot)) {
|
||||
$permissions = isset($CFG->directorypermissions) ? $CFG->directorypermissions : 02777;
|
||||
umask(0);
|
||||
if (!mkdir($CFG->behat_dataroot, $permissions, true)) {
|
||||
behat_error(BEHAT_EXITCODE_PERMISSIONS, '$CFG->behat_dataroot directory can not be created');
|
||||
}
|
||||
|
@ -71,6 +71,28 @@ if (defined('BEHAT_SITE_RUNNING')) {
|
||||
// selected wwwroot to prevent conflicts with production and phpunit environments.
|
||||
behat_check_config_vars();
|
||||
|
||||
// Check that the directory does not contains other things.
|
||||
if (!file_exists("$CFG->behat_dataroot/behattestdir.txt")) {
|
||||
if ($dh = opendir($CFG->behat_dataroot)) {
|
||||
while (($file = readdir($dh)) !== false) {
|
||||
if ($file === 'behat' or $file === '.' or $file === '..' or $file === '.DS_Store') {
|
||||
continue;
|
||||
}
|
||||
behat_error(BEHAT_EXITCODE_CONFIG, '$CFG->behat_dataroot directory is not empty, ensure this is the directory where you want to install behat test dataroot');
|
||||
}
|
||||
closedir($dh);
|
||||
unset($dh);
|
||||
unset($file);
|
||||
}
|
||||
|
||||
if (defined('BEHAT_UTIL')) {
|
||||
// Now we create dataroot directory structure for behat tests.
|
||||
testing_initdataroot($CFG->behat_dataroot, 'behat');
|
||||
} else {
|
||||
behat_error(BEHAT_EXITCODE_INSTALL);
|
||||
}
|
||||
}
|
||||
|
||||
if (!defined('BEHAT_UTIL') and !defined('BEHAT_TEST')) {
|
||||
// Somebody tries to access test site directly, tell them if not enabled.
|
||||
if (!file_exists($CFG->behat_dataroot . '/behat/test_environment_enabled.txt')) {
|
||||
|
@ -38,7 +38,13 @@ function testing_cli_argument_path($moodlepath) {
|
||||
$moodlepath = preg_replace('|^/admin/|', "/$CFG->admin/", $moodlepath);
|
||||
}
|
||||
|
||||
$cwd = getcwd();
|
||||
if (isset($_SERVER['REMOTE_ADDR'])) {
|
||||
// Web access, this should not happen often.
|
||||
$cwd = dirname(dirname(__DIR__));
|
||||
} else {
|
||||
// This is the real CLI script, work with relative paths.
|
||||
$cwd = getcwd();
|
||||
}
|
||||
if (substr($cwd, -1) !== DIRECTORY_SEPARATOR) {
|
||||
$cwd .= DIRECTORY_SEPARATOR;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user