MDL-62950 behat: Correct path to P&P
[moodle.git] / privacy / tests / types_subsystem_link_test.php
blob780aa793a900b893bc17c58af07d126f0c823f1f
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 /**
18 * Types unit tests for the Subsystem Link.
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
26 defined('MOODLE_INTERNAL') || die();
28 global $CFG;
30 use \core_privacy\local\metadata\types\subsystem_link;
32 /**
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 {
40 /**
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();
52 /**
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) {
60 global $CFG;
61 $this->resetAfterTest();
63 $CFG->debug = DEBUG_NORMAL;
64 $record = new subsystem_link($name, $privacyfields, $summary);
65 $this->assertDebuggingNotCalled();
68 /**
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();
80 /**
81 * Data provider with a list of invalid string identifiers.
83 * @return array
85 public function invalid_string_provider() {
86 return [
87 'Space in summary' => [
88 'example',
89 [],
90 'This table is used for purposes.',
92 'Comma in summary' => [
93 'example',
94 [],
95 'privacy,foo',
101 * Data provider with a list of valid string identifiers.
103 * @return array
105 public function valid_string_provider() {
106 return [
107 'Valid combination' => [
108 'example',
110 'privacy:example:valid',