Skip to content

Commit

Permalink
MDL-43213 fix init regression and remove $checkphp parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
skodak authored and David Monllao committed Dec 19, 2013
1 parent a0e1168 commit 9bb80d2
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 23 deletions.
18 changes: 0 additions & 18 deletions admin/tool/behat/cli/util.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,24 +101,6 @@

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');
Expand Down
3 changes: 1 addition & 2 deletions lib/behat/classes/behat_command.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,9 @@ public final static function run($options = '') {
* 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";
Expand Down
4 changes: 2 additions & 2 deletions lib/behat/classes/util.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ public static function start_test_mode() {
}

// 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);
}

Expand Down Expand Up @@ -230,7 +230,7 @@ public static function get_behat_status() {
}

// 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;
}

Expand Down
1 change: 1 addition & 0 deletions lib/behat/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand Down
22 changes: 22 additions & 0 deletions lib/setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,28 @@
// 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')) {
Expand Down
8 changes: 7 additions & 1 deletion lib/testing/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 9bb80d2

Please sign in to comment.