Línea 35... |
Línea 35... |
35 |
* Unit tests for the privacy API implementation.
|
35 |
* Unit tests for the privacy API implementation.
|
36 |
*
|
36 |
*
|
37 |
* @copyright 2018 David Mudrák <david@moodle.com>
|
37 |
* @copyright 2018 David Mudrák <david@moodle.com>
|
38 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
38 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
39 |
*/
|
39 |
*/
|
40 |
class provider_test extends provider_testcase {
|
40 |
final class provider_test extends provider_testcase {
|
Línea 41... |
Línea 41... |
41 |
|
41 |
|
42 |
/** @var testing_data_generator */
|
42 |
/** @var testing_data_generator */
|
Línea 43... |
Línea 43... |
43 |
protected $generator;
|
43 |
protected $generator;
|
Línea 122... |
Línea 122... |
122 |
*
|
122 |
*
|
123 |
* etc.
|
123 |
* etc.
|
124 |
*/
|
124 |
*/
|
125 |
protected function setUp(): void {
|
125 |
protected function setUp(): void {
|
126 |
global $DB;
|
126 |
global $DB;
|
- |
|
127 |
parent::setUp();
|
127 |
$this->resetAfterTest();
|
128 |
$this->resetAfterTest();
|
128 |
$this->setAdminUser();
|
129 |
$this->setAdminUser();
|
Línea 129... |
Línea 130... |
129 |
|
130 |
|
130 |
$this->generator = $this->getDataGenerator();
|
131 |
$this->generator = $this->getDataGenerator();
|
Línea 189... |
Línea 190... |
189 |
$context21 = \context_module::instance($cm21->id);
|
190 |
$context21 = \context_module::instance($cm21->id);
|
Línea 190... |
Línea 191... |
190 |
|
191 |
|
191 |
// Student1 has data in workshop11 (author + self reviewer), workshop12 (author) and workshop21 (reviewer).
|
192 |
// Student1 has data in workshop11 (author + self reviewer), workshop12 (author) and workshop21 (reviewer).
|
192 |
$contextlist = \mod_workshop\privacy\provider::get_contexts_for_userid($this->student1->id);
|
193 |
$contextlist = \mod_workshop\privacy\provider::get_contexts_for_userid($this->student1->id);
|
193 |
$this->assertInstanceOf(\core_privacy\local\request\contextlist::class, $contextlist);
|
194 |
$this->assertInstanceOf(\core_privacy\local\request\contextlist::class, $contextlist);
|
Línea 194... |
Línea 195... |
194 |
$this->assertEqualsCanonicalizing([$context11->id, $context12->id, $context21->id], $contextlist->get_contextids());
|
195 |
$this->assertEqualsCanonicalizing([$context11->id, $context12->id, $context21->id], array_values($contextlist->get_contextids()));
|
195 |
|
196 |
|
196 |
// Student2 has data in workshop11 (reviewer), workshop12 (reviewer) and workshop21 (author).
|
197 |
// Student2 has data in workshop11 (reviewer), workshop12 (reviewer) and workshop21 (author).
|
Línea 197... |
Línea 198... |
197 |
$contextlist = \mod_workshop\privacy\provider::get_contexts_for_userid($this->student2->id);
|
198 |
$contextlist = \mod_workshop\privacy\provider::get_contexts_for_userid($this->student2->id);
|
198 |
$this->assertEqualsCanonicalizing([$context11->id, $context12->id, $context21->id], $contextlist->get_contextids());
|
199 |
$this->assertEqualsCanonicalizing([$context11->id, $context12->id, $context21->id], array_values($contextlist->get_contextids()));
|
199 |
|
200 |
|
Línea 200... |
Línea 201... |
200 |
// Student3 has data in workshop11 (reviewer).
|
201 |
// Student3 has data in workshop11 (reviewer).
|
201 |
$contextlist = \mod_workshop\privacy\provider::get_contexts_for_userid($this->student3->id);
|
202 |
$contextlist = \mod_workshop\privacy\provider::get_contexts_for_userid($this->student3->id);
|
202 |
$this->assertEqualsCanonicalizing([$context11->id], $contextlist->get_contextids());
|
203 |
$this->assertEqualsCanonicalizing([$context11->id], array_values($contextlist->get_contextids()));
|
203 |
|
204 |
|
Línea 204... |
Línea 205... |
204 |
// Teacher4 has data in workshop12 (gradeoverby) and workshop21 (gradinggradeoverby).
|
205 |
// Teacher4 has data in workshop12 (gradeoverby) and workshop21 (gradinggradeoverby).
|
205 |
$contextlist = \mod_workshop\privacy\provider::get_contexts_for_userid($this->teacher4->id);
|
206 |
$contextlist = \mod_workshop\privacy\provider::get_contexts_for_userid($this->teacher4->id);
|
206 |
$this->assertEqualsCanonicalizing([$context21->id, $context12->id], $contextlist->get_contextids());
|
207 |
$this->assertEqualsCanonicalizing([$context21->id, $context12->id], array_values($contextlist->get_contextids()));
|