2 // This file is part of Moodle - http://moodle.org/
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.
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.
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/>.
18 * Types unit tests for the Subsystem Link.
20 * @package core_privacy
22 * @copyright 2018 Andrew Nicols <andrew@nicols.co.uk>
23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
26 defined('MOODLE_INTERNAL') ||
die();
30 use \core_privacy\local\metadata\types\subsystem_link
;
33 * Tests for the \core_privacy API's types\subsystem_link functionality.
35 * @copyright 2018 Andrew Nicols <andrew@nicols.co.uk>
36 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
38 class core_privacy_metadata_types_subsystem_link
extends advanced_testcase
{
41 * Ensure that warnings are thrown if string identifiers contain invalid characters.
43 * @dataProvider invalid_string_provider
44 * @param string $name Name
45 * @param string $summary Summary
47 public function test_invalid_configs($name, $privacyfields, $summary) {
48 $record = new subsystem_link($name, $privacyfields, $summary);
49 $this->assertDebuggingCalled();
53 * Ensure that warnings are not thrown if debugging is not enabled, even if string identifiers contain invalid characters.
55 * @dataProvider invalid_string_provider
56 * @param string $name Name
57 * @param string $summary Summary
59 public function test_invalid_configs_debug_normal($name, $privacyfields, $summary) {
61 $this->resetAfterTest();
63 $CFG->debug
= DEBUG_NORMAL
;
64 $record = new subsystem_link($name, $privacyfields, $summary);
65 $this->assertDebuggingNotCalled();
69 * Ensure that no warnings are shown for valid combinations.
71 * @dataProvider valid_string_provider
72 * @param string $name Name
73 * @param string $summary Summary
75 public function test_valid_configs($name, $privacyfields, $summary) {
76 $record = new subsystem_link($name, $privacyfields, $summary);
77 $this->assertDebuggingNotCalled();
81 * Data provider with a list of invalid string identifiers.
85 public function invalid_string_provider() {
87 'Space in summary' => [
90 'This table is used for purposes.',
92 'Comma in summary' => [
101 * Data provider with a list of valid string identifiers.
105 public function valid_string_provider() {
107 'Valid combination' => [
110 'privacy:example:valid',