‪TYPO3CMS  11.5
FontawesomeIconProviderTest.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
20 use Prophecy\Argument;
21 use Prophecy\PhpUnit\ProphecyTrait;
26 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
27 
31 class ‪FontawesomeIconProviderTest extends UnitTestCase
32 {
33  use ProphecyTrait;
34 
36 
40  protected ‪$icon;
41 
45  protected function ‪setUp(): void
46  {
47  parent::setUp();
48  $cacheProphecy = $this->prophesize(FrontendInterface::class);
49  $cacheProphecy->get(Argument::any())->willReturn([]);
50  $this->subject = new ‪FontawesomeIconProvider($cacheProphecy->reveal(), 'FontawesomeSvgIcons');
51  $this->icon = GeneralUtility::makeInstance(Icon::class);
52  $this->icon->setIdentifier('foo');
53  $this->icon->setSize(‪Icon::SIZE_SMALL);
54  }
55 
60  {
61  $this->subject->prepareIconMarkup($this->icon, ['name' => 'times']);
62  self::assertEquals('<span class="icon-unify"><i class="fa fa-times"></i></span>', $this->icon->getMarkup());
63  }
64 
70  public function ‪wrongNamesDataProvider(): array
71  {
72  return [
73  'name with spaces' => ['name with spaces', 1440754979],
74  'name with spaces and umlauts' => ['name with spaces äöü', 1440754979],
75  'name umlauts' => ['häuser', 1440754979],
76  'name with underscore' => ['name_with_underscore', 1440754979],
77  'name is empty' => ['', 1440754978],
78  ];
79  }
80 
87  public function ‪prepareIconMarkupWithInvalidNameThrowsException(string $name, int $expectedExceptionCode): void
88  {
89  $this->expectException(\InvalidArgumentException::class);
90  $this->expectExceptionCode($expectedExceptionCode);
91 
92  $this->subject->prepareIconMarkup($this->icon, ['name' => $name]);
93  }
94 }
‪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:57
‪TYPO3\CMS\Core\Imaging\Icon
Definition: Icon.php:26
‪TYPO3\CMS\Core\Tests\Unit\Imaging\IconProvider\FontawesomeIconProviderTest\$icon
‪Icon $icon
Definition: FontawesomeIconProviderTest.php:38
‪TYPO3\CMS\Core\Imaging\IconProvider\FontawesomeIconProvider
Definition: FontawesomeIconProvider.php:27
‪TYPO3\CMS\Core\Tests\Unit\Imaging\IconProvider\FontawesomeIconProviderTest
Definition: FontawesomeIconProviderTest.php:32
‪TYPO3\CMS\Core\Tests\Unit\Imaging\IconProvider\FontawesomeIconProviderTest\$subject
‪FontawesomeIconProvider $subject
Definition: FontawesomeIconProviderTest.php:34
‪TYPO3\CMS\Core\Tests\Unit\Imaging\IconProvider\FontawesomeIconProviderTest\setUp
‪setUp()
Definition: FontawesomeIconProviderTest.php:43
‪TYPO3\CMS\Core\Cache\Frontend\FrontendInterface
Definition: FrontendInterface.php:22
‪TYPO3\CMS\Core\Tests\Unit\Imaging\IconProvider\FontawesomeIconProviderTest\prepareIconMarkupWithInvalidNameThrowsException
‪prepareIconMarkupWithInvalidNameThrowsException(string $name, int $expectedExceptionCode)
Definition: FontawesomeIconProviderTest.php:85
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:50
‪TYPO3\CMS\Core\Tests\Unit\Imaging\IconProvider
Definition: BitmapIconProviderTest.php:18
‪TYPO3\CMS\Core\Tests\Unit\Imaging\IconProvider\FontawesomeIconProviderTest\wrongNamesDataProvider
‪array wrongNamesDataProvider()
Definition: FontawesomeIconProviderTest.php:68