weekly release 4.5dev
[moodle.git] / privacy / tests / types_subsystem_link_test.php
blob0459ddbb2bbe7c0fc5fba406f853fd84c637a6d6
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.
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/>.
17 namespace core_privacy;
19 use core_privacy\local\metadata\types\subsystem_link;
21 /**
22 * Tests for the \core_privacy API's types\subsystem_link functionality.
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\subsystem_link
30 class types_subsystem_link_test extends \advanced_testcase {
32 /**
33 * Ensure that warnings are thrown if string identifiers contain invalid characters.
35 * @dataProvider invalid_string_provider
36 * @param string $name Name
37 * @param string $summary Summary
38 * @covers ::__construct
40 public function test_invalid_configs($name, $privacyfields, $summary): void {
41 $record = new subsystem_link($name, $privacyfields, $summary);
42 $this->assertDebuggingCalled();
45 /**
46 * Ensure that warnings are not thrown if debugging is not enabled, even if string identifiers contain invalid characters.
48 * @dataProvider invalid_string_provider
49 * @param string $name Name
50 * @param string $summary Summary
51 * @covers ::__construct
53 public function test_invalid_configs_debug_normal($name, $privacyfields, $summary): void {
54 global $CFG;
55 $this->resetAfterTest();
57 $CFG->debug = DEBUG_NORMAL;
58 $record = new subsystem_link($name, $privacyfields, $summary);
59 $this->assertDebuggingNotCalled();
62 /**
63 * Ensure that no warnings are shown for valid combinations.
65 * @dataProvider valid_string_provider
66 * @param string $name Name
67 * @param string $summary Summary
68 * @covers ::__construct
70 public function test_valid_configs($name, $privacyfields, $summary): void {
71 $record = new subsystem_link($name, $privacyfields, $summary);
72 $this->assertDebuggingNotCalled();
75 /**
76 * Data provider with a list of invalid string identifiers.
78 * @return array
80 public function invalid_string_provider() {
81 return [
82 'Space in summary' => [
83 'example',
84 [],
85 'This table is used for purposes.',
87 'Comma in summary' => [
88 'example',
89 [],
90 'privacy,foo',
95 /**
96 * Data provider with a list of valid string identifiers.
98 * @return array
100 public function valid_string_provider() {
101 return [
102 'Valid combination' => [
103 'example',
105 'privacy:example:valid',