mirror of
https://github.com/moodle/moodle.git
synced 2025-08-07 01:46:45 +02:00
Merge branch 'MDL-54751-master-v5' of https://github.com/snake/moodle
This commit is contained in:
commit
90abff01b3
25 changed files with 725 additions and 25 deletions
|
@ -152,6 +152,17 @@ function tool_recyclebin_pre_course_module_delete($cm) {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Hook called to check whether async course module deletion should be performed or not.
|
||||
*
|
||||
* @return true if background deletion is required (is the recyclebin is enabled), false otherwise.
|
||||
*/
|
||||
function tool_recyclebin_course_module_background_deletion_recommended() {
|
||||
if (\tool_recyclebin\course_bin::is_enabled()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Hook called before we delete a course.
|
||||
*
|
||||
|
|
|
@ -58,6 +58,7 @@ Feature: Backup user data
|
|||
And I follow "Course 1"
|
||||
And I turn editing mode on
|
||||
And I delete "Quiz 1" activity
|
||||
And I run all adhoc tasks
|
||||
And I navigate to "Recycle bin" node in "Course administration"
|
||||
And I should see "Quiz 1"
|
||||
And I click on "Restore" "link" in the "region-main" "region"
|
||||
|
|
|
@ -69,6 +69,7 @@ Feature: Basic recycle bin functionality
|
|||
| Assignment name | Test assign |
|
||||
| Description | Test |
|
||||
And I delete "Test assign" activity
|
||||
And I run all adhoc tasks
|
||||
And I navigate to "Recycle bin" node in "Course administration"
|
||||
When I click on "Delete" "link"
|
||||
Then I should see "Are you sure you want to delete the selected item from the recycle bin?"
|
||||
|
@ -92,6 +93,7 @@ Feature: Basic recycle bin functionality
|
|||
| Description | Test 2 |
|
||||
And I delete "Test assign 1" activity
|
||||
And I delete "Test assign 2" activity
|
||||
And I run all adhoc tasks
|
||||
And I navigate to "Recycle bin" node in "Course administration"
|
||||
And I should see "Test assign 1"
|
||||
And I should see "Test assign 2"
|
||||
|
|
|
@ -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