‪TYPO3CMS  9.5
FontawesomeIconProviderTest.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
19 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
20 
24 class ‪FontawesomeIconProviderTest extends UnitTestCase
25 {
29  protected ‪$subject;
30 
34  protected ‪$icon;
35 
39  protected function ‪setUp()
40  {
41  $this->subject = new \TYPO3\CMS\Core\Imaging\IconProvider\FontawesomeIconProvider();
42  $this->icon = GeneralUtility::makeInstance(Icon::class);
43  $this->icon->setIdentifier('foo');
44  $this->icon->setSize(‪Icon::SIZE_SMALL);
45  }
46 
51  {
52  $this->subject->prepareIconMarkup($this->icon, ['name' => 'times']);
53  $this->assertEquals('<span class="icon-unify"><i class="fa fa-times"></i></span>', $this->icon->getMarkup());
54  }
55 
61  public function ‪wrongNamesDataProvider()
62  {
63  return [
64  'name with spaces' => ['name with spaces', 1440754979],
65  'name with spaces and umlauts' => ['name with spaces äöü', 1440754979],
66  'name umlauts' => ['häuser', 1440754979],
67  'name with underscore' => ['name_with_underscore', 1440754979],
68  'name is empty' => ['', 1440754978],
69  ];
70  }
71 
78  public function ‪prepareIconMarkupWithInvalidNameThrowsException($name, $expectedExceptionCode)
79  {
80  $this->expectException(\InvalidArgumentException::class);
81  $this->expectExceptionCode($expectedExceptionCode);
82 
83  $this->subject->prepareIconMarkup($this->icon, ['name' => $name]);
84  }
85 }
‪TYPO3\CMS\Core\Imaging\Icon\SIZE_SMALL
‪const SIZE_SMALL
Definition: Icon.php:29
‪TYPO3\CMS\Core\Tests\Unit\Imaging\IconProvider\FontawesomeIconProviderTest\prepareIconMarkupWithNameReturnsInstanceOfIconWithCorrectMarkup
‪prepareIconMarkupWithNameReturnsInstanceOfIconWithCorrectMarkup()
Definition: FontawesomeIconProviderTest.php:48
‪TYPO3\CMS\Core\Tests\Unit\Imaging\IconProvider\FontawesomeIconProviderTest\prepareIconMarkupWithInvalidNameThrowsException
‪prepareIconMarkupWithInvalidNameThrowsException($name, $expectedExceptionCode)
Definition: FontawesomeIconProviderTest.php:76
‪TYPO3\CMS\Core\Imaging\Icon
Definition: Icon.php:25
‪TYPO3\CMS\Core\Tests\Unit\Imaging\IconProvider\FontawesomeIconProviderTest\$icon
‪Icon $icon
Definition: FontawesomeIconProviderTest.php:32
‪TYPO3\CMS\Core\Tests\Unit\Imaging\IconProvider\FontawesomeIconProviderTest\$subject
‪TYPO3 CMS Core Imaging IconProvider FontawesomeIconProvider $subject
Definition: FontawesomeIconProviderTest.php:28
‪TYPO3\CMS\Core\Tests\Unit\Imaging\IconProvider\FontawesomeIconProviderTest
Definition: FontawesomeIconProviderTest.php:25
‪TYPO3\CMS\Core\Tests\Unit\Imaging\IconProvider\FontawesomeIconProviderTest\setUp
‪setUp()
Definition: FontawesomeIconProviderTest.php:37
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45
‪TYPO3\CMS\Core\Tests\Unit\Imaging\IconProvider
Definition: BitmapIconProviderTest.php:2
‪TYPO3\CMS\Core\Tests\Unit\Imaging\IconProvider\FontawesomeIconProviderTest\wrongNamesDataProvider
‪array wrongNamesDataProvider()
Definition: FontawesomeIconProviderTest.php:59