MDL-69138 behat: Update session->visit() to use visit step

This commit is contained in:
Andrew Nicols 2020-06-25 14:39:38 +08:00 committed by Adrian Greeve
parent d61fa24239
commit b284293402
9 changed files with 21 additions and 23 deletions

View File

@ -49,6 +49,6 @@ class behat_auth_email extends behat_base {
$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]);
}
}

View File

@ -58,7 +58,7 @@ class behat_auth extends behat_base {
}
// 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)));

View File

@ -56,7 +56,7 @@ class behat_backup extends behat_base {
// 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.
@ -98,7 +98,7 @@ class behat_backup extends behat_base {
// 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);
@ -134,7 +134,7 @@ class behat_backup extends behat_base {
// 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.

View File

@ -121,7 +121,7 @@ class behat_calendar extends behat_base {
*/
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]);
}
@ -134,6 +134,6 @@ class behat_calendar extends behat_base {
*/
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]);
}
}

View File

@ -283,7 +283,7 @@ class behat_app extends behat_base {
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');

View File

@ -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', ['/']);
}
/**
@ -83,7 +83,7 @@ class behat_general extends behat_base {
* @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']);
}
/**
@ -92,7 +92,7 @@ class behat_general extends behat_base {
* @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']);
}
/**
@ -1057,7 +1057,7 @@ EOF;
* @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']);
}
/**

View File

@ -496,7 +496,7 @@ EOF;
// 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()) {

View File

@ -526,7 +526,7 @@ class behat_navigation extends behat_base {
}
}
$this->getSession()->visit($this->locate_path($url->out_as_local_url()));
$this->execute('behat_general::i_visit', [$url]);
}
// Restore global user variable.
@ -549,8 +549,7 @@ class behat_navigation extends behat_base {
* @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)]);
}
/**
@ -629,8 +628,7 @@ class behat_navigation extends behat_base {
* @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)]);
}
/**
@ -753,7 +751,7 @@ class behat_navigation extends behat_base {
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]);
}
/**
@ -774,13 +772,13 @@ class behat_navigation extends behat_base {
// 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'));
@ -1003,6 +1001,6 @@ class behat_navigation extends behat_base {
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]);
}
}

View File

@ -529,6 +529,6 @@ class behat_mod_forum extends behat_base {
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]);
}
}