Skip to content

Commit

Permalink
MDL-69138 behat: Update session->visit() to use visit step
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewnicols authored and abgreeve committed Jul 22, 2020
1 parent d61fa24 commit b284293
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 23 deletions.
2 changes: 1 addition & 1 deletion auth/email/tests/behat/behat_auth_email.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,6 @@ public function i_confirm_email_for($username) {
$confirmationpath = $confirmationurl->out_as_local_url(false);
$url = $confirmationpath . '?' . 'data='. $secret .'/'. $username;

$this->getSession()->visit($this->locate_path($url));
$this->execute('behat_general::i_visit', [$url]);
}
}
2 changes: 1 addition & 1 deletion auth/tests/behat/behat_auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function i_log_in_as(string $username, moodle_url $wantsurl = null) {
}

// Visit login page.
$this->getSession()->visit($this->locate_path($loginurl->out_as_local_url()));
$this->execute('behat_general::i_visit', [$loginurl]);

// Enter username and password.
$this->execute('behat_forms::i_set_the_field_to', array('Username', $this->escape($username)));
Expand Down
6 changes: 3 additions & 3 deletions backup/util/ui/tests/behat/behat_backup.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function i_backup_course_using_this_options($backupcourse, $options = fal
// table elements are used, and we need to catch exceptions contantly.

// Go to homepage.
$this->getSession()->visit($this->locate_path('/?redirect=0'));
$this->execute('behat_general::i_visit', ['/?redirect=0']);
$this->execute("behat_general::wait_until_the_page_is_ready");

// Click the course link.
Expand Down Expand Up @@ -98,7 +98,7 @@ public function i_perform_a_quick_backup_of_course($backupcourse) {
// table elements are used, and we need to catch exceptions contantly.

// Go to homepage.
$this->getSession()->visit($this->locate_path('/?redirect=0'));
$this->execute('behat_general::i_visit', ['/?redirect=0']);

// Click the course link.
$this->execute("behat_general::click_link", $backupcourse);
Expand Down Expand Up @@ -134,7 +134,7 @@ public function i_import_course_into_course($fromcourse, $tocourse, $options = f
// table elements are used, and we need to catch exceptions contantly.

// Go to homepage.
$this->getSession()->visit($this->locate_path('/?redirect=0'));
$this->execute('behat_general::i_visit', ['/?redirect=0']);
$this->execute("behat_general::wait_until_the_page_is_ready");

// Click the course link.
Expand Down
4 changes: 2 additions & 2 deletions calendar/tests/behat/behat_calendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public function i_hover_over_today_in_the_calendar() {
*/
public function i_view_the_calendar_for($month, $year) {
$time = make_timestamp($year, $month, 1);
$this->getSession()->visit($this->locate_path('/calendar/view.php?view=month&course=1&time='.$time));
$this->execute('behat_general::i_visit', ['/calendar/view.php?view=month&course=1&time='.$time]);

}

Expand All @@ -134,6 +134,6 @@ public function i_view_the_calendar_for($month, $year) {
*/
public function i_am_viewing_site_calendar() {
$url = new moodle_url('/calendar/view.php', ['view' => 'month']);
$this->getSession()->visit($this->locate_path($url->out_as_local_url(false)));
$this->execute('behat_general::i_visit', [$url]);
}
}
2 changes: 1 addition & 1 deletion lib/tests/behat/behat_app.php
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ protected function prepare_browser(string $url) {
global $CFG;

// Visit the Ionic URL and wait for it to load.
$this->getSession()->visit($url);
$this->execute('behat_general::i_visit', [$url]);
$this->spin(
function($context, $args) {
$title = $context->getSession()->getPage()->find('xpath', '//title');
Expand Down
8 changes: 4 additions & 4 deletions lib/tests/behat/behat_general.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class behat_general extends behat_base {
* @Given /^I am on homepage$/
*/
public function i_am_on_homepage() {
$this->getSession()->visit($this->locate_path('/'));
$this->execute('behat_general::i_visit', ['/']);
}

/**
Expand All @@ -83,7 +83,7 @@ public function i_am_on_homepage() {
* @Given /^I am on site homepage$/
*/
public function i_am_on_site_homepage() {
$this->getSession()->visit($this->locate_path('/?redirect=0'));
$this->execute('behat_general::i_visit', ['/?redirect=0']);
}

/**
Expand All @@ -92,7 +92,7 @@ public function i_am_on_site_homepage() {
* @Given /^I am on course index$/
*/
public function i_am_on_course_index() {
$this->getSession()->visit($this->locate_path('/course/index.php'));
$this->execute('behat_general::i_visit', ['/course/index.php']);
}

/**
Expand Down Expand Up @@ -1057,7 +1057,7 @@ public function should_not_exist($element, $selectortype) {
* @Given /^I trigger cron$/
*/
public function i_trigger_cron() {
$this->getSession()->visit($this->locate_path('/admin/cron.php'));
$this->execute('behat_general::i_visit', ['/admin/cron.php']);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion lib/tests/behat/behat_hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ public function before_step(BeforeStepScope $scope) {
// Again, this would be better in the BeforeSuite hook, but that does not have access to the selectors in
// order to perform the necessary searches.
$session = $this->getSession();
$session->visit($this->locate_path('/'));
$this->execute('behat_general::i_visit', ['/']);

// Checking that the root path is a Moodle test site.
if (self::is_first_scenario()) {
Expand Down
16 changes: 7 additions & 9 deletions lib/tests/behat/behat_navigation.php
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ public function i_open_my_profile_in_edit_mode() {

}
}
$this->getSession()->visit($this->locate_path($url->out_as_local_url()));
$this->execute('behat_general::i_visit', [$url]);
}

// Restore global user variable.
Expand All @@ -549,8 +549,7 @@ public function i_open_my_profile_in_edit_mode() {
* @throws Exception if the specified page cannot be determined.
*/
public function i_am_on_page(string $page) {
$this->getSession()->visit($this->locate_path(
$this->resolve_page_helper($page)->out_as_local_url()));
$this->execute('behat_general::i_visit', [$this->resolve_page_helper($page)]);
}

/**
Expand Down Expand Up @@ -629,8 +628,7 @@ protected function parse_page_name(string $page): array {
* @throws Exception if the specified page cannot be determined.
*/
public function i_am_on_page_instance(string $identifier, string $type) {
$this->getSession()->visit($this->locate_path(
$this->resolve_page_instance_helper($identifier, $type)->out_as_local_url()));
$this->execute('behat_general::i_visit', [$this->resolve_page_instance_helper($identifier, $type)]);
}

/**
Expand Down Expand Up @@ -753,7 +751,7 @@ public function i_am_on_course_homepage($coursefullname) {
global $DB;
$course = $DB->get_record("course", array("fullname" => $coursefullname), 'id', MUST_EXIST);
$url = new moodle_url('/course/view.php', ['id' => $course->id]);
$this->getSession()->visit($this->locate_path($url->out_as_local_url(false)));
$this->execute('behat_general::i_visit', [$url]);
}

/**
Expand All @@ -774,13 +772,13 @@ public function i_am_on_course_homepage_with_editing_mode_on($coursefullname) {
// Javascript is running so it is possible to grab the session ket and jump straight to editing mode.
$url->param('edit', 1);
$url->param('sesskey', $sesskey);
$this->getSession()->visit($this->locate_path($url->out_as_local_url(false)));
$this->execute('behat_general::i_visit', [$url]);

return;
}

// Visit the course page.
$this->getSession()->visit($this->locate_path($url->out_as_local_url(false)));
$this->execute('behat_general::i_visit', [$url]);

try {
$this->execute("behat_forms::press_button", get_string('turneditingon'));
Expand Down Expand Up @@ -1003,6 +1001,6 @@ public function i_am_on_fixture_page($url) {
if (!preg_match($fixtureregex, $url)) {
throw new coding_exception("URL {$url} is not a fixture URL");
}
$this->getSession()->visit($this->locate_path($url));
$this->execute('behat_general::i_visit', [$url]);
}
}
2 changes: 1 addition & 1 deletion mod/forum/tests/behat/behat_mod_forum.php
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,6 @@ protected function goto_main_post_reply($postsubject) {
global $DB;
$post = $DB->get_record("forum_posts", array("subject" => $postsubject), 'id', MUST_EXIST);
$url = new moodle_url('/mod/forum/post.php', ['reply' => $post->id]);
$this->getSession()->visit($this->locate_path($url->out_as_local_url(false)));
$this->execute('behat_general::i_visit', [$url]);
}
}

0 comments on commit b284293

Please sign in to comment.