mirror of
https://github.com/moodle/moodle.git
synced 2025-08-07 01:46:45 +02:00
MDL-54751 phpunit: Support adhoc module and section deletion in phpunit
Created a new phpunit util function run_all_adhoc_tasks which runs any pending tasks, for use in unit tests. Added new recyclebin and course unit tests covering the new functionality.
This commit is contained in:
parent
2f6e0d92b7
commit
3704ff8cde
3 changed files with 313 additions and 0 deletions
|
@ -71,6 +71,9 @@ class tool_recyclebin_course_bin_tests extends advanced_testcase {
|
|||
// Delete the course module.
|
||||
course_delete_module($this->quiz->cmid);
|
||||
|
||||
// Now, run the course module deletion adhoc task.
|
||||
phpunit_util::run_all_adhoc_tasks();
|
||||
|
||||
// Check the course module is now in the recycle bin.
|
||||
$this->assertEquals(1, $DB->count_records('tool_recyclebin_course'));
|
||||
|
||||
|
@ -112,6 +115,9 @@ class tool_recyclebin_course_bin_tests extends advanced_testcase {
|
|||
// Delete the course module.
|
||||
course_delete_module($this->quiz->cmid);
|
||||
|
||||
// Now, run the course module deletion adhoc task.
|
||||
phpunit_util::run_all_adhoc_tasks();
|
||||
|
||||
// Try purging.
|
||||
$recyclebin = new \tool_recyclebin\course_bin($this->course->id);
|
||||
foreach ($recyclebin->get_items() as $item) {
|
||||
|
@ -134,6 +140,9 @@ class tool_recyclebin_course_bin_tests extends advanced_testcase {
|
|||
// Delete the quiz.
|
||||
course_delete_module($this->quiz->cmid);
|
||||
|
||||
// Now, run the course module deletion adhoc task.
|
||||
phpunit_util::run_all_adhoc_tasks();
|
||||
|
||||
// Set deleted date to the distant past.
|
||||
$recyclebin = new \tool_recyclebin\course_bin($this->course->id);
|
||||
foreach ($recyclebin->get_items() as $item) {
|
||||
|
@ -147,6 +156,9 @@ class tool_recyclebin_course_bin_tests extends advanced_testcase {
|
|||
|
||||
course_delete_module($book->cmid);
|
||||
|
||||
// Now, run the course module deletion adhoc task.
|
||||
phpunit_util::run_all_adhoc_tasks();
|
||||
|
||||
// Should have 2 items now.
|
||||
$this->assertEquals(2, count($recyclebin->get_items()));
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue