Skip to content

Commit

Permalink
MDL-46894 make Behat backup steps more robust.
Browse files Browse the repository at this point in the history
  • Loading branch information
timhunt committed Aug 21, 2014
1 parent fd72531 commit 7464e1b
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions backup/util/ui/tests/behat/behat_backup.php
Expand Up @@ -27,6 +27,7 @@

require_once(__DIR__ . '/../../../../../lib/behat/behat_base.php');
require_once(__DIR__ . '/../../../../../lib/behat/behat_field_manager.php');
require_once(__DIR__ . '/../../../../../lib/tests/behat/behat_navigation.php');

use Behat\Gherkin\Node\TableNode as TableNode,
Behat\Mink\Exception\ElementNotFoundException as ElementNotFoundException,
Expand All @@ -42,6 +43,19 @@
*/
class behat_backup extends behat_base {

/**
* Follow a link like 'Backup' or 'Import', where the link name comes from
* a language string, in the settings nav block of a course.
* @param string $langstring the lang string to look for. E.g. 'backup' or 'import'.
* @param string $component (optional) second argument to {@link get_string}.
*/
protected function navigate_to_course_settings_link($langstring, $component = '') {
$behatnavigation = new behat_navigation();
$behatnavigation->setMink($this->getMink());
$behatnavigation->i_navigate_to_node_in(get_string($langstring, $component),
get_string('courseadministration'));
}

/**
* Backups the specified course using the provided options. If you are interested in restoring this backup would be useful to provide a 'Filename' option.
*
Expand All @@ -60,7 +74,7 @@ public function i_backup_course_using_this_options($backupcourse, $options = fal
$this->find_link($backupcourse)->click();

// Click the backup link.
$this->find_link(get_string('backup'))->click();
$this->navigate_to_course_settings_link('backup');
$this->wait();

// Initial settings.
Expand Down Expand Up @@ -110,7 +124,7 @@ public function i_import_course_into_course($fromcourse, $tocourse, $options = f
$this->wait();

// Click the import link.
$this->find_link(get_string('import'))->click();
$this->navigate_to_course_settings_link('import');
$this->wait();

// Select the course.
Expand Down

0 comments on commit 7464e1b

Please sign in to comment.