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/>.
17 namespace core\output
;
20 * Unit tests for the FontAwesome icon system.
23 * @copyright 2023 Andrew Nicols <andrew@nicols.co.uk>
24 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25 * @covers \core\output\icon_system_fontawesome
27 class icon_system_fontawesome_test
extends \advanced_testcase
{
30 * Test that the specified icon has an SVG fallback.
32 public function test_svg_fallback(): void
{
33 // This can't be tested using data provider because it initializes the theme system when running filtered tests.
34 $instance = icon_system
::instance(icon_system
::FONTAWESOME
);
35 $icons = array_map(function($key) {
37 [$component, $file] = explode(':', $key);
39 if ($component === 'core') {
40 $componentdir = $CFG->dirroot
;
41 } else if ($component === 'theme') {
42 $componentdir = \core_component
::get_component_directory('theme_' . \theme_config
::DEFAULT_THEME
);
44 $componentdir = \core_component
::get_component_directory($component);
49 'path' => $componentdir,
52 }, array_keys($instance->get_icon_name_map()));
54 foreach ($icons as $icon) {
56 file_exists("{$icon['path']}/pix/{$icon['filename']}.svg"), "No SVG equivalent found for '{$icon['key']}'",