MDL-63919 tool_dataprivacy: admin & notify fixes
This includes the following: 1) Replace $ADMIN->id by get_admin()->id. The former doesn't exist. 2) Only change the notify parameter when it has not been specified at creation time (null). If specified, observe it. 3) Set the current user in tests to admin, able to create those requests.
This commit is contained in:
committed by
Andrew Nicols
parent
cd496c0307
commit
68987522ea
@@ -235,7 +235,7 @@ class api {
|
||||
*/
|
||||
public static function create_data_request($foruser, $type, $comments = '',
|
||||
$creationmethod = data_request::DATAREQUEST_CREATION_MANUAL) {
|
||||
global $USER, $ADMIN;
|
||||
global $USER;
|
||||
|
||||
$datarequest = new data_request();
|
||||
// The user the request is being made for.
|
||||
@@ -245,7 +245,7 @@ class api {
|
||||
// NOTE: This should probably be changed. We should leave the default value for $requestinguser if
|
||||
// the request is not explicitly created by a specific user.
|
||||
$requestinguser = (isguestuser() && $creationmethod == data_request::DATAREQUEST_CREATION_AUTO) ?
|
||||
$ADMIN->id : $USER->id;
|
||||
get_admin()->id : $USER->id;
|
||||
// The user making the request.
|
||||
$datarequest->set('requestedby', $requestinguser);
|
||||
// Set status.
|
||||
|
||||
@@ -81,6 +81,7 @@ class tool_dataprivacy_user_deleted_observer_testcase extends advanced_testcase
|
||||
*/
|
||||
public function test_create_delete_data_request_export_data_request_preexists() {
|
||||
$this->resetAfterTest();
|
||||
$this->setAdminUser();
|
||||
|
||||
// Enable automatic creation of delete data requests.
|
||||
set_config('automaticdeletionrequests', 1, 'tool_dataprivacy');
|
||||
@@ -106,6 +107,7 @@ class tool_dataprivacy_user_deleted_observer_testcase extends advanced_testcase
|
||||
*/
|
||||
public function test_create_delete_data_request_ongoing_delete_data_request_preexists() {
|
||||
$this->resetAfterTest();
|
||||
$this->setAdminUser();
|
||||
|
||||
// Enable automatic creation of delete data requests.
|
||||
set_config('automaticdeletionrequests', 1, 'tool_dataprivacy');
|
||||
@@ -130,6 +132,7 @@ class tool_dataprivacy_user_deleted_observer_testcase extends advanced_testcase
|
||||
*/
|
||||
public function test_create_delete_data_request_canceled_delete_data_request_preexists() {
|
||||
$this->resetAfterTest();
|
||||
$this->setAdminUser();
|
||||
|
||||
// Enable automatic creation of delete data requests.
|
||||
set_config('automaticdeletionrequests', 1, 'tool_dataprivacy');
|
||||
@@ -159,6 +162,7 @@ class tool_dataprivacy_user_deleted_observer_testcase extends advanced_testcase
|
||||
*/
|
||||
public function test_create_delete_data_request_completed_delete_data_request_preexists() {
|
||||
$this->resetAfterTest();
|
||||
$this->setAdminUser();
|
||||
|
||||
// Enable automatic creation of delete data requests.
|
||||
set_config('automaticdeletionrequests', 1, 'tool_dataprivacy');
|
||||
|
||||
Reference in New Issue
Block a user