1 |
efrain |
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 |
namespace core\output;
|
|
|
18 |
|
|
|
19 |
/**
|
|
|
20 |
* Unit tests for the FontAwesome icon system.
|
|
|
21 |
*
|
|
|
22 |
* @package core
|
|
|
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
|
|
|
26 |
*/
|
|
|
27 |
class icon_system_fontawesome_test extends \advanced_testcase {
|
|
|
28 |
|
|
|
29 |
/**
|
|
|
30 |
* Test that the specified icon has an SVG fallback.
|
|
|
31 |
*/
|
|
|
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) {
|
|
|
36 |
global $CFG;
|
|
|
37 |
[$component, $file] = explode(':', $key);
|
|
|
38 |
|
|
|
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);
|
|
|
43 |
} else {
|
|
|
44 |
$componentdir = \core_component::get_component_directory($component);
|
|
|
45 |
}
|
|
|
46 |
|
|
|
47 |
return [
|
|
|
48 |
'key' => $key,
|
|
|
49 |
'path' => $componentdir,
|
|
|
50 |
'filename' => $file,
|
|
|
51 |
];
|
|
|
52 |
}, array_keys($instance->get_icon_name_map()));
|
|
|
53 |
|
|
|
54 |
foreach ($icons as $icon) {
|
|
|
55 |
$this->assertTrue(
|
|
|
56 |
file_exists("{$icon['path']}/pix/{$icon['filename']}.svg"), "No SVG equivalent found for '{$icon['key']}'",
|
|
|
57 |
);
|
|
|
58 |
}
|
|
|
59 |
}
|
|
|
60 |
}
|