Skip to content

Commit

Permalink
MDL-38007 behat: Refining error texts
Browse files Browse the repository at this point in the history
Also removing a couple of silly notices
  • Loading branch information
David Monllao authored and Aparup Banerjee committed Mar 5, 2013
1 parent ce91af8 commit 6fe3986
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
5 changes: 4 additions & 1 deletion admin/tool/behat/lang/en/tool_behat.php
Expand Up @@ -38,4 +38,7 @@
$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>';
18 changes: 14 additions & 4 deletions lib/behat/classes/behat_command.php
Expand Up @@ -140,17 +140,22 @@ public static function behat_setup_problem($checkphp = false) {
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;
Expand All @@ -161,7 +166,12 @@ public static function behat_setup_problem($checkphp = false) {

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

Expand Down
4 changes: 2 additions & 2 deletions lib/behat/classes/util.php
Expand Up @@ -177,7 +177,7 @@ public static function start_test_mode() {

// 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.
Expand Down Expand Up @@ -211,7 +211,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)) {
return $code;
return $errorcode;
}

// Check that test environment is correctly set up, stops execution.
Expand Down

0 comments on commit 6fe3986

Please sign in to comment.