mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 14:27:22 +01:00
MDL-54072 tool_recyclebin: Avoid hardcoded course_modules count
One of the unit tests for tool_recyclebin makes an assumption that a fresh install of Moodle has no course modules, which is true for vanilla moodle. However there are some third party plugins (mod_oublog and mod_respondusws are the ones I've run into) that have a course module added to the frontpage course on install. So this change alters the test from comparing the count of modules in the test course with a hardcoded value to first getting the existing count of values before performing the actions that affect the count and then using that value to compare with.
This commit is contained in:
parent
fc1ef59fbe
commit
4ec4b2b65c
@ -85,6 +85,8 @@ class tool_recyclebin_course_bin_tests extends advanced_testcase {
|
||||
public function test_restore() {
|
||||
global $DB;
|
||||
|
||||
$startcount = $DB->count_records('course_modules');
|
||||
|
||||
// Delete the course module.
|
||||
course_delete_module($this->quiz->cmid);
|
||||
|
||||
@ -95,7 +97,7 @@ class tool_recyclebin_course_bin_tests extends advanced_testcase {
|
||||
}
|
||||
|
||||
// Check that it was restored and removed from the recycle bin.
|
||||
$this->assertEquals(1, $DB->count_records('course_modules'));
|
||||
$this->assertEquals($startcount, $DB->count_records('course_modules'));
|
||||
$this->assertEquals(0, count($recyclebin->get_items()));
|
||||
}
|
||||
|
||||
@ -105,6 +107,8 @@ class tool_recyclebin_course_bin_tests extends advanced_testcase {
|
||||
public function test_delete() {
|
||||
global $DB;
|
||||
|
||||
$startcount = $DB->count_records('course_modules');
|
||||
|
||||
// Delete the course module.
|
||||
course_delete_module($this->quiz->cmid);
|
||||
|
||||
@ -115,7 +119,7 @@ class tool_recyclebin_course_bin_tests extends advanced_testcase {
|
||||
}
|
||||
|
||||
// Item was deleted, so no course module was restored.
|
||||
$this->assertEquals(0, $DB->count_records('course_modules'));
|
||||
$this->assertEquals($startcount - 1, $DB->count_records('course_modules'));
|
||||
$this->assertEquals(0, count($recyclebin->get_items()));
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user