1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-04-09 02:12:44 +02:00

[ticket/15538] Add icon tests

PHPBB3-15538
This commit is contained in:
mrgoldy 2019-10-31 19:36:19 +01:00
parent b4b6ba0a37
commit fea97cd115
6 changed files with 192 additions and 7 deletions

View File

@ -125,6 +125,9 @@ class icon extends \Twig\Extension\AbstractExtension
*/
protected function prepare_svg(\Twig\TemplateWrapper $file)
{
$code = $file->render();
$code = preg_replace( "/<\?xml.+?\?>/", '', $code);
$doc = new \DOMDocument();
$doc->preserveWhiteSpace = false;
@ -132,7 +135,16 @@ class icon extends \Twig\Extension\AbstractExtension
* Suppression is needed as DOMDocument does not like HTML5 and SVGs.
* Options parameter prevents $dom->saveHTML() from adding an <html> element.
*/
@$doc->loadHTML($file->render(), LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
@$doc->loadHTML($code, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
// Remove any DOCTYPE
foreach ($doc->childNodes as $child)
{
if ($child->nodeType === XML_DOCUMENT_TYPE_NODE)
{
$child->parentNode->removeChild($child);
}
}
$xpath = new \DOMXPath($doc);

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
{{ Icon(type, icon, title, hidden, classes, attributes) }}

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 8.1 KiB

View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><title>My fake title!</title><path d="M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04c.39-.39.39-1.02 0-1.41l-2.34-2.34c-.39-.39-1.02-.39-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z"/><path d="M0 0h24v24H0z" fill="none"/></svg>

After

Width:  |  Height:  |  Size: 317 B

View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path fill="none" d="M0 0h24v24H0z"/><path d="M20.01 15.38c-1.23 0-2.42-.2-3.53-.56-.35-.12-.74-.03-1.01.24l-1.57 1.97c-2.83-1.35-5.48-3.9-6.89-6.83l1.95-1.66c.27-.28.35-.67.24-1.02-.37-1.11-.56-2.3-.56-3.53 0-.54-.45-.99-.99-.99H4.19C3.65 3 3 3.24 3 3.99 3 13.28 10.73 21 20.01 21c.71 0 .99-.63.99-1.18v-3.45c0-.54-.45-.99-.99-.99z"/></svg>

After

Width:  |  Height:  |  Size: 425 B