Show
Run unit tests and make sure all is good
Make sure the new calendar units tests are executed with the phpunit run. Check phpunit.xml and make sure there is an entry for calendar.
Setup a ws client of your choice. (/moodle/admin/settings.php?section=webservicesoverview might help)
create 6 calendar events (1 site, 1 course with 2 childern(using repeat in new event form), 1 group event, 1 user event)
Goto event table in database using database browser of your choice and note the ids of each of them.
Lets say the ids are 1, 2-3-4,5,6 respectively
Assign a user the permission to make ws calls
Enrol this user in the course and group for events above as student.
Modfiy student role and remove the following permissions:-
moodle/calendar:manageownentries from user context
moodle/calendar:managegroupentries from course context
moodle/calendar:manageentries from course context
moodle/calendar:manageentries from site context (You will need to enable the student role for site context from admin>users>permissions>define role)
try making the ws call to delete all events, param would be something like (assuming you are using xml rpc client, if you are using something else refer the api documentation for correct params format)
$events = array(
array('eventid' => $siteevent->id, 'repeat' => 0),
array('eventid' => $courseevent->id, 'repeat' => 0),
array('eventid' => $userevent->id, 'repeat' => 0),
array('eventid' => $groupevent->id, 'repeat' => 0)
);
Since the user doesn't have the permissions the events should not be deleted.
Give back the user cap 9.1 and make a ws call with the following param, and make sure it is deleted
$events = array(
array('eventid' => $userevent->id, 'repeat' => 0),
);
Give back user all caps as step 9 and making delete call with following params:-
$events = array(
array('eventid' => $siteevent->id, 'repeat' => 0),
array('eventid' => $courseevent->id, 'repeat' => 1),
array('eventid' => $groupevent->id, 'repeat' => 0)
);
Make sure all events are deleted.
Treat yourself for getting through this crappy test