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 /** 18 * Privacy tests for theme_boost. 19 * 20 * @package theme_boost 21 * @category test 22 * @copyright 2018 Adrian Greeve <adriangreeve.com> 23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 24 */ 25 26 defined('MOODLE_INTERNAL') || die(); 27 28 use \theme_boost\privacy\provider; 29 30 /** 31 * Unit tests for theme_boost/classes/privacy/policy 32 * 33 * @copyright 2018 Adrian Greeve <adriangreeve.com> 34 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 35 */ 36 class theme_boost_privacy_testcase extends \core_privacy\tests\provider_testcase { 37 38 /** 39 * Test for provider::test_export_user_preferences(). 40 */ 41 public function test_export_user_preferences() { 42 $this->resetAfterTest(); 43 44 // Test setup. 45 $user = $this->getDataGenerator()->create_user(); 46 $this->setUser($user); 47 48 // Add a user home page preference for the User. 49 set_user_preference(provider::DRAWER_OPEN_NAV, 'false', $user); 50 51 // Test the user preferences export contains 1 user preference record for the User. 52 provider::export_user_preferences($user->id); 53 $contextuser = context_user::instance($user->id); 54 $writer = \core_privacy\local\request\writer::with_context($contextuser); 55 $this->assertTrue($writer->has_any_data()); 56 57 $exportedpreferences = $writer->get_user_preferences('theme_boost'); 58 $this->assertCount(1, (array) $exportedpreferences); 59 $this->assertEquals('false', $exportedpreferences->{provider::DRAWER_OPEN_NAV}->value); 60 $this->assertEquals(get_string('privacy:drawernavclosed', 'theme_boost'), 61 $exportedpreferences->{provider::DRAWER_OPEN_NAV}->description); 62 63 // Add a user home page preference for the User. 64 set_user_preference(provider::DRAWER_OPEN_NAV, 'true', $user); 65 66 // Test the user preferences export contains 1 user preference record for the User. 67 provider::export_user_preferences($user->id); 68 $contextuser = context_user::instance($user->id); 69 $writer = \core_privacy\local\request\writer::with_context($contextuser); 70 $this->assertTrue($writer->has_any_data()); 71 72 $exportedpreferences = $writer->get_user_preferences('theme_boost'); 73 $this->assertCount(1, (array) $exportedpreferences); 74 $this->assertEquals('true', $exportedpreferences->{provider::DRAWER_OPEN_NAV}->value); 75 $this->assertEquals(get_string('privacy:drawernavopen', 'theme_boost'), 76 $exportedpreferences->{provider::DRAWER_OPEN_NAV}->description); 77 } 78 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body