See Release Notes
Long Term Support Release
Differences Between: [Versions 39 and 311] [Versions 39 and 400] [Versions 39 and 401] [Versions 39 and 402] [Versions 39 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 * Tests for field value validators of tool_uploaduser. 19 * 20 * @package tool_uploaduser 21 * @copyright 2019 Jun Pataleta 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 25 use tool_uploaduser\local\field_value_validators; 26 27 defined('MOODLE_INTERNAL') || die(); 28 29 global $CFG; 30 31 /** 32 * Tests for field value validators of tool_uploaduser. 33 * 34 * @package tool_uploaduser 35 * @copyright 2019 Jun Pataleta 36 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 37 */ 38 class field_value_validators_testcase extends advanced_testcase { 39 40 /** 41 * Data provider for \field_value_validators_testcase::test_validate_theme(). 42 */ 43 public function themes_provider() { 44 return [ 45 'User themes disabled' => [ 46 false, 'boost', 'warning', get_string('userthemesnotallowed', 'tool_uploaduser') 47 ], 48 'User themes enabled, empty theme' => [ 49 true, '', 'warning', get_string('notheme', 'tool_uploaduser') 50 ], 51 'User themes enabled, invalid theme' => [ 52 true, 'badtheme', 'warning', get_string('invalidtheme', 'tool_uploaduser', 'badtheme') 53 ], 54 'User themes enabled, valid theme' => [ 55 true, 'boost', 'normal', '' 56 ], 57 ]; 58 } 59 60 /** 61 * Unit test for \tool_uploaduser\local\field_value_validators::validate_theme() 62 * 63 * @dataProvider themes_provider 64 * @param boolean $userthemesallowed Whether to allow user themes. 65 * @param string $themename The theme name to be tested. 66 * @param string $expectedstatus The expected status. 67 * @param string $expectedmessage The expected validation message. 68 */ 69 public function test_validate_theme($userthemesallowed, $themename, $expectedstatus, $expectedmessage) { 70 $this->resetAfterTest(); 71 72 // Set value for $CFG->allowuserthemes. 73 set_config('allowuserthemes', $userthemesallowed); 74 75 // Validate the theme. 76 list($status, $message) = field_value_validators::validate_theme($themename); 77 78 // Check the status and validation message. 79 $this->assertEquals($expectedstatus, $status); 80 $this->assertEquals($expectedmessage, $message); 81 } 82 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body