MDL-87621 subsection: Fix automated tests to include summary field
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
@mod @mod_subsection @_file_upload
|
||||
@mod @mod_subsection
|
||||
Feature: Subsection clean descriptions
|
||||
In order to manage subsection descriptions
|
||||
As an administrator
|
||||
@@ -8,19 +8,17 @@ Feature: Subsection clean descriptions
|
||||
Given the following "courses" exist:
|
||||
| fullname | shortname | category |
|
||||
| Course 1 | C1 | 0 |
|
||||
And the following config values are set as admin:
|
||||
| enableasyncbackup | 0 |
|
||||
And I am on the "Course 1" "restore" page logged in as "admin"
|
||||
And I press "Manage course backups"
|
||||
And I upload "mod/subsection/tests/fixtures/subsections_with_descriptions.mbz" file to "Files" filemanager
|
||||
And I press "Save changes"
|
||||
And I restore "subsections_with_descriptions.mbz" backup into a new course using this options:
|
||||
| Schema | Course name | Course 2 |
|
||||
| Schema | Course short name | C2 |
|
||||
| Course 2 | C2 | 0 |
|
||||
And the following "activities" exist:
|
||||
| activity | name | course | idnumber | section | summary |
|
||||
| subsection | Subsection1 | C1 | subsection1 | 1 | Test Subsection1 summary |
|
||||
| subsection | subsection3 | C1 | subsection3 | 1 | |
|
||||
| subsection | subsection2 | C2 | subsection2 | 1 | Test Subsection2 summary |
|
||||
|
||||
@javascript
|
||||
Scenario: Migrate subsection descriptions
|
||||
Given I navigate to "Plugins > Activity modules > Subsection" in site administration
|
||||
Given I log in as "admin"
|
||||
And I navigate to "Plugins > Activity modules > Subsection" in site administration
|
||||
And I should see "This site has 2 subsection descriptions that are no longer visible to users."
|
||||
When I click on "Migrate descriptions" "link" in the "region-main" "region"
|
||||
And I should see "This will migrate 2 subsection descriptions to Text and Media areas." in the "Migrate all subsection descriptions?" "dialogue"
|
||||
@@ -36,7 +34,8 @@ Feature: Subsection clean descriptions
|
||||
|
||||
@javascript
|
||||
Scenario: Delete subsection descriptions
|
||||
Given I navigate to "Plugins > Activity modules > Subsection" in site administration
|
||||
Given I log in as "admin"
|
||||
And I navigate to "Plugins > Activity modules > Subsection" in site administration
|
||||
And I should see "This site has 2 subsection descriptions that are no longer visible to users."
|
||||
When I click on "Delete descriptions" "link" in the "region-main" "region"
|
||||
And I should see "This will permanently delete 2 subsection descriptions from the database." in the "Delete all subsection descriptions?" "dialogue"
|
||||
|
||||
@@ -35,8 +35,12 @@ final class migrate_subsection_descriptions_task_test extends \advanced_testcase
|
||||
$this->setAdminUser();
|
||||
|
||||
$course = $this->getDataGenerator()->create_course(['format' => 'topics', 'numsections' => 1]);
|
||||
// Add subsection with description.
|
||||
$summarytext = 'Section with description';
|
||||
$this->getDataGenerator()->create_module('subsection', ['course' => $course->id, 'section' => 1]);
|
||||
$this->getDataGenerator()->create_module(
|
||||
'subsection',
|
||||
['course' => $course->id, 'section' => 1, 'summary' => $summarytext],
|
||||
);
|
||||
// Add forum to the subsection to test the order of the modules is preserved.
|
||||
$this->getDataGenerator()->create_module(
|
||||
'forum',
|
||||
@@ -46,25 +50,9 @@ final class migrate_subsection_descriptions_task_test extends \advanced_testcase
|
||||
'section' => 2,
|
||||
],
|
||||
);
|
||||
// Add description to course sections and the subsection.
|
||||
$DB->set_field(
|
||||
'course_sections',
|
||||
'summary',
|
||||
$summarytext,
|
||||
['course' => $course->id],
|
||||
);
|
||||
// Add another subsection without description.
|
||||
$this->getDataGenerator()->create_module('subsection', ['course' => $course->id, 'section' => 1]);
|
||||
|
||||
// Check only 2 sections and 1 subsection have description.
|
||||
$this->assertEquals(
|
||||
3,
|
||||
$DB->count_records_select(
|
||||
'course_sections',
|
||||
'course = :courseid AND summary != \'\'',
|
||||
['courseid' => $course->id],
|
||||
),
|
||||
);
|
||||
$this->assertEquals(
|
||||
2,
|
||||
$DB->count_records_select(
|
||||
@@ -113,15 +101,6 @@ final class migrate_subsection_descriptions_task_test extends \advanced_testcase
|
||||
'Subsection descriptions migration task completed. Total migrated subsections: 1',
|
||||
trim($output),
|
||||
);
|
||||
// Check only 2 sections keep having description after running the task.
|
||||
$this->assertEquals(
|
||||
2,
|
||||
$DB->count_records_select(
|
||||
'course_sections',
|
||||
'course = :courseid AND summary != \'\'',
|
||||
['courseid' => $course->id],
|
||||
),
|
||||
);
|
||||
// Check no subsection has description after running the task.
|
||||
$this->assertEquals(
|
||||
0,
|
||||
@@ -184,19 +163,16 @@ final class migrate_subsection_descriptions_task_test extends \advanced_testcase
|
||||
$this->setAdminUser();
|
||||
|
||||
$course = $this->getDataGenerator()->create_course(['format' => 'topics', 'numsections' => 1]);
|
||||
// Add subsection with file in the description.
|
||||
$summarytext = 'Subsection text with <a href="@@PLUGINFILE@@/intro.txt">link</a>';
|
||||
$this->getDataGenerator()->create_module('subsection', ['course' => $course->id, 'section' => 1]);
|
||||
$this->getDataGenerator()->create_module(
|
||||
'subsection',
|
||||
['course' => $course->id, 'section' => 1, 'summary' => $summarytext],
|
||||
);
|
||||
$subsection = $DB->get_record(
|
||||
'course_sections',
|
||||
['course' => $course->id, 'section' => 2],
|
||||
);
|
||||
// Add description to the subsection.
|
||||
$DB->set_field(
|
||||
'course_sections',
|
||||
'summary',
|
||||
$summarytext,
|
||||
['course' => $course->id, 'section' => $subsection->section],
|
||||
);
|
||||
$filerecord = [
|
||||
'component' => 'course',
|
||||
'filearea' => 'section',
|
||||
@@ -321,24 +297,13 @@ final class migrate_subsection_descriptions_task_test extends \advanced_testcase
|
||||
$this->setAdminUser();
|
||||
|
||||
$course = $this->getDataGenerator()->create_course(['format' => 'topics', 'numsections' => 1]);
|
||||
$summarytext = 'Section with description';
|
||||
$this->getDataGenerator()->create_module('subsection', ['course' => $course->id, 'section' => 1]);
|
||||
// Add description to course sections and the subsection.
|
||||
$DB->set_field(
|
||||
'course_sections',
|
||||
'summary',
|
||||
$summarytext,
|
||||
['course' => $course->id],
|
||||
);
|
||||
// Check only 2 sections and 1 subsection have description.
|
||||
$this->assertEquals(
|
||||
3,
|
||||
$DB->count_records_select(
|
||||
'course_sections',
|
||||
'course = :courseid AND summary != \'\'',
|
||||
['courseid' => $course->id],
|
||||
),
|
||||
// Add subsection with description.
|
||||
$this->getDataGenerator()->create_module(
|
||||
'subsection',
|
||||
['course' => $course->id, 'section' => 1, 'summary' => 'Summary text'],
|
||||
);
|
||||
|
||||
// Check subsection has description.
|
||||
$this->assertEquals(
|
||||
1,
|
||||
$DB->count_records_select(
|
||||
@@ -433,18 +398,15 @@ final class migrate_subsection_descriptions_task_test extends \advanced_testcase
|
||||
$this->setAdminUser();
|
||||
|
||||
$course = $this->getDataGenerator()->create_course(['format' => 'topics', 'numsections' => 1]);
|
||||
// Add subsections with description.
|
||||
for ($i = 0; $i < 101; $i++) {
|
||||
$this->getDataGenerator()->create_module('subsection', ['course' => $course->id, 'section' => 1]);
|
||||
$this->getDataGenerator()->create_module(
|
||||
'subsection',
|
||||
['course' => $course->id, 'section' => 1, 'summary' => 'Summary text'],
|
||||
);
|
||||
}
|
||||
// Add description to course sections and subsections.
|
||||
$DB->set_field(
|
||||
'course_sections',
|
||||
'summary',
|
||||
'Section with description',
|
||||
['course' => $course->id],
|
||||
);
|
||||
|
||||
// Check 101 subsections have description.
|
||||
// Check all subsections have description.
|
||||
$this->assertEquals(
|
||||
101,
|
||||
$DB->count_records_select(
|
||||
|
||||
Reference in New Issue
Block a user