Commit 57e6fb7a authored by Eloy Lafuente's avatar Eloy Lafuente
Browse files

MDL-73348 phpunit: privacy and privacy_provider testcase names

All privacy_test and privacy_provider_test classes:

- Namespaced with component\privacy.
- Fixed incorrect use statements with leading backslash.
- Changed code to point to global scope when needed.
- Renamed a few files to make all be privacy_test or privacy_provider_test.php
- All them passing individually.
- Complete runs passing too.
parent 58a729f0
...@@ -22,16 +22,17 @@ ...@@ -22,16 +22,17 @@
* @copyright 2018 Carlos Escobedo <carlos@moodle.com> * @copyright 2018 Carlos Escobedo <carlos@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/ */
namespace core_role\privacy;
defined('MOODLE_INTERNAL') || die(); defined('MOODLE_INTERNAL') || die();
use \core_role\privacy\provider; use core_role\privacy\provider;
use \core_privacy\local\request\approved_contextlist; use core_privacy\local\request\approved_contextlist;
use \core_privacy\local\request\writer; use core_privacy\local\request\writer;
use \core_privacy\tests\provider_testcase; use core_privacy\tests\provider_testcase;
use \core_privacy\local\request\transform; use core_privacy\local\request\transform;
use \tool_cohortroles\api; use tool_cohortroles\api;
use \core_privacy\local\request\approved_userlist; use core_privacy\local\request\approved_userlist;
/** /**
* Privacy test for core_role * Privacy test for core_role
...@@ -39,7 +40,7 @@ use \core_privacy\local\request\approved_userlist; ...@@ -39,7 +40,7 @@ use \core_privacy\local\request\approved_userlist;
* @copyright 2018 Carlos Escobedo <carlos@moodle.com> * @copyright 2018 Carlos Escobedo <carlos@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/ */
class core_role_privacy_testcase extends provider_testcase { class privacy_test extends provider_testcase {
/** /**
* Test to check export_user_preferences. * Test to check export_user_preferences.
* returns user preferences data. * returns user preferences data.
......
...@@ -22,14 +22,15 @@ ...@@ -22,14 +22,15 @@
* @copyright 2018 Zig Tan <zig@moodle.com> * @copyright 2018 Zig Tan <zig@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/ */
namespace tool_cohortroles\privacy;
defined('MOODLE_INTERNAL') || die(); defined('MOODLE_INTERNAL') || die();
global $CFG; global $CFG;
use \core_privacy\local\request\writer; use core_privacy\local\request\writer;
use \core_privacy\local\request\approved_contextlist; use core_privacy\local\request\approved_contextlist;
use \tool_cohortroles\api; use tool_cohortroles\api;
use \tool_cohortroles\privacy\provider; use tool_cohortroles\privacy\provider;
use core_privacy\local\request\approved_userlist; use core_privacy\local\request\approved_userlist;
/** /**
...@@ -38,7 +39,7 @@ use core_privacy\local\request\approved_userlist; ...@@ -38,7 +39,7 @@ use core_privacy\local\request\approved_userlist;
* @copyright 2018 Zig Tan <zig@moodle.com> * @copyright 2018 Zig Tan <zig@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @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 privacy_test extends \core_privacy\tests\provider_testcase {
/** /**
* Overriding setUp() function to always reset after tests. * Overriding setUp() function to always reset after tests.
...@@ -61,7 +62,7 @@ class tool_cohortroles_privacy_testcase extends \core_privacy\tests\provider_tes ...@@ -61,7 +62,7 @@ class tool_cohortroles_privacy_testcase extends \core_privacy\tests\provider_tes
// Create course category. // Create course category.
$coursecategory = $this->getDataGenerator()->create_category(); $coursecategory = $this->getDataGenerator()->create_category();
$coursecategoryctx = \context_coursecat::instance($coursecategory->id); $coursecategoryctx = \context_coursecat::instance($coursecategory->id);
$systemctx = context_system::instance(); $systemctx = \context_system::instance();
// Create course. // Create course.
$course = $this->getDataGenerator()->create_course(); $course = $this->getDataGenerator()->create_course();
$coursectx = \context_course::instance($course->id); $coursectx = \context_course::instance($course->id);
...@@ -102,7 +103,7 @@ class tool_cohortroles_privacy_testcase extends \core_privacy\tests\provider_tes ...@@ -102,7 +103,7 @@ class tool_cohortroles_privacy_testcase extends \core_privacy\tests\provider_tes
// Create course category. // Create course category.
$coursecategory = $this->getDataGenerator()->create_category(); $coursecategory = $this->getDataGenerator()->create_category();
$coursecategoryctx = \context_coursecat::instance($coursecategory->id); $coursecategoryctx = \context_coursecat::instance($coursecategory->id);
$systemctx = context_system::instance(); $systemctx = \context_system::instance();
// Create course. // Create course.
$course = $this->getDataGenerator()->create_course(); $course = $this->getDataGenerator()->create_course();
$coursectx = \context_course::instance($course->id); $coursectx = \context_course::instance($course->id);
...@@ -154,7 +155,7 @@ class tool_cohortroles_privacy_testcase extends \core_privacy\tests\provider_tes ...@@ -154,7 +155,7 @@ class tool_cohortroles_privacy_testcase extends \core_privacy\tests\provider_tes
// Create course category. // Create course category.
$coursecategory = $this->getDataGenerator()->create_category(); $coursecategory = $this->getDataGenerator()->create_category();
$coursecategoryctx = \context_coursecat::instance($coursecategory->id); $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, $systemctx, 1);
$this->setup_test_scenario_data($user->id, $coursecategoryctx, 1, 'Sausage roll 2', $this->setup_test_scenario_data($user->id, $coursecategoryctx, 1, 'Sausage roll 2',
...@@ -170,7 +171,7 @@ class tool_cohortroles_privacy_testcase extends \core_privacy\tests\provider_tes ...@@ -170,7 +171,7 @@ class tool_cohortroles_privacy_testcase extends \core_privacy\tests\provider_tes
$this->assertCount(2, $contexts); $this->assertCount(2, $contexts);
// Make sure the user data is only being deleted in within the system and course category context. // 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. // Delete all the User's records in mdl_tool_cohortroles table by the user context.
provider::delete_data_for_all_users_in_context($usercontext); provider::delete_data_for_all_users_in_context($usercontext);
...@@ -213,7 +214,7 @@ class tool_cohortroles_privacy_testcase extends \core_privacy\tests\provider_tes ...@@ -213,7 +214,7 @@ class tool_cohortroles_privacy_testcase extends \core_privacy\tests\provider_tes
// Create course category. // Create course category.
$coursecategory = $this->getDataGenerator()->create_category(); $coursecategory = $this->getDataGenerator()->create_category();
$coursecategoryctx = \context_coursecat::instance($coursecategory->id); $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, $systemctx, 1);
$this->setup_test_scenario_data($user->id, $coursecategoryctx, 1, 'Sausage roll 2', $this->setup_test_scenario_data($user->id, $coursecategoryctx, 1, 'Sausage roll 2',
...@@ -229,7 +230,7 @@ class tool_cohortroles_privacy_testcase extends \core_privacy\tests\provider_tes ...@@ -229,7 +230,7 @@ class tool_cohortroles_privacy_testcase extends \core_privacy\tests\provider_tes
$this->assertCount(2, $contexts); $this->assertCount(2, $contexts);
// Make sure the user data is only being deleted in within the system and the course category 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. // 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]); $approvedcontextlist = new approved_contextlist($user, 'tool_cohortroles', [$usercontext->id]);
provider::delete_data_for_user($approvedcontextlist); provider::delete_data_for_user($approvedcontextlist);
...@@ -255,12 +256,12 @@ class tool_cohortroles_privacy_testcase extends \core_privacy\tests\provider_tes ...@@ -255,12 +256,12 @@ class tool_cohortroles_privacy_testcase extends \core_privacy\tests\provider_tes
// Create a user. // Create a user.
$user = $this->getDataGenerator()->create_user(); $user = $this->getDataGenerator()->create_user();
$usercontext = context_user::instance($user->id); $usercontext = \context_user::instance($user->id);
// Create course category. // Create course category.
$coursecategory = $this->getDataGenerator()->create_category(); $coursecategory = $this->getDataGenerator()->create_category();
$coursecategoryctx = \context_coursecat::instance($coursecategory->id); $coursecategoryctx = \context_coursecat::instance($coursecategory->id);
$systemctx = context_system::instance(); $systemctx = \context_system::instance();
$this->setAdminUser(); $this->setAdminUser();
...@@ -301,12 +302,12 @@ class tool_cohortroles_privacy_testcase extends \core_privacy\tests\provider_tes ...@@ -301,12 +302,12 @@ class tool_cohortroles_privacy_testcase extends \core_privacy\tests\provider_tes
$user2 = $this->getDataGenerator()->create_user(); $user2 = $this->getDataGenerator()->create_user();
// Create user3. // Create user3.
$user3 = $this->getDataGenerator()->create_user(); $user3 = $this->getDataGenerator()->create_user();
$usercontext3 = context_user::instance($user3->id); $usercontext3 = \context_user::instance($user3->id);
// Create course category. // Create course category.
$coursecategory = $this->getDataGenerator()->create_category(); $coursecategory = $this->getDataGenerator()->create_category();
$coursecategoryctx = \context_coursecat::instance($coursecategory->id); $coursecategoryctx = \context_coursecat::instance($coursecategory->id);
$systemctx = context_system::instance(); $systemctx = \context_system::instance();
$this->setAdminUser(); $this->setAdminUser();
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
* @copyright 2020 Paul Holden <paulh@moodle.com> * @copyright 2020 Paul Holden <paulh@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/ */
namespace tool_dataprivacy\privacy;
defined('MOODLE_INTERNAL') || die(); defined('MOODLE_INTERNAL') || die();
...@@ -38,7 +39,7 @@ use tool_dataprivacy\privacy\provider; ...@@ -38,7 +39,7 @@ use tool_dataprivacy\privacy\provider;
* @copyright 2020 Paul Holden <paulh@moodle.com> * @copyright 2020 Paul Holden <paulh@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/ */
class tool_dataprivacy_privacy_provider_testcase extends provider_testcase { class privacy_provider_test extends provider_testcase {
/** /**
* Test provider get_contexts_for_userid method * Test provider get_contexts_for_userid method
...@@ -49,7 +50,7 @@ class tool_dataprivacy_privacy_provider_testcase extends provider_testcase { ...@@ -49,7 +50,7 @@ class tool_dataprivacy_privacy_provider_testcase extends provider_testcase {
$this->resetAfterTest(); $this->resetAfterTest();
$user = $this->getDataGenerator()->create_user(); $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. // Returned context list should contain a single item.
$contextlist = $this->get_contexts_for_userid($user->id, 'tool_dataprivacy'); $contextlist = $this->get_contexts_for_userid($user->id, 'tool_dataprivacy');
...@@ -68,7 +69,7 @@ class tool_dataprivacy_privacy_provider_testcase extends provider_testcase { ...@@ -68,7 +69,7 @@ class tool_dataprivacy_privacy_provider_testcase extends provider_testcase {
$this->resetAfterTest(); $this->resetAfterTest();
$user = $this->getDataGenerator()->create_user(); $user = $this->getDataGenerator()->create_user();
$context = context_user::instance($user->id); $context = \context_user::instance($user->id);
$userlist = new userlist($context, 'tool_dataprivacy'); $userlist = new userlist($context, 'tool_dataprivacy');
provider::get_users_in_context($userlist); provider::get_users_in_context($userlist);
...@@ -82,7 +83,7 @@ class tool_dataprivacy_privacy_provider_testcase extends provider_testcase { ...@@ -82,7 +83,7 @@ class tool_dataprivacy_privacy_provider_testcase extends provider_testcase {
* @return void * @return void
*/ */
public function test_get_users_in_context_non_user_context() { public function test_get_users_in_context_non_user_context() {
$context = context_system::instance(); $context = \context_system::instance();
$userlist = new userlist($context, 'tool_dataprivacy'); $userlist = new userlist($context, 'tool_dataprivacy');
provider::get_users_in_context($userlist); provider::get_users_in_context($userlist);
...@@ -99,7 +100,7 @@ class tool_dataprivacy_privacy_provider_testcase extends provider_testcase { ...@@ -99,7 +100,7 @@ class tool_dataprivacy_privacy_provider_testcase extends provider_testcase {
$this->resetAfterTest(); $this->resetAfterTest();
$user = $this->getDataGenerator()->create_user(); $user = $this->getDataGenerator()->create_user();
$context = context_user::instance($user->id); $context = \context_user::instance($user->id);
$this->setUser($user); $this->setUser($user);
...@@ -170,7 +171,7 @@ class tool_dataprivacy_privacy_provider_testcase extends provider_testcase { ...@@ -170,7 +171,7 @@ class tool_dataprivacy_privacy_provider_testcase extends provider_testcase {
provider::export_user_preferences($user->id); provider::export_user_preferences($user->id);
/** @var \core_privacy\tests\request\content_writer $writer */ /** @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()); $this->assertTrue($writer->has_any_data());
/** @var stdClass[] $preferences */ /** @var stdClass[] $preferences */
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
* @author Frédéric Massart <fred@branchup.tech> * @author Frédéric Massart <fred@branchup.tech>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/ */
namespace logstore_database\privacy;
defined('MOODLE_INTERNAL') || die(); defined('MOODLE_INTERNAL') || die();
global $CFG; global $CFG;
...@@ -48,7 +49,7 @@ require_once(__DIR__ . '/fixtures/event.php'); ...@@ -48,7 +49,7 @@ require_once(__DIR__ . '/fixtures/event.php');
* @author Frédéric Massart <fred@branchup.tech> * @author Frédéric Massart <fred@branchup.tech>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/ */
class logstore_database_privacy_testcase extends provider_testcase { class privacy_test extends provider_testcase {
public function setUp(): void { public function setUp(): void {
global $CFG; global $CFG;
...@@ -105,11 +106,11 @@ class logstore_database_privacy_testcase extends provider_testcase { ...@@ -105,11 +106,11 @@ class logstore_database_privacy_testcase extends provider_testcase {
$c2 = $this->getDataGenerator()->create_course(); $c2 = $this->getDataGenerator()->create_course();
$cm2 = $this->getDataGenerator()->create_module('url', ['course' => $c2]); $cm2 = $this->getDataGenerator()->create_module('url', ['course' => $c2]);
$sysctx = context_system::instance(); $sysctx = \context_system::instance();
$c1ctx = context_course::instance($c1->id); $c1ctx = \context_course::instance($c1->id);
$c2ctx = context_course::instance($c2->id); $c2ctx = \context_course::instance($c2->id);
$cm1ctx = context_module::instance($cm1->cmid); $cm1ctx = \context_module::instance($cm1->cmid);
$cm2ctx = context_module::instance($cm2->cmid); $cm2ctx = \context_module::instance($cm2->cmid);
$this->enable_logging(); $this->enable_logging();
$manager = get_log_manager(true); $manager = get_log_manager(true);
...@@ -143,7 +144,7 @@ class logstore_database_privacy_testcase extends provider_testcase { ...@@ -143,7 +144,7 @@ class logstore_database_privacy_testcase extends provider_testcase {
$this->assert_contextlist_equals($this->get_contextlist_for_user($u3), [$sysctx, $c1ctx]); $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->assert_contextlist_equals($this->get_contextlist_for_user($admin), [$sysctx, $c1ctx]);
$this->setAdminUser(); $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 = \logstore_database\event\unittest_executed::create(['context' => $c2ctx, 'relateduserid' => $u3->id]);
$e->trigger(); $e->trigger();
$this->assert_contextlist_equals($this->get_contextlist_for_user($u1), [$sysctx, $cm1ctx, $c2ctx]); $this->assert_contextlist_equals($this->get_contextlist_for_user($u1), [$sysctx, $cm1ctx, $c2ctx]);
...@@ -163,8 +164,8 @@ class logstore_database_privacy_testcase extends provider_testcase { ...@@ -163,8 +164,8 @@ class logstore_database_privacy_testcase extends provider_testcase {
$c1 = $this->getDataGenerator()->create_course(); $c1 = $this->getDataGenerator()->create_course();
$sysctx = context_system::instance(); $sysctx = \context_system::instance();
$c1ctx = context_course::instance($c1->id); $c1ctx = \context_course::instance($c1->id);
$this->enable_logging(); $this->enable_logging();
$manager = get_log_manager(true); $manager = get_log_manager(true);
...@@ -185,7 +186,7 @@ class logstore_database_privacy_testcase extends provider_testcase { ...@@ -185,7 +186,7 @@ class logstore_database_privacy_testcase extends provider_testcase {
$e->trigger(); $e->trigger();
// The admin user should be added (realuserid). // The admin user should be added (realuserid).
$this->setAdminUser(); $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 = \logstore_database\event\unittest_executed::create(['context' => $sysctx]);
$e->trigger(); $e->trigger();
// Set off an event in a different context. User 4 should not be returned below. // Set off an event in a different context. User 4 should not be returned below.
...@@ -206,9 +207,9 @@ class logstore_database_privacy_testcase extends provider_testcase { ...@@ -206,9 +207,9 @@ class logstore_database_privacy_testcase extends provider_testcase {
$u2 = $this->getDataGenerator()->create_user(); $u2 = $this->getDataGenerator()->create_user();
$c1 = $this->getDataGenerator()->create_course(); $c1 = $this->getDataGenerator()->create_course();
$c2 = $this->getDataGenerator()->create_course(); $c2 = $this->getDataGenerator()->create_course();
$sysctx = context_system::instance(); $sysctx = \context_system::instance();
$c1ctx = context_course::instance($c1->id); $c1ctx = \context_course::instance($c1->id);
$c2ctx = context_course::instance($c2->id); $c2ctx = \context_course::instance($c2->id);
$this->enable_logging(); $this->enable_logging();
$manager = get_log_manager(true); $manager = get_log_manager(true);
...@@ -247,9 +248,9 @@ class logstore_database_privacy_testcase extends provider_testcase { ...@@ -247,9 +248,9 @@ class logstore_database_privacy_testcase extends provider_testcase {
$u2 = $this->getDataGenerator()->create_user(); $u2 = $this->getDataGenerator()->create_user();
$c1 = $this->getDataGenerator()->create_course(); $c1 = $this->getDataGenerator()->create_course();
$c2 = $this->getDataGenerator()->create_course(); $c2 = $this->getDataGenerator()->create_course();
$sysctx = context_system::instance(); $sysctx = \context_system::instance();
$c1ctx = context_course::instance($c1->id); $c1ctx = \context_course::instance($c1->id);
$c2ctx = context_course::instance($c2->id); $c2ctx = \context_course::instance($c2->id);
$this->enable_logging(); $this->enable_logging();
$manager = get_log_manager(true); $manager = get_log_manager(true);
...@@ -294,8 +295,8 @@ class logstore_database_privacy_testcase extends provider_testcase { ...@@ -294,8 +295,8 @@ class logstore_database_privacy_testcase extends provider_testcase {
$u4 = $this->getDataGenerator()->create_user(); $u4 = $this->getDataGenerator()->create_user();
$course = $this->getDataGenerator()->create_course(); $course = $this->getDataGenerator()->create_course();
$sysctx = context_system::instance(); $sysctx = \context_system::instance();
$c1ctx = context_course::instance($course->id); $c1ctx = \context_course::instance($course->id);
$this->enable_logging(); $this->enable_logging();
$manager = get_log_manager(true); $manager = get_log_manager(true);
...@@ -337,11 +338,11 @@ class logstore_database_privacy_testcase extends provider_testcase { ...@@ -337,11 +338,11 @@ class logstore_database_privacy_testcase extends provider_testcase {
$cm1 = $this->getDataGenerator()->create_module('url', ['course' => $c1]); $cm1 = $this->getDataGenerator()->create_module('url', ['course' => $c1]);
$c2 = $this->getDataGenerator()->create_course(); $c2 = $this->getDataGenerator()->create_course();
$cm2 = $this->getDataGenerator()->create_module('url', ['course' => $c2]); $cm2 = $this->getDataGenerator()->create_module('url', ['course' => $c2]);
$sysctx = context_system::instance(); $sysctx = \context_system::instance();
$c1ctx = context_course::instance($c1->id); $c1ctx = \context_course::instance($c1->id);
$c2ctx = context_course::instance($c2->id); $c2ctx = \context_course::instance($c2->id);
$cm1ctx = context_module::instance($cm1->cmid); $cm1ctx = \context_module::instance($cm1->cmid);
$cm2ctx = context_module::instance($cm2->cmid); $cm2ctx = \context_module::instance($cm2->cmid);
$path = [get_string('privacy:path:logs', 'tool_log'), get_string('pluginname', 'logstore_database')]; $path = [get_string('privacy:path:logs', 'tool_log'), get_string('pluginname', 'logstore_database')];
$this->enable_logging(); $this->enable_logging();
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
* @author Frédéric Massart <fred@branchup.tech> * @author Frédéric Massart <fred@branchup.tech>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/ */
namespace logstore_legacy\privacy;
defined('MOODLE_INTERNAL') || die(); defined('MOODLE_INTERNAL') || die();
global $CFG; global $CFG;
...@@ -46,7 +47,7 @@ require_once(__DIR__ . '/fixtures/event.php'); ...@@ -46,7 +47,7 @@ require_once(__DIR__ . '/fixtures/event.php');
* @author Frédéric Massart <fred@branchup.tech> * @author Frédéric Massart <fred@branchup.tech>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/ */
class logstore_legacy_privacy_testcase extends provider_testcase { class privacy_test extends provider_testcase {
public function setUp(): void { public function setUp(): void {
$this->resetAfterTest(); $this->resetAfterTest();
...@@ -58,9 +59,9 @@ class logstore_legacy_privacy_testcase extends provider_testcase { ...@@ -58,9 +59,9 @@ class logstore_legacy_privacy_testcase extends provider_testcase {
$u3 = $this->getDataGenerator()->create_user(); $u3 = $this->getDataGenerator()->create_user();
$c1 = $this->getDataGenerator()->create_course(); $c1 = $this->getDataGenerator()->create_course();
$cm1 = $this->getDataGenerator()->create_module('url', ['course' => $c1]); $cm1 = $this->getDataGenerator()->create_module('url', ['course' => $c1]);
$sysctx = context_system::instance(); $sysctx = \context_system::instance();
$c1ctx = context_course::instance($c1->id); $c1ctx = \context_course::instance($c1->id);
$cm1ctx = context_module::instance($cm1->cmid); $cm1ctx = \context_module::instance($cm1->cmid);
$this->enable_logging(); $this->enable_logging();
$manager = get_log_manager(true); $manager = get_log_manager(true);
...@@ -96,11 +97,11 @@ class logstore_legacy_privacy_testcase extends provider_testcase { ...@@ -96,11 +97,11 @@ class logstore_legacy_privacy_testcase extends provider_testcase {
$u3 = $this->getDataGenerator()->create_user(); $u3 = $this->getDataGenerator()->create_user();
$course = $this->getDataGenerator()->create_course(); $course = $this->getDataGenerator()->create_course();
$module = $this->getDataGenerator()->create_module('url', ['course' => $course]); $module = $this->getDataGenerator()->create_module('url', ['course' => $course]);
$sysctx = context_system::instance(); $sysctx = \context_system::instance();
$c1ctx = context_course::instance($course->id); $c1ctx = \context_course::instance($course->id);
$cm1ctx = context_module::instance($module->cmid); $cm1ctx = \context_module::instance($module->cmid);
$userctx = context_user::instance($u1->id); $userctx = \context_user::instance($u1->id);
$this->enable_logging(); $this->enable_logging();
$manager = get_log_manager(true); $manager = get_log_manager(true);
...@@ -161,10 +162,10 @@ class logstore_legacy_privacy_testcase extends provider_testcase { ...@@ -161,10 +162,10 @@ class logstore_legacy_privacy_testcase extends provider_testcase {
$c1 = $this->getDataGenerator()->create_course(); $c1 = $this->getDataGenerator()->create_course();
$c2 = $this->getDataGenerator()->create_course(); $c2 = $this->getDataGenerator()->create_course();
$cm1 = $this->getDataGenerator()->create_module('url', ['course' => $c1]); $cm1 = $this->getDataGenerator()->create_module('url', ['course' => $c1]);
$sysctx = context_system::instance(); $sysctx = \context_system::instance();
$c1ctx = context_course::instance($c1->id); $c1ctx = \context_course::instance($c1->id);
$c2ctx = context_course::instance($c2->id); $c2ctx = \context_course::instance($c2->id);
$cm1ctx = context_module::instance($cm1->cmid); $cm1ctx = \context_module::instance($cm1->cmid);
$this->enable_logging(); $this->enable_logging();
$manager = get_log_manager(true); $manager = get_log_manager(true);
...@@ -238,10 +239,10 @@ class logstore_legacy_privacy_testcase extends provider_testcase { ...@@ -238,10 +239,10 @@ class logstore_legacy_privacy_testcase extends provider_testcase {
$c1 = $this->getDataGenerator()->create_course(); $c1 = $this->getDataGenerator()->create_course();
$c2 = $this->getDataGenerator()->create_course(); $c2 = $this->getDataGenerator()->create_course();
$cm1 = $this->getDataGenerator()->create_module('url', ['course' => $c1]); $cm1 = $this->getDataGenerator()->create_module('url', ['course' => $c1]);
$sysctx = context_system::instance(); $sysctx = \context_system::instance();
$c1ctx = context_course::instance($c1->id); $c1ctx = \context_course::instance($c1->id);
$c2ctx = context_course::instance($c2->id); $c2ctx = \context_course::instance($c2->id);
$cm1ctx = context_module::instance($cm1->cmid); $cm1ctx = \context_module::instance($cm1->cmid);
$this->enable_logging(); $this->enable_logging();
$manager = get_log_manager(true); $manager = get_log_manager(true);
...@@ -317,11 +318,11 @@ class logstore_legacy_privacy_testcase extends provider_testcase { ...@@ -317,11 +318,11 @@ class logstore_legacy_privacy_testcase extends provider_testcase {
$u3 = $this->getDataGenerator()->create_user(); $u3 = $this->getDataGenerator()->create_user();
$course = $this->getDataGenerator()->create_course(); $course = $this->getDataGenerator()->create_course();
$module = $this->getDataGenerator()->create_module('url', ['course' => $course]); $module = $this->getDataGenerator()->create_module('url', ['course' => $course]);
$sysctx = context_system::instance(); $sysctx = \context_system::instance();
$c1ctx = context_course::instance($course->id); $c1ctx = \context_course::instance($course->id);
$cm1ctx = context_module::instance($module->cmid); $cm1ctx = \context_module::instance($module->cmid);
$userctx = context_user::instance($u1->id); $userctx = \context_user::instance($u1->id);
$this->enable_logging(); $this->enable_logging();
$manager = get_log_manager(true); $manager = get_log_manager(true);
...@@ -377,10 +378,10 @@ class logstore_legacy_privacy_testcase extends provider_testcase { ...@@ -377,10 +378,10 @@ class logstore_legacy_privacy_testcase extends provider_testcase {
$c1 = $this->getDataGenerator()->create_course(); $c1 = $this->getDataGenerator()->create_course();
$c2 = $this->getDataGenerator()->create_course(); $c2 = $this->getDataGenerator()->create_course();