Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1441 ariadna 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.
13
//
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/>.
16
 
17
namespace qbank_managecategories\privacy;
18
 
19
use advanced_testcase;
20
use core_privacy\local\request\writer;
21
use qbank_managecategories\privacy\provider;
22
 
23
/**
24
 * Unit tests for qbank_managecategories privacy provider.
25
 *
26
 * @package    qbank_managecategories
27
 * @copyright  2021 Catalyst IT Australia Pty Ltd
28
 * @author     2021, Ghaly Marc-Alexandre <marc-alexandreghaly@catalyst-ca.net>
29
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
30
 * @coversDefaultClass \qbank_managecategories\privacy\provider
31
 */
32
final class provider_test extends advanced_testcase {
33
    /**
34
     * Test to check export_user_preferences.
35
     *
36
     * @covers ::export_user_preferences
37
     */
38
    public function test_export_user_preferences(): void {
39
        $this->resetAfterTest();
40
        $user = $this->getDataGenerator()->create_user();
41
        set_user_preference('qbank_managecategories_showdescriptions', 1, $user);
42
        set_user_preference('qbank_managecategories_includesubcategories_filter_default', 1, $user);
43
        provider::export_user_preferences($user->id);
44
        $writer = writer::with_context(\context_system::instance());
45
        $prefs = $writer->get_user_preferences('qbank_managecategories');
46
        $this->assertEquals(1, $prefs->showdescr->value);
47
        $this->assertEquals(1, $prefs->includesubcategories->value);
48
        $this->assertEquals(get_string('displaydescription', 'qbank_managecategories'), $prefs->showdescr->description);
49
        $this->assertEquals(get_string('questionsubcategoriesdisplayed',
50
            'qbank_managecategories'), $prefs->includesubcategories->description);
51
    }
52
}