MDL-38007 behat: Refining error texts

Also removing a couple of silly notices
This commit is contained in:
David Monllao 2013-03-05 16:11:15 +08:00 committed by Aparup Banerjee
parent ce91af8114
commit 6fe3986dec
3 changed files with 20 additions and 7 deletions

View File

@ -38,4 +38,7 @@ $string['stepsdefinitionstype'] = 'Type';
$string['theninfo'] = 'Then. Checkings to ensure the outcomes are the expected ones';
$string['viewsteps'] = 'Filter';
$string['wheninfo'] = 'When. Actions that provokes an event';
$string['wrongbehatsetup'] = 'Something is wrong with the setup, ensure you ran the composer installer and vendor/bin/behat file has execution permissions';
$string['wrongbehatsetup'] = 'Something is wrong with behat setup, ensure:<ul>
<li>You ran "curl http://getcomposer.org/installer | php"</li>
<li>You ran "php composer.phar install --dev"</li>
<li>vendor/bin/behat file has execution permissions</li></ul>';

View File

@ -140,17 +140,22 @@ class behat_command {
behat_error(BEHAT_EXITCODE_REQUIREMENT, 'PHP 5.4 is required. See config-dist.php for possible alternatives');
}
$clibehaterrorstr = "Behat dependencies not installed. Ensure you ran the composer installer. " . self::DOCS_URL . "#Installation\n";
// Moodle setting.
if (!self::are_behat_dependencies_installed()) {
$msg = get_string('wrongbehatsetup', 'tool_behat');
// With HTML.
$docslink = self::DOCS_URL . '#Installation';
if (!CLI_SCRIPT) {
$msg = get_string('wrongbehatsetup', 'tool_behat');
$docslink = self::DOCS_URL . '#Installation';
$docslink = html_writer::tag('a', $docslink, array('href' => $docslink, 'target' => '_blank'));
$msg .= get_string('moreinfoin', 'tool_behat', $docslink);
} else {
$msg = $clibehaterrorstr;
}
$msg .= '. ' . get_string('moreinfoin', 'tool_behat', $docslink);
self::output_msg($msg);
return BEHAT_EXITCODE_COMPOSER;
@ -161,7 +166,12 @@ class behat_command {
if ($code != 0) {
// Returning composer error code to avoid conflicts with behat and moodle error codes.
self::output_msg(get_string('wrongbehatsetup', 'tool_behat'));
if (!CLI_SCRIPT) {
$msg = get_string('wrongbehatsetup', 'tool_behat');
} else {
$msg = $clibehaterrorstr;
}
self::output_msg($msg);
return BEHAT_EXITCODE_COMPOSER;
}

View File

@ -177,7 +177,7 @@ class behat_util extends testing_util {
// Checks the behat set up and the PHP version.
if ($errorcode = behat_command::behat_setup_problem(true)) {
exit($code);
exit($errorcode);
}
// Check that test environment is correctly set up.
@ -211,7 +211,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)) {
return $code;
return $errorcode;
}
// Check that test environment is correctly set up, stops execution.