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