MDL-78962 core/loadingicon: remove jQuery requirement in the API
[moodle.git] / privacy / tests / approved_contextlist_test.php
bloba5057f0232df1f201d19f151613c42c09268b344
1 <?php
2 // This file is part of Moodle - http://moodle.org/
3 //
4 // Moodle is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // Moodle is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
17 /**
18 * Unit Tests for the approved contextlist Class
20 * @package core_privacy
21 * @category test
22 * @copyright 2018 Andrew Nicols <andrew@nicols.co.uk>
23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
26 defined('MOODLE_INTERNAL') || die();
28 global $CFG;
30 use \core_privacy\local\request\approved_contextlist;
32 /**
33 * Tests for the \core_privacy API's approved contextlist functionality.
35 * @copyright 2018 Andrew Nicols <andrew@nicols.co.uk>
36 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
37 * @coversDefaultClass \core_privacy\local\request\approved_contextlist
39 class approved_contextlist_test extends advanced_testcase {
41 /**
42 * The approved contextlist should not be modifiable once set.
44 * @covers ::__construct
45 * @covers \core_privacy\local\request\approved_contextlist<extended>
47 public function test_default_values_set() {
48 $testuser = \core_user::get_user_by_username('admin');
49 $contextids = [3, 2, 1];
50 $component = 'core_privacy';
52 $uit = new approved_contextlist($testuser, $component, $contextids);
54 $this->assertEquals($testuser, $uit->get_user());
55 $this->assertEquals($component, $uit->get_component());
56 $result = $uit->get_contextids();
58 // Note: Array order is not guaranteed and should not matter.
59 foreach ($contextids as $contextid) {
60 $this->assertNotFalse(array_search($contextid, $result));