MDL-34161 mod_lti: Added Behat tests

This commit is contained in:
Tim Lock 2015-05-13 13:19:18 +09:30 committed by Marina Glancy
parent 387a3a208a
commit edbcee25c1
2 changed files with 40 additions and 3 deletions

View File

@ -117,14 +117,16 @@ class restore_lti_activity_structure_step extends restore_activity_structure_ste
if ($this->task->is_samesite() && $ltitype->course != SITEID
&& $ltitype->state == LTI_TOOL_STATE_CONFIGURED) {
// If restoring into the same course, use existing data, else re-create.
$course = $this->get_courseid();
if ($ltitype->course != $course) {
$data->course = $course;
$courseid = $this->get_courseid();
if ($ltitype->course != $courseid) {
// Override course field of restore data with current courseid.
$data->course = $courseid;
$ltitype = new stdClass();
$ltitype->id = $DB->insert_record('lti_types', $data);
}
} else if (!$this->task->is_samesite() || !isset($ltitype->id)) {
// Either we are restoring into a new site, or didn't find a database match.
// Override course field of restore data with current courseid.
$data->course = $this->get_courseid();
$ltitype = new stdClass();
$ltitype->id = $DB->insert_record('lti_types', $data);

View File

@ -0,0 +1,35 @@
@mod @mod_lti @core_backup @javascript
Feature: Restoring Moodle 2 backup restores LTI configuration
Background:
Given the following "courses" exist:
| fullname | shortname | category | idnumber |
| Course 1 | C1 | 0 | C1 |
And I log in as "admin"
Scenario: Backup and restore course 1
Given I navigate to "Manage external tool types" node in "Site administration > Plugins > Activity modules > LTI"
And I follow "Add external tool configuration"
And I set the following fields to these values:
| Tool name | Site Netspot Tool |
| Tool base URL | http://www.netspot.com.au |
| lti_coursevisible | 1 |
And I press "Save changes"
And I wait to be redirected
Given I am on site homepage
Then I follow "Course 1"
Then I turn editing mode on
And I add a "External tool" to section "1" and I fill the form with:
| Activity name | Site Netspot Tool |
| External tool type | Site Netspot Tool |
| Launch container | Embed |
And I follow "Course 1"
Then I should see "Site Netspot Tool"
Then I backup "Course 1" course using this options:
| Confirmation | Filename | test_backup.mbz |
And I restore "test_backup.mbz" backup into a new course using this options:
Then I am on site homepage
And I follow "Course 1 copy 1"
And I open "Site Netspot Tool" actions menu
And I click on "Edit settings" "link" in the "Site Netspot Tool" activity
Then the field "External tool type" matches value "Site Netspot Tool"