mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 14:27:22 +01:00
MDL-67271 core: Add test to find missing SVG icons
Ensure that all system icons now come with an accompanying SVG file. Any missing SVG files have been addressed, and to maintain this consistency, a PHPUnit test has been implemented to validate the inclusion of SVG files for any new icons.
This commit is contained in:
parent
b4c6ed3650
commit
5281100031
@ -45,11 +45,11 @@ defined('MOODLE_INTERNAL') || die();
|
||||
*/
|
||||
abstract class icon_system {
|
||||
/**
|
||||
* @var Default icon system.
|
||||
* @var string Default icon system.
|
||||
*/
|
||||
const STANDARD = '\\core\\output\\icon_system_standard';
|
||||
/**
|
||||
* @var Default icon system.
|
||||
* @var string Default icon system.
|
||||
*/
|
||||
const FONTAWESOME = '\\core\\output\\icon_system_fontawesome';
|
||||
|
||||
|
66
lib/tests/output/icon_system_fontawesome_test.php
Normal file
66
lib/tests/output/icon_system_fontawesome_test.php
Normal file
@ -0,0 +1,66 @@
|
||||
<?php
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
namespace core\output;
|
||||
|
||||
/**
|
||||
* Unit tests for the FontAwesome icon system.
|
||||
*
|
||||
* @package core
|
||||
* @copyright 2023 Andrew Nicols <andrew@nicols.co.uk>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @covers \core\output\icon_system_fontawesome
|
||||
*/
|
||||
class icon_system_fontawesome_test extends \advanced_testcase {
|
||||
/**
|
||||
* Returns a list of all mapped icons along with the component dir, and file name (without any suffix/extension).
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_icon_name_map(): array {
|
||||
$instance = icon_system::instance(icon_system::FONTAWESOME);
|
||||
return array_map(function($key) {
|
||||
global $CFG;
|
||||
[$component, $file] = explode(':', $key);
|
||||
|
||||
if ($component === 'core') {
|
||||
$componentdir = $CFG->dirroot;
|
||||
} else if ($component === 'theme') {
|
||||
$componentdir = \core_component::get_component_directory('theme_' . \theme_config::DEFAULT_THEME);
|
||||
} else {
|
||||
$componentdir = \core_component::get_component_directory($component);
|
||||
}
|
||||
|
||||
return [
|
||||
$key,
|
||||
$componentdir,
|
||||
$file,
|
||||
];
|
||||
}, array_keys($instance->get_icon_name_map()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that the specified icon has an SVG fallback.
|
||||
*
|
||||
* @param string $key Icon key.
|
||||
* @param string $path Path to the component directory.
|
||||
* @param string $filename Icon filename.
|
||||
* @dataProvider get_icon_name_map
|
||||
*/
|
||||
public function test_svg_fallback(string $key, string $path, string $filename): void {
|
||||
$this->assertTrue(file_exists("{$path}/pix/{$filename}.svg"), "No SVG equivalent found for '{$key}'");
|
||||
}
|
||||
}
|
@ -167,6 +167,8 @@ being forced open in all behat tests.
|
||||
the grade item once the recalculations are completed. (This was fixed in 4.3, 4.2.2)
|
||||
* Added a new constant called MAX_PASSWORD_CHARACTERS in moodlelib.php to hold a length of accepted password.
|
||||
* Added a new method called exceeds_password_length in moodlelib.php to validate the password length.
|
||||
* Ensure that all system icons now come with an accompanying SVG file. Any missing SVG files have been addressed, and to maintain
|
||||
this consistency, a PHPUnit test has been implemented to validate the inclusion of SVG files for any new icons.
|
||||
|
||||
=== 4.2 ===
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user