MDL-46481 backup: behat tests for the quick backup button
authorSam Hemelryk <sam@moodle.com>
Wed, 23 Jul 2014 01:18:22 +0000 (13:18 +1200)
committerSam Hemelryk <sam@moodle.com>
Thu, 2 Oct 2014 20:43:08 +0000 (09:43 +1300)
backup/util/ui/tests/behat/backup_courses.feature
backup/util/ui/tests/behat/behat_backup.php

index 94e02e3..ee3fea3 100644 (file)
@@ -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
index 9a230ed..064bfac 100644 (file)
@@ -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<course_fullname_string>(?:[^"]|\\")*)"$/
+     * @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.
      *