Skip to content

Commit

Permalink
Merge branch 'MDL-73348' of https://github.com/stronk7/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
rezaies committed Dec 22, 2021
2 parents 90c0a7a + e4a2d9c commit dacfebe
Show file tree
Hide file tree
Showing 132 changed files with 1,674 additions and 1,529 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @coversDefaultClass \tool_admin_presets\privacy\provider
*/
class privacy_provider_test extends provider_testcase {
class provider_test extends provider_testcase {

/**
* Test for provider::get_metadata().
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand All @@ -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.
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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',
Expand All @@ -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);

Expand Down Expand Up @@ -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',
Expand All @@ -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);
Expand All @@ -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();

Expand Down Expand Up @@ -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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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
Expand All @@ -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');
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);

Expand Down Expand Up @@ -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 */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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.
Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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]);
Expand All @@ -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);
Expand All @@ -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.
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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();
Expand Down
Loading

0 comments on commit dacfebe

Please sign in to comment.