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