1 icon.test | protected IconTestCase::assertIconContentsEqual($svg1, $svg2, $message) |
Compare the contents of two SVG icons for equality.
This function compares the inner contents of an SVG while ignoring some differences on the <svg> tag, like the default classes added by theme_icon() and the aria-hidden="true" added when no alt text is used.
Parameters
string $svg1: The first SVG content to compare.
string $svg2: The second SVG contents to compare.
string $message: The message to display along with the assertion.
Return value
boolean: TRUE if the assertion succeeded, FALSE otherwise.
File
- core/
modules/ simpletest/ tests/ icon.test, line 191 - Tests for displaying and overriding icons in Backdrop.
Class
- IconTestCase
- Tests providing and overriding icons from both modules and themes.
Code
protected function assertIconContentsEqual($svg1, $svg2, $message) {
$reset_attributes = array(
'alt' => '',
'class' => '',
'aria-hidden' => '',
);
$tags = array('svg', 'title', 'use', 'desc', 'defs', 'linearGradient',
'stop', 'rect', 'circle', 'path');
$svg1 = image_add_svg_attributes($svg1, $reset_attributes);
$svg1 = filter_xss($svg1, $tags);
$svg2 = image_add_svg_attributes($svg2, $reset_attributes);
$svg2 = filter_xss($svg2, $tags);
return $this->assertEqual($svg1, $svg2, $message);
}