Differences Between: [Versions 310 and 400] [Versions 39 and 400]
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 core_privacy; 18 19 use core_privacy\local\metadata\types\user_preference; 20 21 /** 22 * Tests for the \core_privacy API's types\user_preference functionality. 23 * 24 * @package core_privacy 25 * @category test 26 * @copyright 2018 Andrew Nicols <andrew@nicols.co.uk> 27 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 28 * @coversDefaultClass \core_privacy\local\metadata\types\user_preference 29 */ 30 class types_user_preference_test extends \advanced_testcase { 31 32 /** 33 * Ensure that warnings are thrown if string identifiers contain invalid characters. 34 * 35 * @dataProvider invalid_string_provider 36 * @param string $name Name 37 * @param string $summary Summary 38 * @covers ::__construct 39 */ 40 public function test_invalid_configs($name, $summary) { 41 $record = new user_preference($name, $summary); 42 $this->assertDebuggingCalled(); 43 } 44 45 /** 46 * Ensure that warnings are not thrown if debugging is not enabled, even if string identifiers contain invalid characters. 47 * 48 * @dataProvider invalid_string_provider 49 * @param string $name Name 50 * @param string $summary Summary 51 * @covers ::__construct 52 */ 53 public function test_invalid_configs_debug_normal($name, $summary) { 54 global $CFG; 55 $this->resetAfterTest(); 56 57 $CFG->debug = DEBUG_NORMAL; 58 $record = new user_preference($name, $summary); 59 $this->assertDebuggingNotCalled(); 60 } 61 62 /** 63 * Ensure that no warnings are shown for valid combinations. 64 * 65 * @dataProvider valid_string_provider 66 * @param string $name Name 67 * @param string $summary Summary 68 * @covers ::__construct 69 */ 70 public function test_valid_configs($name, $summary) { 71 $record = new user_preference($name, $summary); 72 $this->assertDebuggingNotCalled(); 73 } 74 75 /** 76 * Data provider with a list of invalid string identifiers. 77 * 78 * @return array 79 */ 80 public function invalid_string_provider() { 81 return [ 82 'Space in summary' => [ 83 'example', 84 'This table is used for purposes.', 85 ], 86 'Comma in summary' => [ 87 'example', 88 'privacy,foo', 89 ], 90 ]; 91 } 92 93 /** 94 * Data provider with a list of valid string identifiers. 95 * 96 * @return array 97 */ 98 public function valid_string_provider() { 99 return [ 100 'Valid combination' => [ 101 'example', 102 'privacy:example:valid', 103 ], 104 ]; 105 } 106 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body