From d1ac356a8b9f05e21c3731e2bde0289cda4332ca Mon Sep 17 00:00:00 2001 From: Tim Hunt Date: Mon, 15 Apr 2019 16:50:46 +0100 Subject: [PATCH] MDL-60418 Behat: Fix broken docs links in Behat code. --- admin/tool/behat/renderer.php | 7 +++---- lib/behat/classes/behat_command.php | 4 ++-- lib/behat/classes/util.php | 2 +- lib/tests/behat/behat_data_generators.php | 5 ++++- lib/tests/behat/behat_forms.php | 10 +++++----- lib/tests/behat/behat_general.php | 4 +--- lib/tests/behat/behat_hooks.php | 4 ++-- 7 files changed, 18 insertions(+), 18 deletions(-) diff --git a/admin/tool/behat/renderer.php b/admin/tool/behat/renderer.php index bf2b7a10a62..3bd03fe4382 100644 --- a/admin/tool/behat/renderer.php +++ b/admin/tool/behat/renderer.php @@ -162,11 +162,10 @@ class tool_behat_renderer extends plugin_renderer_base { $html .= $this->output->heading($title); // Info. - $installurl = behat_command::DOCS_URL . '#Installation'; - $installlink = html_writer::tag('a', $installurl, array('href' => $installurl, 'target' => '_blank')); - $writetestsurl = behat_command::DOCS_URL . '#Writing_features'; + $installlink = html_writer::tag('a', $installurl, array('href' => behat_command::DOCS_URL, 'target' => '_blank')); + $writetestsurl = 'https://docs.moodle.org/dev/Writing acceptance tests'; $writetestslink = html_writer::tag('a', $writetestsurl, array('href' => $writetestsurl, 'target' => '_blank')); - $writestepsurl = behat_command::DOCS_URL . '#Adding_steps_definitions'; + $writestepsurl = 'https://docs.moodle.org/dev/Writing_new_acceptance_test_step_definitions'; $writestepslink = html_writer::tag('a', $writestepsurl, array('href' => $writestepsurl, 'target' => '_blank')); $infos = array( get_string('installinfo', 'tool_behat', $installlink), diff --git a/lib/behat/classes/behat_command.php b/lib/behat/classes/behat_command.php index 2d231850858..4adc6275ee3 100644 --- a/lib/behat/classes/behat_command.php +++ b/lib/behat/classes/behat_command.php @@ -40,7 +40,7 @@ class behat_command { /** * Docs url */ - const DOCS_URL = 'http://docs.moodle.org/dev/Acceptance_testing'; + const DOCS_URL = 'https://docs.moodle.org/dev/Running_acceptance_test'; /** * Ensures the behat dir exists in moodledata @@ -265,7 +265,7 @@ class behat_command { // We continue execution after this. $clibehaterrorstr = "Ensure you set \$CFG->behat_* vars in config.php " . "and you ran admin/tool/behat/cli/init.php.\n" . - "More info in " . self::DOCS_URL . "#Installation\n\n"; + "More info in " . self::DOCS_URL; echo 'Error: ' . $msg . "\n\n" . $clibehaterrorstr; } diff --git a/lib/behat/classes/util.php b/lib/behat/classes/util.php index a9ab97a7bbb..4f11771f00a 100644 --- a/lib/behat/classes/util.php +++ b/lib/behat/classes/util.php @@ -179,7 +179,7 @@ class behat_util extends testing_util { behat_error (BEHAT_EXITCODE_REQUIREMENT, $CFG->behat_wwwroot . ' is not available, ensure you specified ' . 'correct url and that the server is set up and started.' . PHP_EOL . ' More info in ' . - behat_command::DOCS_URL . '#Running_tests' . PHP_EOL); + behat_command::DOCS_URL . PHP_EOL); } // Check if cli version is same as web version. diff --git a/lib/tests/behat/behat_data_generators.php b/lib/tests/behat/behat_data_generators.php index 78c72e19b5b..22b8d0a5057 100644 --- a/lib/tests/behat/behat_data_generators.php +++ b/lib/tests/behat/behat_data_generators.php @@ -201,7 +201,10 @@ class behat_data_generators extends behat_base { ); /** - * Creates the specified element. More info about available elements in http://docs.moodle.org/dev/Acceptance_testing#Fixtures. + * Creates the specified element. + * + * The most reliable list of what types of thing can be created is the + * $elements array defined above. * * @Given /^the following "(?P(?:[^"]|\\")*)" exist:$/ * diff --git a/lib/tests/behat/behat_forms.php b/lib/tests/behat/behat_forms.php index 354cdb495a0..cd532a346a6 100644 --- a/lib/tests/behat/behat_forms.php +++ b/lib/tests/behat/behat_forms.php @@ -71,7 +71,7 @@ class behat_forms extends behat_base { } /** - * Fills a form with field/value data. More info in http://docs.moodle.org/dev/Acceptance_testing#Providing_values_to_steps. + * Fills a form with field/value data. * * @Given /^I set the following fields to these values:$/ * @throws ElementNotFoundException Thrown by behat_base::find @@ -253,7 +253,7 @@ class behat_forms extends behat_base { } /** - * Checks, the field matches the value. More info in http://docs.moodle.org/dev/Acceptance_testing#Providing_values_to_steps. + * Checks, the field matches the value. * * @Then /^the field "(?P(?:[^"]|\\")*)" matches value "(?P(?:[^"]|\\")*)"$/ * @throws ElementNotFoundException Thrown by behat_base::find @@ -277,7 +277,7 @@ class behat_forms extends behat_base { } /** - * Checks, the field does not match the value. More info in http://docs.moodle.org/dev/Acceptance_testing#Providing_values_to_steps. + * Checks, the field does not match the value. * * @Then /^the field "(?P(?:[^"]|\\")*)" does not match value "(?P(?:[^"]|\\")*)"$/ * @throws ExpectationException @@ -352,7 +352,7 @@ class behat_forms extends behat_base { } /** - * Checks, the provided field/value matches. More info in http://docs.moodle.org/dev/Acceptance_testing#Providing_values_to_steps. + * Checks, the provided field/value matches. * * @Then /^the following fields match these values:$/ * @throws ExpectationException @@ -372,7 +372,7 @@ class behat_forms extends behat_base { } /** - * Checks that the provided field/value pairs don't match. More info in http://docs.moodle.org/dev/Acceptance_testing#Providing_values_to_steps. + * Checks that the provided field/value pairs don't match. * * @Then /^the following fields do not match these values:$/ * @throws ExpectationException diff --git a/lib/tests/behat/behat_general.php b/lib/tests/behat/behat_general.php index e446e32f20c..b09255cc2f6 100644 --- a/lib/tests/behat/behat_general.php +++ b/lib/tests/behat/behat_general.php @@ -1280,7 +1280,6 @@ class behat_general extends behat_base { /** * Checks that the provided value exist in table. - * More info in http://docs.moodle.org/dev/Acceptance_testing#Providing_values_to_steps. * * First row may contain column headers or numeric indexes of the columns * (syntax -1- is also considered to be column index). Column indexes are @@ -1309,8 +1308,7 @@ class behat_general extends behat_base { } /** - * Checks that the provided value exist in table. - * More info in http://docs.moodle.org/dev/Acceptance_testing#Providing_values_to_steps. + * Checks that the provided values do not exist in a table. * * @Then /^the following should not exist in the "(?P[^"]*)" table:$/ * @throws ExpectationException diff --git a/lib/tests/behat/behat_hooks.php b/lib/tests/behat/behat_hooks.php index 68dcf9fecf1..8cda5a7d7f8 100644 --- a/lib/tests/behat/behat_hooks.php +++ b/lib/tests/behat/behat_hooks.php @@ -176,7 +176,7 @@ class behat_hooks extends behat_base { if (!behat_util::is_test_mode_enabled()) { throw new behat_stop_exception('Behat only can run if test mode is enabled. More info in ' . - behat_command::DOCS_URL . '#Running_tests'); + behat_command::DOCS_URL); } // Reset all data, before checking for check_server_status. @@ -303,7 +303,7 @@ class behat_hooks extends behat_base { throw new behat_stop_exception('Behat only can modify the test database and the test dataroot!'); } - $moreinfo = 'More info in ' . behat_command::DOCS_URL . '#Running_tests'; + $moreinfo = 'More info in ' . behat_command::DOCS_URL; $driverexceptionmsg = 'Selenium server is not running, you need to start it to run tests that involve Javascript. ' . $moreinfo; try { $session = $this->getSession();