Differences Between: [Versions 310 and 311] [Versions 311 and 402] [Versions 311 and 403] [Versions 39 and 311]
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 * External functions test for record_feedback_action. 19 * 20 * @package core 21 * @category test 22 * @copyright 2020 Andrew Nicols <andrew@nicols.co.uk> 23 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 24 */ 25 26 namespace core\external\output\icon_system; 27 28 use externallib_advanced_testcase; 29 30 defined('MOODLE_INTERNAL') || die(); 31 32 global $CFG; 33 34 require_once($CFG->dirroot . '/webservice/tests/helpers.php'); 35 36 /** 37 * Class record_userfeedback_action_testcase 38 * 39 * @copyright 2020 Andrew Nicols <andrew@nicols.co.uk> 40 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 41 * @coversDefaultClass \core\external\output\icon_system\load_fontawesome_map 42 */ 43 class load_fontawesome_map_test extends externallib_advanced_testcase { 44 45 /** 46 * Perform setup before these tests are run. 47 */ 48 public static function setUpBeforeClass(): void { 49 global $CFG; 50 51 // In normal operation the external_api classes will have been loaded by the caller. 52 // The load_fontawesome_map class should not need to supplement our lack of autoloading of these classes. 53 require_once($CFG->libdir . '/externallib.php'); 54 } 55 56 /** 57 * Ensure that a valid theme which uses fontawesome returns a map. 58 * 59 * @covers ::execute_parameters 60 * @covers ::execute 61 * @covers ::execute_returns 62 * @dataProvider valid_fontawesome_theme_provider 63 * @param string $themename 64 */ 65 public function test_execute(string $themename): void { 66 $result = load_fontawesome_map::execute($themename); 67 $this->assertIsArray($result); 68 69 foreach ($result as $value) { 70 $this->assertArrayHasKey('component', $value); 71 $this->assertArrayHasKey('pix', $value); 72 $this->assertArrayHasKey('to', $value); 73 } 74 } 75 76 /** 77 * Ensure that an invalid theme cannot be loaded. 78 */ 79 public function test_execute_invalid_themename(): void { 80 $result = load_fontawesome_map::execute('invalidtheme'); 81 $this->assertDebuggingCalled( 82 'This page should be using theme invalidtheme which cannot be initialised. Falling back to the site theme boost' 83 ); 84 $this->assertIsArray($result); 85 } 86 87 /** 88 * Data provider for valid themes to use with the execute function. 89 * 90 * @return array 91 */ 92 public function valid_fontawesome_theme_provider(): array { 93 return [ 94 'Boost theme' => ['boost'], 95 'Classic theme (extends boost)' => ['classic'], 96 ]; 97 } 98 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body