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 * Unit Tests for the request transform helper.
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\request\transform;
33 * Tests for the \core_privacy API's request transform helper 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 request_transform_test extends advanced_testcase {
40 * Test that user translation currently does nothing.
42 * We have not determined if we will do this or not, but we provide the functionality and encourgae people to use
43 * it so that it can be retrospectively fitted if required.
45 public function test_user() {
46 // Note: This test currently sucks, but there's no point creating users just to test this.
47 for ($i = 0; $i < 10; $i++) {
48 $this->assertEquals($i, transform::user($i));
53 * Test that the datetime is translated into a string.
55 public function test_datetime() {
56 $this->assertInternalType('string', transform::datetime(1));
60 * Test that the date is translated into a string.
62 public function test_date() {
63 $this->assertInternalType('string', transform::date(1));
67 * Ensure that the yesno function translates correctly.
69 * @dataProvider yesno_provider
70 * @param mixed $input The input to test
71 * @param string $expected The expected value
73 public function test_yesno($input, $expected) {
74 $this->assertEquals($expected, transform::yesno($input));
78 * Data provider for tests of the yesno transformation.
82 public function yesno_provider() {