mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 05:58:34 +01:00
MDL-68314 core_contentbank: Backup and restore tests
This commit is contained in:
parent
3449e22683
commit
66489aea0f
@ -1063,4 +1063,32 @@ class core_backup_moodle2_testcase extends advanced_testcase {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the content bank content through a backup and restore.
|
||||
*/
|
||||
public function test_contentbank_content_backup() {
|
||||
global $DB, $USER, $CFG;
|
||||
$this->resetAfterTest();
|
||||
|
||||
$this->setAdminUser();
|
||||
$generator = $this->getDataGenerator();
|
||||
$cbgenerator = $this->getDataGenerator()->get_plugin_generator('core_contentbank');
|
||||
|
||||
// Create course and add content bank content.
|
||||
$course = $generator->create_course();
|
||||
$context = context_course::instance($course->id);
|
||||
$filepath = $CFG->dirroot . '/h5p/tests/fixtures/filltheblanks.h5p';
|
||||
$contents = $cbgenerator->generate_contentbank_data('contenttype_h5p', 2, $USER->id, $context, true, $filepath);
|
||||
$this->assertEquals(2, $DB->count_records('contentbank_content'));
|
||||
|
||||
// Do backup and restore.
|
||||
$newcourseid = $this->backup_and_restore($course);
|
||||
|
||||
// Confirm that values were transferred correctly into content bank on new course.
|
||||
$newcontext = context_course::instance($newcourseid);
|
||||
|
||||
$this->assertEquals(4, $DB->count_records('contentbank_content'));
|
||||
$this->assertEquals(2, $DB->count_records('contentbank_content', ['contextid' => $newcontext->id]));
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,45 @@
|
||||
@core @core_backup @core_contentbank
|
||||
Feature: Import course content bank content
|
||||
In order to import content from a course contentbank
|
||||
As a teacher
|
||||
I need to confirm that errors will not happen
|
||||
|
||||
Background:
|
||||
Given the following "courses" exist:
|
||||
| fullname | shortname | category |
|
||||
| Course 1 | C1 | 0 |
|
||||
| Course 2 | C2 | 0 |
|
||||
And the following "users" exist:
|
||||
| username | firstname | lastname | email |
|
||||
| teacher1 | Teacher | 1 | teacher1@example.com |
|
||||
And the following "course enrolments" exist:
|
||||
| user | course | role |
|
||||
| teacher1 | C1 | editingteacher |
|
||||
| teacher1 | C2 | editingteacher |
|
||||
And the following "contentbank content" exist:
|
||||
| course| contenttype | user | contentname |
|
||||
| C1 | contenttype_h5p | teacher1 | ipsums.h5p |
|
||||
And I log in as "teacher1"
|
||||
|
||||
Scenario: Import content bank content to another course
|
||||
Given I am on "Course 2" course homepage
|
||||
And I click on "Content bank" "link"
|
||||
And I should not see "ipsums.h5p"
|
||||
When I import "Course 1" course into "Course 2" course using this options:
|
||||
And I click on "Content bank" "link"
|
||||
Then I should see "ipsums.h5p"
|
||||
And I am on "Course 1" course homepage
|
||||
And I click on "Content bank" "link"
|
||||
And I should see "ipsums.h5p"
|
||||
|
||||
Scenario: User could configure not to import content bank
|
||||
Given I am on "Course 2" course homepage
|
||||
And I click on "Content bank" "link"
|
||||
And I should not see "ipsums.h5p"
|
||||
When I import "Course 1" course into "Course 2" course using this options:
|
||||
| Initial | Include content bank content | 0 |
|
||||
And I click on "Content bank" "link"
|
||||
Then I should not see "ipsums.h5p"
|
||||
And I am on "Course 1" course homepage
|
||||
And I click on "Content bank" "link"
|
||||
And I should see "ipsums.h5p"
|
Loading…
x
Reference in New Issue
Block a user