MDL-48012 tool_recyclebin: multiple changes before integration

- Added new icon for the recycle bin.
- Fixed issue where the course expiry setting was being used to display
  the expiry messages in the category bin.
- Fixed failing Behat tests.
- Tidied Behat tests.
  - General tidy up.
  - Deleted three Behat feature files.
    - Deleted 'delete_confirmation.feature' as it's testing JS functionality
      that was removed (see comment further down). The 'basic_functionality.feature'
      now tests deleting an activity and a course.
    - Deleted 'description.feature' and added the tested functionality to
      'basic_functionality.feature'.
    - Deleted 'logs_test.feature' and moved testing to PHPUnit tests.
  - Added another scenario for restoring a course.
- Removed protected mod settings - it was discussed that this was not a necessary
  feature. We should not be treating the recycle bin as a backup.
- Renamed events to conform to guidelines.
- Wrote new PHPUnit tests for events.
- Tidied up existing PHPUnit tests and extended them.
- Alphabetised lang file.
- Made changes to strings and string identifiers in the lang file and changed usages in code.
- Changed setting names to better identify their purpose.
- Renamed classes and file names so it's easier to identify their purpose.
- Renamed the 'deleted' column to 'timecreated' for consistency with other
  Moodle tables, and to easily identify what the value represents.
- Changed the columns 'category' and 'course' to 'categoryid' and
  'courseid' respectively.
- Changed the name of the table indexes for consistency with core.
- Removed module.js and any use of it and replaced with Moodle core libraries
  for JS confirmation.
- Removed 'noevent' argument in delete_item().
- Removed unnecessary capabilities - we can use the same capabilties for both
  recycle bins based on the context the capability was given.
- Removed '_' in the capability definitions to keep it consistent with core.
- Set page layout and headings for index.php - varies between the course and
  category recycle bins.
- Deleted styles.css and centred columns using the flexible_table API.
- Fixed IDE and codechecker complaints.
- Made use of the files API, rather than writing directly to
  "$CFG->dataroot . '/recyclebin'".
- Used make_temp_directory rather than expecting it to exist.
- Replaced debugging function calls with calls to the backup API to
  display errors.
- Deleted the temporary backup file after a successful restore, or if it fails.
- If the restore fails for a course, delete the course we created.
- Removed unnecessary '\' characters when not in namespace.
- Used configduration class for expiry times in the settings.
- Cleanup course bin when a course is deleted.
- Cleanup a category bin when a category is deleted.
- Removed unnecessary throw tags.
- Changed default settings.
This commit is contained in:
Mark Nelson
2016-03-18 14:12:08 +08:00
parent 1c42ad7135
commit 93af6a610e
33 changed files with 1126 additions and 964 deletions
@@ -1,8 +1,8 @@
@tool @tool_recyclebin
Feature: Basic recycle bin functionality
As a teacher
I want be able to recover deleted content
So that I can fix a mistake or accidently deletion
I want be able to recover deleted content and manage the recycle bin content
So that I can fix an accidental deletion and clean the recycle bin
Background: Course with teacher exists.
Given the following "users" exist:
@@ -12,33 +12,95 @@ Feature: Basic recycle bin functionality
And the following "courses" exist:
| fullname | shortname |
| Course 1 | C1 |
| Course 2 | C2 |
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
And the following config values are set as admin:
| coursebinenable | 1 | tool_recyclebin |
| categorybinenable | 1 | tool_recyclebin |
| coursebinexpiry | 604800 | tool_recyclebin |
| categorybinexpiry | 1209600 | tool_recyclebin |
| autohide | 0 | tool_recyclebin |
Scenario: Restore and delete an assingnment.
Scenario: Restore a deleted assignment
Given I log in as "teacher1"
And I follow "Course 1"
And I turn editing mode on
And I add a "Page" to section "1" and I fill the form with:
| Name | Test page |
| Description | Test |
| Page content | Test |
When I delete "Test page" activity
And I follow "Recycle bin"
Then I should see "Test page"
When I follow "Restore"
Then I should see "Test page has been restored"
When I wait to be redirected
And I add a "Assignment" to section "1" and I fill the form with:
| Assignment name | Test assign |
| Description | Test |
And I delete "Test assign" activity
When I follow "Recycle bin"
Then I should see "Test assign"
And I should see "Contents will be permanently deleted after 7 days"
And I follow "Restore"
And I should see "'Test assign' has been restored"
And I wait to be redirected
And I am on homepage
And I follow "Course 1"
Then I should see "Test page" in the "Topic 1" "section"
When I delete "Test page" activity
And I follow "Recycle bin"
Then I should see "Test page"
When I follow "Delete"
Then I should see "Test page has been deleted"
When I wait to be redirected
And I am on homepage
And I should see "Test assign" in the "Topic 1" "section"
Scenario: Restore a deleted course
Given I log in as "admin"
And I go to the courses management page
And I click on "delete" action for "Course 2" in management course listing
And I press "Delete"
And I should see "Deleting C2"
And I should see "C2 has been completely deleted"
And I press "Continue"
And I go to the courses management page
And I should not see "Course 2" in the "#course-listing" "css_element"
When I follow "Recycle bin"
Then I should see "Course 2"
And I should see "Contents will be permanently deleted after 14 days"
And I follow "Restore"
And I should see "'Course 2' has been restored"
And I wait to be redirected
And I go to the courses management page
And I should see "Course 2" in the "#course-listing" "css_element"
@javascript
Scenario: Deleting a single item from the recycle bin
Given I log in as "teacher1"
And I follow "Course 1"
Then I should not see "Test page" in the "Topic 1" "section"
And I turn editing mode on
And I add a "Assignment" to section "1" and I fill the form with:
| Assignment name | Test assign |
| Description | Test |
And I delete "Test assign" activity
And I follow "Recycle bin"
When I click on "Delete" "link"
Then I should see "Are you sure you want to delete the selected item from the recycle bin?"
And I press "Cancel"
And I should see "Test assign"
And I click on "Delete" "link"
And I press "Yes"
And I should see "'Test assign' has been deleted"
And I should see "There are no items in the recycle bin."
@javascript
Scenario: Deleting all the items from the recycle bin
Given I log in as "teacher1"
And I follow "Course 1"
And I turn editing mode on
And I add a "Assignment" to section "1" and I fill the form with:
| Assignment name | Test assign 1 |
| Description | Test 1 |
And I add a "Assignment" to section "1" and I fill the form with:
| Assignment name | Test assign 2 |
| Description | Test 2 |
And I delete "Test assign 1" activity
And I delete "Test assign 2" activity
And I follow "Recycle bin"
And I should see "Test assign 1"
And I should see "Test assign 2"
When I click on "Delete all" "link"
Then I should see "Are you sure you want to delete all items from the recycle bin?"
And I press "Cancel"
And I should see "Test assign 1"
And I should see "Test assign 2"
And I click on "Delete all" "link"
And I press "Yes"
And I should see "Recycle bin has been emptied"
And I should see "There are no items in the recycle bin."