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