Skip to content

Commit

Permalink
Merge branch 'MDL-73971' of https://github.com/stronk7/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
junpataleta committed May 12, 2022
2 parents 9cb0f7c + 9f53b0e commit aa88375
Show file tree
Hide file tree
Showing 143 changed files with 1,891 additions and 2,313 deletions.
14 changes: 7 additions & 7 deletions admin/roles/tests/preset_test.php
Expand Up @@ -14,19 +14,19 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

namespace core_role;

use core_role_preset;

/**
* Role XML presets test case.
*
* @package core_role
* @category phpunit
* @category test
* @copyright 2013 Petr Skoda {@link http://skodak.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

defined('MOODLE_INTERNAL') || die();


class core_role_preset_testcase extends advanced_testcase {
class preset_test extends \advanced_testcase {
public function test_xml() {
global $DB;

Expand Down Expand Up @@ -61,7 +61,7 @@ public function test_xml() {
FROM {role_capabilities}
WHERE contextid = :syscontext AND roleid = :roleid
ORDER BY capability ASC",
array('syscontext'=>context_system::instance()->id, 'roleid'=>$role->id));
array('syscontext' => \context_system::instance()->id, 'roleid' => $role->id));

foreach ($capabilities as $cap) {
$this->assertEquals($cap->permission, $info['permissions'][$cap->capability]);
Expand Down
18 changes: 4 additions & 14 deletions admin/tool/dataprivacy/tests/data_registry_test.php
Expand Up @@ -14,17 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Unit tests for the data_registry class.
*
* @package tool_dataprivacy
* @copyright 2018 Andrew Nicols <andrew@nicols.co.uk>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

defined('MOODLE_INTERNAL') || die();

use \tool_dataprivacy\data_registry;
namespace tool_dataprivacy;

/**
* Unit tests for the data_registry class.
Expand All @@ -33,15 +23,15 @@
* @copyright 2018 Andrew Nicols <andrew@nicols.co.uk>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class tool_dataprivacy_dataregistry_testcase extends advanced_testcase {
class data_registry_test extends \advanced_testcase {

/**
* Ensure that the get_effective_context_value only errors if provided an inappropriate element.
*
* This test is not great because we only test a limited set of values. This is a fault of the underlying API.
*/
public function test_get_effective_context_value_invalid_element() {
$this->expectException(coding_exception::class);
$this->expectException(\coding_exception::class);
data_registry::get_effective_context_value(\context_system::instance(), 'invalid');
}

Expand All @@ -51,7 +41,7 @@ public function test_get_effective_context_value_invalid_element() {
* This test is not great because we only test a limited set of values. This is a fault of the underlying API.
*/
public function test_get_effective_contextlevel_value_invalid_element() {
$this->expectException(coding_exception::class);
$this->expectException(\coding_exception::class);
data_registry::get_effective_contextlevel_value(\context_system::instance(), 'invalid');
}
}
14 changes: 4 additions & 10 deletions admin/tool/dataprivacy/tests/data_request_test.php
Expand Up @@ -14,27 +14,21 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Tests for the data_request persistent.
*
* @package tool_dataprivacy
* @copyright 2018 Andrew Nicols <andrew@nicols.co.uk>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace tool_dataprivacy;

use data_privacy_testcase;

defined('MOODLE_INTERNAL') || die();
require_once('data_privacy_testcase.php');

use tool_dataprivacy\api;

/**
* Tests for the data_request persistent.
*
* @package tool_dataprivacy
* @copyright 2018 Andrew Nicols <andrew@nicols.co.uk>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class tool_dataprivacy_data_request_testcase extends data_privacy_testcase {
class data_request_test extends data_privacy_testcase {

/**
* Data provider for testing is_resettable, and is_active.
Expand Down
22 changes: 2 additions & 20 deletions admin/tool/dataprivacy/tests/expired_contexts_test.php
Expand Up @@ -14,25 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Expired contexts tests.
*
* @package tool_dataprivacy
* @copyright 2018 David Monllao
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

use tool_dataprivacy\api;
use tool_dataprivacy\data_registry;
use tool_dataprivacy\expired_context;
use tool_dataprivacy\purpose;
use tool_dataprivacy\purpose_override;
use tool_dataprivacy\category;
use tool_dataprivacy\contextlevel;
use tool_dataprivacy\expired_contexts_manager;

defined('MOODLE_INTERNAL') || die();
global $CFG;
namespace tool_dataprivacy;

/**
* Expired contexts tests.
Expand All @@ -41,7 +23,7 @@
* @copyright 2018 David Monllao
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class tool_dataprivacy_expired_contexts_testcase extends advanced_testcase {
class expired_contexts_test extends \advanced_testcase {

/**
* Setup the basics with the specified retention period.
Expand Down
18 changes: 4 additions & 14 deletions admin/tool/dataprivacy/tests/expired_data_requests_test.php
Expand Up @@ -14,21 +14,11 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Expired data requests tests.
*
* @package tool_dataprivacy
* @copyright 2018 Michael Hawkins
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace tool_dataprivacy;

use tool_dataprivacy\api;
use tool_dataprivacy\category;
use tool_dataprivacy\data_request;
use tool_dataprivacy\purpose;
use data_privacy_testcase;

defined('MOODLE_INTERNAL') || die();
global $CFG;

require_once('data_privacy_testcase.php');

Expand All @@ -39,7 +29,7 @@
* @copyright 2018 Michael Hawkins
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class tool_dataprivacy_expired_data_requests_testcase extends data_privacy_testcase {
class expired_data_requests_test extends data_privacy_testcase {

/**
* Test tearDown.
Expand All @@ -59,7 +49,7 @@ public function test_data_request_expiry() {
// Set up test users.
$this->setAdminUser();
$studentuser = $this->getDataGenerator()->create_user();
$studentusercontext = context_user::instance($studentuser->id);
$studentusercontext = \context_user::instance($studentuser->id);

$dpouser = $this->getDataGenerator()->create_user();
$this->assign_site_dpo($dpouser);
Expand Down
10 changes: 2 additions & 8 deletions admin/tool/dataprivacy/tests/filtered_userlist_test.php
Expand Up @@ -14,13 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Unit tests for the filtered_userlist.
*
* @package tool_dataprivacy
* @copyright 2018 Andrew Nicols <andrew@nicols.co.uk>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace tool_dataprivacy;

/**
* Unit tests for the filtered_userlist.
Expand All @@ -29,7 +23,7 @@
* @copyright 2018 Andrew Nicols <andrew@nicols.co.uk>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class tool_dataprivacy_filtered_userlist_testcase extends advanced_testcase {
class filtered_userlist_test extends \advanced_testcase {
/**
* Test the apply_expired_contexts_filters function with arange of options.
*
Expand Down
14 changes: 5 additions & 9 deletions admin/tool/dataprivacy/tests/manager_observer_test.php
Expand Up @@ -14,25 +14,21 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Tests for the manager observer.
*
* @package tool_dataprivacy
* @copyright 2018 Andrew Nicols <andrew@nicols.co.uk>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace tool_dataprivacy;

use data_privacy_testcase;

defined('MOODLE_INTERNAL') || die();
require_once('data_privacy_testcase.php');

/**
* API tests.
* Tests for the manager observer.
*
* @package tool_dataprivacy
* @copyright 2018 Andrew Nicols <andrew@nicols.co.uk>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class tool_dataprivacy_manager_observer_testcase extends data_privacy_testcase {
class manager_observer_test extends data_privacy_testcase {
/**
* Ensure that when users are configured as DPO, they are sent an message upon failure.
*/
Expand Down
13 changes: 2 additions & 11 deletions admin/tool/dataprivacy/tests/metadata_registry_test.php
Expand Up @@ -14,16 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Metadata registry tests.
*
* @package tool_dataprivacy
* @copyright 2018 Adrian Greeve <adriangreeve.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

defined('MOODLE_INTERNAL') || die();
global $CFG;
namespace tool_dataprivacy;

/**
* Metadata registry tests.
Expand All @@ -32,7 +23,7 @@
* @copyright 2018 Adrian Greeve <adriangreeve.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class tool_dataprivacy_metadata_registry_testcase extends advanced_testcase {
class metadata_registry_test extends \advanced_testcase {

/**
* Fetch the meta data and return it in a form that we can easily unit test.
Expand Down
15 changes: 3 additions & 12 deletions admin/tool/dataprivacy/tests/user_deleted_observer_test.php
Expand Up @@ -14,18 +14,9 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Tests for the event observer.
*
* @package tool_dataprivacy
* @copyright 2018 Mihail Geshoski <mihail@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

defined('MOODLE_INTERNAL') || die();
namespace tool_dataprivacy;

use \tool_dataprivacy\event\user_deleted_observer;
use \tool_dataprivacy\api;
use tool_dataprivacy\event\user_deleted_observer;

/**
* Event observer test.
Expand All @@ -34,7 +25,7 @@
* @copyright 2018 Mihail Geshoski <mihail@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class tool_dataprivacy_user_deleted_observer_testcase extends advanced_testcase {
class user_deleted_observer_test extends \advanced_testcase {

/**
* Ensure that a delete data request is created upon user deletion.
Expand Down
18 changes: 10 additions & 8 deletions admin/tool/generator/tests/maketestcourse_test.php
Expand Up @@ -14,7 +14,9 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

defined('MOODLE_INTERNAL') || die();
namespace tool_generator;

use tool_generator_course_backend;

/**
* Automated unit testing. This tests the 'make large course' backend,
Expand All @@ -24,7 +26,7 @@
* @copyright 2013 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class tool_generator_maketestcourse_testcase extends advanced_testcase {
class maketestcourse_test extends \advanced_testcase {
/**
* Creates a small test course and checks all the components have been put in place.
*/
Expand Down Expand Up @@ -52,7 +54,7 @@ public function test_make_xs_course() {

// Get course details.
$course = get_course($courseid);
$context = context_course::instance($courseid);
$context = \context_course::instance($courseid);
$modinfo = get_fast_modinfo($course);

// Check course names.
Expand Down Expand Up @@ -88,7 +90,7 @@ public function test_make_xs_course() {

// Check it contains 2 files (the default txt and a dat file).
$fs = get_file_storage();
$resourcecontext = context_module::instance($resource->id);
$resourcecontext = \context_module::instance($resource->id);
$files = $fs->get_area_files($resourcecontext->id, 'mod_resource', 'content', false, 'filename', false);
$files = array_values($files);
$this->assertEquals(2, count($files));
Expand All @@ -106,7 +108,7 @@ public function test_make_xs_course() {
$this->assertTrue($ok);

// Check it contains 2 files.
$resourcecontext = context_module::instance($resource->id);
$resourcecontext = \context_module::instance($resource->id);
$files = $fs->get_area_files($resourcecontext->id, 'mod_resource', 'content', false, 'filename', false);
$files = array_values($files);
$this->assertEquals(2, count($files));
Expand Down Expand Up @@ -155,7 +157,7 @@ public function test_fixed_data_set() {
$lastusernumber = 0;
$discussionstarters = array();
foreach ($discussions as $discussion) {
$usernumber = core_user::get_user($discussion->userid, 'id, idnumber')->idnumber;
$usernumber = \core_user::get_user($discussion->userid, 'id, idnumber')->idnumber;

// Checks that the users are odd numbers.
$this->assertEquals(1, $usernumber % 2);
Expand Down Expand Up @@ -190,7 +192,7 @@ public function test_filesize_limit() {
$fs = get_file_storage();
$resources = $modinfo->get_instances_of('resource');
foreach ($resources as $resource) {
$resourcecontext = context_module::instance($resource->id);
$resourcecontext = \context_module::instance($resource->id);
$files = $fs->get_area_files($resourcecontext->id, 'mod_resource', 'content', false, 'filename', false);
foreach ($files as $file) {
if ($file->get_mimetype() == 'application/octet-stream') {
Expand All @@ -210,7 +212,7 @@ public function test_filesize_limit() {
$fs = get_file_storage();
$resources = $modinfo->get_instances_of('resource');
foreach ($resources as $resource) {
$resourcecontext = context_module::instance($resource->id);
$resourcecontext = \context_module::instance($resource->id);
$files = $fs->get_area_files($resourcecontext->id, 'mod_resource', 'content', false, 'filename', false);
foreach ($files as $file) {
if ($file->get_mimetype() == 'application/octet-stream') {
Expand Down

0 comments on commit aa88375

Please sign in to comment.