20 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
40 protected function setUp()
42 $this->subject = new \TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider();
43 $this->icon = GeneralUtility::makeInstance(Icon::class);
44 $this->icon->setIdentifier(
'foo');
53 $this->subject->prepareIconMarkup($this->icon, [
'source' =>
'fileadmin/foo.svg']);
54 $this->assertEquals(
'<img src="fileadmin/foo.svg" width="16" height="16" />', $this->icon->getMarkup());
62 $this->subject->prepareIconMarkup($this->icon, [
'source' =>
'/fileadmin/foo.svg']);
63 $this->assertEquals(
'<img src="/fileadmin/foo.svg" width="16" height="16" />', $this->icon->getMarkup());
71 $this->subject->prepareIconMarkup($this->icon, [
'source' =>
'EXT:core/Resources/Public/Images/foo.svg']);
72 $this->assertEquals(
'<img src="typo3/sysext/core/Resources/Public/Images/foo.svg" width="16" height="16" />', $this->icon->getMarkup());
80 $testFile = GeneralUtility::tempnam(uniqid(
'svg_') .
'.svg');
81 $this->testFilesToDelete[] = $testFile;
82 $svgTestFileContent =
'<?xml version="1.0" encoding="ISO-8859-1" standalone="no" ?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path fill="#CD201F" d="M11 12l3-2v6H2v-6l3 2 3-2 3 2z"></path><script><![CDATA[ function alertMe() {} ]]></script></svg>';
83 file_put_contents($testFile, $svgTestFileContent);
84 $this->testFilesToDelete[] = GeneralUtility::tempnam(uniqid(
'svg_') .
'.svg');
85 $this->subject->prepareIconMarkup($this->icon, [
'source' => $testFile]);
86 $this->assertEquals(
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path fill="#CD201F" d="M11 12l3-2v6H2v-6l3 2 3-2 3 2z"/></svg>', $this->icon->getMarkup(
SvgIconProvider::MARKUP_IDENTIFIER_INLINE));