MDL-46894 make Behat backup steps more robust.

This commit is contained in:
Tim Hunt 2014-08-19 17:38:14 +01:00
parent e609e6cf02
commit ef03842ad3

View file

@ -27,6 +27,7 @@
require_once(__DIR__ . '/../../../../../lib/behat/behat_base.php'); require_once(__DIR__ . '/../../../../../lib/behat/behat_base.php');
require_once(__DIR__ . '/../../../../../lib/behat/behat_field_manager.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, use Behat\Gherkin\Node\TableNode as TableNode,
Behat\Mink\Exception\ElementNotFoundException as ElementNotFoundException, Behat\Mink\Exception\ElementNotFoundException as ElementNotFoundException,
@ -42,6 +43,19 @@ use Behat\Gherkin\Node\TableNode as TableNode,
*/ */
class behat_backup extends behat_base { 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. * Backups the specified course using the provided options. If you are interested in restoring this backup would be useful to provide a 'Filename' option.
* *
@ -60,7 +74,7 @@ class behat_backup extends behat_base {
$this->find_link($backupcourse)->click(); $this->find_link($backupcourse)->click();
// Click the backup link. // Click the backup link.
$this->find_link(get_string('backup'))->click(); $this->navigate_to_course_settings_link('backup');
$this->wait(); $this->wait();
// Initial settings. // Initial settings.
@ -110,7 +124,7 @@ class behat_backup extends behat_base {
$this->wait(); $this->wait();
// Click the import link. // Click the import link.
$this->find_link(get_string('import'))->click(); $this->navigate_to_course_settings_link('import');
$this->wait(); $this->wait();
// Select the course. // Select the course.