forked from moodle/moodle
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'MDL-73348' of https://github.com/stronk7/moodle
- Loading branch information
Showing
132 changed files
with
1,674 additions
and
1,529 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,24 +22,25 @@ | |
* @copyright 2018 Carlos Escobedo <[email protected]> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
namespace core_role\privacy; | ||
|
||
defined('MOODLE_INTERNAL') || die(); | ||
|
||
use \core_role\privacy\provider; | ||
use \core_privacy\local\request\approved_contextlist; | ||
use \core_privacy\local\request\writer; | ||
use \core_privacy\tests\provider_testcase; | ||
use \core_privacy\local\request\transform; | ||
use \tool_cohortroles\api; | ||
use \core_privacy\local\request\approved_userlist; | ||
use core_role\privacy\provider; | ||
use core_privacy\local\request\approved_contextlist; | ||
use core_privacy\local\request\writer; | ||
use core_privacy\tests\provider_testcase; | ||
use core_privacy\local\request\transform; | ||
use tool_cohortroles\api; | ||
use core_privacy\local\request\approved_userlist; | ||
|
||
/** | ||
* Privacy test for core_role | ||
* | ||
* @copyright 2018 Carlos Escobedo <[email protected]> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
class core_role_privacy_testcase extends provider_testcase { | ||
class provider_test extends provider_testcase { | ||
/** | ||
* Test to check export_user_preferences. | ||
* returns user preferences data. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,14 +22,15 @@ | |
* @copyright 2018 Zig Tan <[email protected]> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
namespace tool_cohortroles\privacy; | ||
|
||
defined('MOODLE_INTERNAL') || die(); | ||
global $CFG; | ||
|
||
use \core_privacy\local\request\writer; | ||
use \core_privacy\local\request\approved_contextlist; | ||
use \tool_cohortroles\api; | ||
use \tool_cohortroles\privacy\provider; | ||
use core_privacy\local\request\writer; | ||
use core_privacy\local\request\approved_contextlist; | ||
use tool_cohortroles\api; | ||
use tool_cohortroles\privacy\provider; | ||
use core_privacy\local\request\approved_userlist; | ||
|
||
/** | ||
|
@@ -38,7 +39,7 @@ | |
* @copyright 2018 Zig Tan <[email protected]> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
class tool_cohortroles_privacy_testcase extends \core_privacy\tests\provider_testcase { | ||
class provider_test extends \core_privacy\tests\provider_testcase { | ||
|
||
/** | ||
* Overriding setUp() function to always reset after tests. | ||
|
@@ -61,7 +62,7 @@ public function test_get_contexts_for_userid() { | |
// Create course category. | ||
$coursecategory = $this->getDataGenerator()->create_category(); | ||
$coursecategoryctx = \context_coursecat::instance($coursecategory->id); | ||
$systemctx = context_system::instance(); | ||
$systemctx = \context_system::instance(); | ||
// Create course. | ||
$course = $this->getDataGenerator()->create_course(); | ||
$coursectx = \context_course::instance($course->id); | ||
|
@@ -102,7 +103,7 @@ public function test_export_user_data() { | |
// Create course category. | ||
$coursecategory = $this->getDataGenerator()->create_category(); | ||
$coursecategoryctx = \context_coursecat::instance($coursecategory->id); | ||
$systemctx = context_system::instance(); | ||
$systemctx = \context_system::instance(); | ||
// Create course. | ||
$course = $this->getDataGenerator()->create_course(); | ||
$coursectx = \context_course::instance($course->id); | ||
|
@@ -154,7 +155,7 @@ public function test_delete_data_for_all_users_in_context() { | |
// Create course category. | ||
$coursecategory = $this->getDataGenerator()->create_category(); | ||
$coursecategoryctx = \context_coursecat::instance($coursecategory->id); | ||
$systemctx = context_system::instance(); | ||
$systemctx = \context_system::instance(); | ||
|
||
$this->setup_test_scenario_data($user->id, $systemctx, 1); | ||
$this->setup_test_scenario_data($user->id, $coursecategoryctx, 1, 'Sausage roll 2', | ||
|
@@ -170,7 +171,7 @@ public function test_delete_data_for_all_users_in_context() { | |
$this->assertCount(2, $contexts); | ||
|
||
// Make sure the user data is only being deleted in within the system and course category context. | ||
$usercontext = context_user::instance($user->id); | ||
$usercontext = \context_user::instance($user->id); | ||
// Delete all the User's records in mdl_tool_cohortroles table by the user context. | ||
provider::delete_data_for_all_users_in_context($usercontext); | ||
|
||
|
@@ -213,7 +214,7 @@ public function test_delete_data_for_user() { | |
// Create course category. | ||
$coursecategory = $this->getDataGenerator()->create_category(); | ||
$coursecategoryctx = \context_coursecat::instance($coursecategory->id); | ||
$systemctx = context_system::instance(); | ||
$systemctx = \context_system::instance(); | ||
|
||
$this->setup_test_scenario_data($user->id, $systemctx, 1); | ||
$this->setup_test_scenario_data($user->id, $coursecategoryctx, 1, 'Sausage roll 2', | ||
|
@@ -229,7 +230,7 @@ public function test_delete_data_for_user() { | |
$this->assertCount(2, $contexts); | ||
|
||
// Make sure the user data is only being deleted in within the system and the course category contexts. | ||
$usercontext = context_user::instance($user->id); | ||
$usercontext = \context_user::instance($user->id); | ||
// Delete all the User's records in mdl_tool_cohortroles table by the specified approved context list. | ||
$approvedcontextlist = new approved_contextlist($user, 'tool_cohortroles', [$usercontext->id]); | ||
provider::delete_data_for_user($approvedcontextlist); | ||
|
@@ -255,12 +256,12 @@ public function test_get_users_in_context() { | |
|
||
// Create a user. | ||
$user = $this->getDataGenerator()->create_user(); | ||
$usercontext = context_user::instance($user->id); | ||
$usercontext = \context_user::instance($user->id); | ||
|
||
// Create course category. | ||
$coursecategory = $this->getDataGenerator()->create_category(); | ||
$coursecategoryctx = \context_coursecat::instance($coursecategory->id); | ||
$systemctx = context_system::instance(); | ||
$systemctx = \context_system::instance(); | ||
|
||
$this->setAdminUser(); | ||
|
||
|
@@ -301,12 +302,12 @@ public function test_delete_data_for_users() { | |
$user2 = $this->getDataGenerator()->create_user(); | ||
// Create user3. | ||
$user3 = $this->getDataGenerator()->create_user(); | ||
$usercontext3 = context_user::instance($user3->id); | ||
$usercontext3 = \context_user::instance($user3->id); | ||
|
||
// Create course category. | ||
$coursecategory = $this->getDataGenerator()->create_category(); | ||
$coursecategoryctx = \context_coursecat::instance($coursecategory->id); | ||
$systemctx = context_system::instance(); | ||
$systemctx = \context_system::instance(); | ||
|
||
$this->setAdminUser(); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,7 @@ | |
* @copyright 2020 Paul Holden <[email protected]> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
namespace tool_dataprivacy\privacy; | ||
|
||
defined('MOODLE_INTERNAL') || die(); | ||
|
||
|
@@ -38,7 +39,7 @@ | |
* @copyright 2020 Paul Holden <[email protected]> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
class tool_dataprivacy_privacy_provider_testcase extends provider_testcase { | ||
class provider_test extends provider_testcase { | ||
|
||
/** | ||
* Test provider get_contexts_for_userid method | ||
|
@@ -49,7 +50,7 @@ public function test_get_contexts_for_userid() { | |
$this->resetAfterTest(); | ||
|
||
$user = $this->getDataGenerator()->create_user(); | ||
$context = context_user::instance($user->id); | ||
$context = \context_user::instance($user->id); | ||
|
||
// Returned context list should contain a single item. | ||
$contextlist = $this->get_contexts_for_userid($user->id, 'tool_dataprivacy'); | ||
|
@@ -68,7 +69,7 @@ public function test_get_users_in_context() { | |
$this->resetAfterTest(); | ||
|
||
$user = $this->getDataGenerator()->create_user(); | ||
$context = context_user::instance($user->id); | ||
$context = \context_user::instance($user->id); | ||
|
||
$userlist = new userlist($context, 'tool_dataprivacy'); | ||
provider::get_users_in_context($userlist); | ||
|
@@ -82,7 +83,7 @@ public function test_get_users_in_context() { | |
* @return void | ||
*/ | ||
public function test_get_users_in_context_non_user_context() { | ||
$context = context_system::instance(); | ||
$context = \context_system::instance(); | ||
|
||
$userlist = new userlist($context, 'tool_dataprivacy'); | ||
provider::get_users_in_context($userlist); | ||
|
@@ -99,7 +100,7 @@ public function test_export_user_data() { | |
$this->resetAfterTest(); | ||
|
||
$user = $this->getDataGenerator()->create_user(); | ||
$context = context_user::instance($user->id); | ||
$context = \context_user::instance($user->id); | ||
|
||
$this->setUser($user); | ||
|
||
|
@@ -170,7 +171,7 @@ public function test_export_user_preferences() { | |
provider::export_user_preferences($user->id); | ||
|
||
/** @var \core_privacy\tests\request\content_writer $writer */ | ||
$writer = writer::with_context(context_system::instance()); | ||
$writer = writer::with_context(\context_system::instance()); | ||
$this->assertTrue($writer->has_any_data()); | ||
|
||
/** @var stdClass[] $preferences */ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,7 @@ | |
* @author Frédéric Massart <[email protected]> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
namespace logstore_database\privacy; | ||
|
||
defined('MOODLE_INTERNAL') || die(); | ||
global $CFG; | ||
|
@@ -34,7 +35,7 @@ | |
use core_privacy\local\request\writer; | ||
use logstore_database\privacy\provider; | ||
|
||
require_once(__DIR__ . '/fixtures/event.php'); | ||
require_once(__DIR__ . '/../fixtures/event.php'); | ||
|
||
/** | ||
* Data provider testcase class. | ||
|
@@ -48,7 +49,7 @@ | |
* @author Frédéric Massart <[email protected]> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
class logstore_database_privacy_testcase extends provider_testcase { | ||
class provider_test extends provider_testcase { | ||
|
||
public function setUp(): void { | ||
global $CFG; | ||
|
@@ -105,11 +106,11 @@ public function test_get_contexts_for_userid() { | |
$c2 = $this->getDataGenerator()->create_course(); | ||
$cm2 = $this->getDataGenerator()->create_module('url', ['course' => $c2]); | ||
|
||
$sysctx = context_system::instance(); | ||
$c1ctx = context_course::instance($c1->id); | ||
$c2ctx = context_course::instance($c2->id); | ||
$cm1ctx = context_module::instance($cm1->cmid); | ||
$cm2ctx = context_module::instance($cm2->cmid); | ||
$sysctx = \context_system::instance(); | ||
$c1ctx = \context_course::instance($c1->id); | ||
$c2ctx = \context_course::instance($c2->id); | ||
$cm1ctx = \context_module::instance($cm1->cmid); | ||
$cm2ctx = \context_module::instance($cm2->cmid); | ||
|
||
$this->enable_logging(); | ||
$manager = get_log_manager(true); | ||
|
@@ -143,7 +144,7 @@ public function test_get_contexts_for_userid() { | |
$this->assert_contextlist_equals($this->get_contextlist_for_user($u3), [$sysctx, $c1ctx]); | ||
$this->assert_contextlist_equals($this->get_contextlist_for_user($admin), [$sysctx, $c1ctx]); | ||
$this->setAdminUser(); | ||
\core\session\manager::loginas($u1->id, context_system::instance()); | ||
\core\session\manager::loginas($u1->id, \context_system::instance()); | ||
$e = \logstore_database\event\unittest_executed::create(['context' => $c2ctx, 'relateduserid' => $u3->id]); | ||
$e->trigger(); | ||
$this->assert_contextlist_equals($this->get_contextlist_for_user($u1), [$sysctx, $cm1ctx, $c2ctx]); | ||
|
@@ -163,8 +164,8 @@ public function test_add_userids_for_context() { | |
|
||
$c1 = $this->getDataGenerator()->create_course(); | ||
|
||
$sysctx = context_system::instance(); | ||
$c1ctx = context_course::instance($c1->id); | ||
$sysctx = \context_system::instance(); | ||
$c1ctx = \context_course::instance($c1->id); | ||
|
||
$this->enable_logging(); | ||
$manager = get_log_manager(true); | ||
|
@@ -185,7 +186,7 @@ public function test_add_userids_for_context() { | |
$e->trigger(); | ||
// The admin user should be added (realuserid). | ||
$this->setAdminUser(); | ||
\core\session\manager::loginas($u2->id, context_system::instance()); | ||
\core\session\manager::loginas($u2->id, \context_system::instance()); | ||
$e = \logstore_database\event\unittest_executed::create(['context' => $sysctx]); | ||
$e->trigger(); | ||
// Set off an event in a different context. User 4 should not be returned below. | ||
|
@@ -206,9 +207,9 @@ public function test_delete_data_for_user() { | |
$u2 = $this->getDataGenerator()->create_user(); | ||
$c1 = $this->getDataGenerator()->create_course(); | ||
$c2 = $this->getDataGenerator()->create_course(); | ||
$sysctx = context_system::instance(); | ||
$c1ctx = context_course::instance($c1->id); | ||
$c2ctx = context_course::instance($c2->id); | ||
$sysctx = \context_system::instance(); | ||
$c1ctx = \context_course::instance($c1->id); | ||
$c2ctx = \context_course::instance($c2->id); | ||
|
||
$this->enable_logging(); | ||
$manager = get_log_manager(true); | ||
|
@@ -247,9 +248,9 @@ public function test_delete_data_for_all_users_in_context() { | |
$u2 = $this->getDataGenerator()->create_user(); | ||
$c1 = $this->getDataGenerator()->create_course(); | ||
$c2 = $this->getDataGenerator()->create_course(); | ||
$sysctx = context_system::instance(); | ||
$c1ctx = context_course::instance($c1->id); | ||
$c2ctx = context_course::instance($c2->id); | ||
$sysctx = \context_system::instance(); | ||
$c1ctx = \context_course::instance($c1->id); | ||
$c2ctx = \context_course::instance($c2->id); | ||
|
||
$this->enable_logging(); | ||
$manager = get_log_manager(true); | ||
|
@@ -294,8 +295,8 @@ public function test_delete_data_for_userlist() { | |
$u4 = $this->getDataGenerator()->create_user(); | ||
|
||
$course = $this->getDataGenerator()->create_course(); | ||
$sysctx = context_system::instance(); | ||
$c1ctx = context_course::instance($course->id); | ||
$sysctx = \context_system::instance(); | ||
$c1ctx = \context_course::instance($course->id); | ||
|
||
$this->enable_logging(); | ||
$manager = get_log_manager(true); | ||
|
@@ -337,11 +338,11 @@ public function test_export_data_for_user() { | |
$cm1 = $this->getDataGenerator()->create_module('url', ['course' => $c1]); | ||
$c2 = $this->getDataGenerator()->create_course(); | ||
$cm2 = $this->getDataGenerator()->create_module('url', ['course' => $c2]); | ||
$sysctx = context_system::instance(); | ||
$c1ctx = context_course::instance($c1->id); | ||
$c2ctx = context_course::instance($c2->id); | ||
$cm1ctx = context_module::instance($cm1->cmid); | ||
$cm2ctx = context_module::instance($cm2->cmid); | ||
$sysctx = \context_system::instance(); | ||
$c1ctx = \context_course::instance($c1->id); | ||
$c2ctx = \context_course::instance($c2->id); | ||
$cm1ctx = \context_module::instance($cm1->cmid); | ||
$cm2ctx = \context_module::instance($cm2->cmid); | ||
|
||
$path = [get_string('privacy:path:logs', 'tool_log'), get_string('pluginname', 'logstore_database')]; | ||
$this->enable_logging(); | ||
|
Oops, something went wrong.