Skip to content

Commit

Permalink
MDL-37046 behat: Moving installation instructions to MDocs
Browse files Browse the repository at this point in the history
  • Loading branch information
David Monllao committed Jan 29, 2013
1 parent 8cdc0ce commit 554820d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 36 deletions.
5 changes: 5 additions & 0 deletions admin/tool/behat/cli/util.php
Expand Up @@ -51,6 +51,7 @@
Options:
--stepsdefinitions Displays the available steps definitions (accepts --filter=\"\" option to restrict the list to the matching definitions)
--runtests Runs the tests (accepts --tags=\"\" option to execute only the matching tests and --extra=\"\" to specify extra behat options)
--testenvironment Switches between the real and the test environment (accepts value 'enable' or 'disable', for example --testenvironment=\"enable\"
-h, --help Print out this help
Expand Down Expand Up @@ -90,6 +91,10 @@
case 'runtests':
tool_behat::runtests($options['tags'], $options['extra']);
break;

case 'testenvironment':
tool_behat::switchenvironment($options['testenvironment']);
break;
}


Expand Down
1 change: 0 additions & 1 deletion admin/tool/behat/lang/en/tool_behat.php
Expand Up @@ -23,7 +23,6 @@
*/

$string['actionnotsupported'] = 'Action not supported';
$string['buildconfigfileinfo'] = 'Update the list of available acceptance tests';
$string['commandinfo'] = 'Info';
$string['commandruntests'] = 'Run tests';
$string['commandstepsdefinitions'] = 'Steps definitions list';
Expand Down
52 changes: 17 additions & 35 deletions admin/tool/behat/locallib.php
Expand Up @@ -44,10 +44,13 @@ public static function info() {

$html = self::get_header();
$html .= self::get_info();
$html .= self::get_build_config_file_form();
$html .= self::get_switch_environment_form();
$html .= self::get_steps_definitions_form();
$html .= self::get_run_tests_form();

if (!self::is_test_environment_running()) {
$html .= self::get_steps_definitions_form();
$html .= self::get_run_tests_form();
}

$html .= self::get_footer();

echo $html;
Expand Down Expand Up @@ -128,7 +131,9 @@ public static function switchenvironment($testenvironment = false) {
self::disable_test_environment();
}

redirect(get_login_url());
if (!CLI_SCRIPT) {
redirect(get_login_url());
}
}

/**
Expand Down Expand Up @@ -267,6 +272,7 @@ private static function check_behat_setup() {
* @throws file_exception
*/
private static function enable_test_environment() {
global $CFG;

if (self::is_test_environment_enabled()) {
debugging('Test environment was already enabled');
Expand All @@ -283,7 +289,7 @@ private static function enable_test_environment() {
if (!file_put_contents($filepath, $contents)) {
throw new file_exception('cannotcreatefile', $filepath);
}

chmod($filepath, $CFG->directorypermissions);
}

/**
Expand All @@ -310,7 +316,7 @@ private static function disable_test_environment() {
*
* @return bool
*/
public static function is_test_environment_enabled() {
private static function is_test_environment_enabled() {

$testenvfile = self::get_test_filepath();
if (file_exists($testenvfile)) {
Expand All @@ -324,7 +330,7 @@ public static function is_test_environment_enabled() {
* Returns true if Moodle is currently running with the test database and dataroot
* @return bool
*/
public static function is_test_environment_running() {
private static function is_test_environment_running() {
global $CFG;

if (!empty($CFG->originaldataroot)) {
Expand Down Expand Up @@ -439,17 +445,11 @@ private static function output_success($html, $url = false) {
private static function get_info() {
global $OUTPUT;

$url = 'http://docs.moodle.org/dev/Behat_integration#Installation';

$html = $OUTPUT->box_start();
$html .= html_writer::tag('h1', 'Info');
$info = 'This tool makes use of the phpunit test environment, during the automatic acceptance tests execution the site uses the test database and dataroot directories so this tool IS NOT intended to be used in production sites.';
$html .= html_writer::tag('div', $info);

$html .= html_writer::tag('h1', 'Installation');
$installinstructions = '1.- Follow the PHPUnit installation instructions to set up the testing environment $CFG->wwwroot/admin/tool/phpunit/index.php<br/>';
$installinstructions .= '2.- Follow the moodle-acceptance-test installation instructions https://github.com/dmonllao/behat-moodle<br/>';
$installinstructions .= '3.- Set up the \'config_file_path\' param in /MOODLE-ACCEPTANCE-TEST/ROOT/PATH/behat.yml pointing to $CFG->dataroot/behat/config.yml (for example /YOUR/MOODLEDATA/PATH/behat/config.yml)<br/>';
$installinstructions .= '4.- Set up $CFG->behatpath in your config.php with the path of your moodle-acceptance-test installation (for example /MOODLE-ACCEPTANCE-TEST/ROOT/PATH)<br/>';
$html .= html_writer::tag('div', $installinstructions);
$html .= html_writer::tag('h1', 'Installation info');
$html .= html_writer::tag('div', 'Follow <a href="' . $url . '" target="_blank">' . $url . '</a> instructions');
$html .= $OUTPUT->box_end();

return $html;
Expand Down Expand Up @@ -478,24 +478,6 @@ private static function get_switch_environment_form() {
return $html;
}

/**
* Returns a button to execute the build config file form
* @return string
*/
private static function get_build_config_file_form() {
global $OUTPUT, $CFG;

$params = array('action' => 'buildconfigfile', 'sesskey' => sesskey());
$url = new moodle_url('/' . $CFG->admin . '/tool/behat/index.php', $params);

$html = $OUTPUT->box_start();
$html .= '<p>' . get_string('buildconfigfileinfo', 'tool_behat') . '</p>';
$html .= $OUTPUT->single_button($url, get_string('commandbuildconfigfile', 'tool_behat'));
$html .= $OUTPUT->box_end();

return $html;
}

/**
* Returns the steps definitions form
* @param string $filter To filter the steps definitions list by keyword
Expand Down

0 comments on commit 554820d

Please sign in to comment.