mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 08:26:37 +02:00
Merge branch 'MDL-38690_master' of git://github.com/dmonllao/moodle
This commit is contained in:
commit
991dcb1b82
2 changed files with 93 additions and 0 deletions
|
@ -82,6 +82,61 @@ class behat_backup extends behat_base {
|
|||
$this->find_button('Continue')->press();
|
||||
}
|
||||
|
||||
/**
|
||||
* Imports the specified origin course into the other course using the provided options.
|
||||
*
|
||||
* Keeping it separatelly from backup & restore, it the number of
|
||||
* steps and duplicate code becomes bigger a common method should
|
||||
* be generalized.
|
||||
*
|
||||
* @Given /^I import "(?P<from_course_fullname_string>(?:[^"]|\\")*)" course into "(?P<to_course_fullname_string>(?:[^"]|\\")*)" course using this options:$/
|
||||
* @param string $fromcourse
|
||||
* @param string $tocourse
|
||||
* @param TableNode $options
|
||||
*/
|
||||
public function i_import_course_into_course($fromcourse, $tocourse, $options = false) {
|
||||
|
||||
// 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($tocourse)->click();
|
||||
|
||||
// Click the backup link.
|
||||
$this->find_link('Import')->click();
|
||||
|
||||
// Select the course.
|
||||
$exception = new ExpectationException('"' . $fromcourse . '" course not found in the list of courses to import from', $this->getSession());
|
||||
|
||||
$fromcourse = str_replace("'", "\'", $fromcourse);
|
||||
$xpath = "//div[contains(concat(' ', @class, ' '), ' ics-results ')]
|
||||
/descendant::tr[contains(., '" . $fromcourse . "')]
|
||||
/descendant::input[@type='radio']";
|
||||
$radionode = $this->find('xpath', $xpath, $exception);
|
||||
$radionode->check();
|
||||
$radionode->click();
|
||||
|
||||
$this->find_button('Continue')->press();
|
||||
|
||||
// Initial settings.
|
||||
$this->fill_backup_restore_form($options);
|
||||
$this->find_button('Next')->press();
|
||||
|
||||
// Schema settings.
|
||||
$this->fill_backup_restore_form($options);
|
||||
$this->find_button('Next')->press();
|
||||
|
||||
// Run it.
|
||||
$this->find_button('Perform import')->press();
|
||||
$this->wait();
|
||||
|
||||
// Continue and redirect to 'to' course.
|
||||
$this->find_button('Continue')->press();
|
||||
}
|
||||
|
||||
/**
|
||||
* Restores the backup into the specified course and the provided options. You should be in the 'Restore' page where the backup is.
|
||||
*
|
||||
|
@ -222,6 +277,9 @@ class behat_backup extends behat_base {
|
|||
*/
|
||||
protected function process_restore($options) {
|
||||
|
||||
// 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.
|
||||
|
||||
// Settings.
|
||||
$this->fill_backup_restore_form($options);
|
||||
$this->find_button('Next')->press();
|
||||
|
|
35
backup/util/ui/tests/behat/import_course.feature
Normal file
35
backup/util/ui/tests/behat/import_course.feature
Normal file
|
@ -0,0 +1,35 @@
|
|||
@backup
|
||||
Feature: Import course's contents into another course
|
||||
In order to move and copy contents between courses
|
||||
As a moodle teacher
|
||||
I need to import a course contents into another course selecting what I want to import
|
||||
|
||||
@javascript
|
||||
Scenario: Import course's contents to another course
|
||||
Given the following "courses" exists:
|
||||
| fullname | shortname | category |
|
||||
| Course 1 | C1 | 0 |
|
||||
| Course 2 | C2 | 0 |
|
||||
And the following "users" exists:
|
||||
| username | firstname | lastname | email |
|
||||
| teacher1 | Teacher | 1 | teacher1@asd.com |
|
||||
And the following "course enrolments" exists:
|
||||
| user | course | role |
|
||||
| teacher1 | C1 | editingteacher |
|
||||
| teacher1 | C2 | editingteacher |
|
||||
And I log in as "teacher1"
|
||||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I add a "Database" to section "1" and I fill the form with:
|
||||
| Name | Test database name |
|
||||
| Description | Test database description |
|
||||
And I add a "Forum" to section "2" and I fill the form with:
|
||||
| Forum name | Test forum name |
|
||||
| Description | Test forum description |
|
||||
And I add the "Comments" block
|
||||
And I add the "Recent blog entries" block
|
||||
When I import "Course 1" course into "Course 2" course using this options:
|
||||
Then I should see "Test database name"
|
||||
And I should see "Test forum name"
|
||||
And I should see "Comments"
|
||||
And I should see "Recent blog entries"
|
Loading…
Add table
Add a link
Reference in a new issue