From bae30ef320040f95b09027d25c20382ee5bccd17 Mon Sep 17 00:00:00 2001 From: Sam Hemelryk Date: Wed, 23 Jul 2014 13:18:22 +1200 Subject: [PATCH] MDL-46481 backup: behat tests for the quick backup button --- .../ui/tests/behat/backup_courses.feature | 5 +++ backup/util/ui/tests/behat/behat_backup.php | 37 +++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/backup/util/ui/tests/behat/backup_courses.feature b/backup/util/ui/tests/behat/backup_courses.feature index 94e02e3c67e..ee3fea39ca8 100644 --- a/backup/util/ui/tests/behat/backup_courses.feature +++ b/backup/util/ui/tests/behat/backup_courses.feature @@ -60,3 +60,8 @@ Feature: Backup Moodle courses And I press "Next" And I should see "Test assign" And I should not see "Test data" + + @javascript + Scenario: Backup a course using the one click backup button + When I perform a quick backup of course "Course 2" + Then I should see "Restore" \ No newline at end of file diff --git a/backup/util/ui/tests/behat/behat_backup.php b/backup/util/ui/tests/behat/behat_backup.php index 9a230edcb4f..064bfac0abd 100644 --- a/backup/util/ui/tests/behat/behat_backup.php +++ b/backup/util/ui/tests/behat/behat_backup.php @@ -77,6 +77,9 @@ class behat_backup extends behat_base { $this->navigate_to_course_settings_link('backup'); $this->wait(); + // Expand the backup settings section. + $this->find_link(get_string('backupsettings', 'backup'))->click(); + // Initial settings. $this->fill_backup_restore_form($this->get_step_options($options, "Initial")); $this->find_button(get_string('backupstage1action', 'backup'))->press(); @@ -98,6 +101,40 @@ class behat_backup extends behat_base { $this->find_button(get_string('backupstage16action', 'backup'))->press(); } + /** + * Performs a quick (one click) backup of a course. + * + * Please note that because you can't set settings with this there is no way to know what the filename + * that was produced was. It contains a timestamp making it hard to find. + * + * @Given /^I perform a quick backup of course "(?P(?:[^"]|\\")*)"$/ + * @param string $backupcourse + */ + public function i_perform_a_quick_backup_of_course($backupcourse) { + // We can not use other steps here as we don't know where the provided data + // table elements are used, and we need to catch exceptions contantly. + + // Go to homepage. + $this->getSession()->visit($this->locate_path('/')); + + // Click the course link. + $this->find_link($backupcourse)->click(); + + // Click the backup link. + $this->find_link(get_string('backup'))->click(); + $this->wait(); + + // Initial settings. + $this->find_button(get_string('performoneclickbackup', 'backup'))->press(); + $this->wait(); + + // Waiting for it to finish. + $this->wait(self::EXTENDED_TIMEOUT); + + // Last backup continue button. + $this->find_button(get_string('backupstage16action', 'backup'))->press(); + } + /** * Imports the specified origin course into the other course using the provided options. * -- 2.43.0