‪TYPO3CMS  10.4
IconTest.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 
18 use Prophecy\Argument;
19 use Psr\EventDispatcher\EventDispatcherInterface;
27 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
28 
32 class ‪IconTest extends UnitTestCase
33 {
37  protected ‪$subject;
38 
42  protected ‪$iconIdentifier = 'actions-close';
43 
47  protected ‪$overlayIdentifier = 'overlay-readonly';
48 
52  protected function ‪setUp(): void
53  {
54  parent::setUp();
55  $cacheManagerProphecy = $this->prophesize(CacheManager::class);
56  GeneralUtility::setSingletonInstance(CacheManager::class, $cacheManagerProphecy->reveal());
57  $cacheFrontendProphecy = $this->prophesize(FrontendInterface::class);
58  $cacheManagerProphecy->getCache('assets')->willReturn($cacheFrontendProphecy->reveal());
59  $cacheFrontendProphecy->get(Argument::cetera())->willReturn(false);
60  $cacheFrontendProphecy->set(Argument::cetera())->willReturn(null);
61  $eventDispatcherProphecy = $this->prophesize(EventDispatcherInterface::class);
62  $iconFactory = new ‪IconFactory($eventDispatcherProphecy->reveal(), new ‪IconRegistry());
63  $this->subject = $iconFactory->getIcon($this->iconIdentifier, ‪Icon::SIZE_SMALL, $this->overlayIdentifier, ‪IconState::cast(‪IconState::STATE_DISABLED));
64  }
65 
66  public function ‪tearDown(): void
67  {
68  // Drop cache manager singleton again
69  GeneralUtility::purgeInstances();
70  parent::tearDown();
71  }
72 
77  {
78  self::assertEquals($this->subject->render(), (string)$this->subject);
79  }
80 
85  {
86  self::assertEquals($this->iconIdentifier, $this->subject->getIdentifier());
87  }
88 
93  {
94  self::assertEquals($this->overlayIdentifier, $this->subject->getOverlayIcon()->getIdentifier());
95  }
96 
101  {
102  self::assertEquals(‪Icon::SIZE_SMALL, $this->subject->getSize());
103  }
104 
108  public function ‪getStateReturnsCorrectIdentifier()
109  {
110  self::assertTrue($this->subject->getState()->equals(‪IconState::STATE_DISABLED));
111  }
112 }
‪TYPO3\CMS\Core\Imaging\Icon\SIZE_SMALL
‪const SIZE_SMALL
Definition: Icon.php:30
‪TYPO3\CMS\Core\Tests\Unit\Imaging\IconTest\$subject
‪Icon $subject
Definition: IconTest.php:36
‪TYPO3\CMS\Core\Imaging\Icon
Definition: Icon.php:26
‪TYPO3\CMS\Core\Tests\Unit\Imaging\IconTest\getSizeIdentifierReturnsCorrectIdentifier
‪getSizeIdentifierReturnsCorrectIdentifier()
Definition: IconTest.php:97
‪TYPO3\CMS\Core\Type\Icon\IconState\STATE_DISABLED
‪const STATE_DISABLED
Definition: IconState.php:35
‪TYPO3\CMS\Core\Tests\Unit\Imaging\IconTest\setUp
‪setUp()
Definition: IconTest.php:49
‪TYPO3\CMS\Core\Imaging\IconFactory
Definition: IconFactory.php:33
‪TYPO3\CMS\Core\Tests\Unit\Imaging
Definition: DimensionTest.php:16
‪TYPO3\CMS\Core\Type\Enumeration\cast
‪static static cast($value)
Definition: Enumeration.php:186
‪TYPO3\CMS\Core\Imaging\IconRegistry
Definition: IconRegistry.php:38
‪TYPO3\CMS\Core\Cache\CacheManager
Definition: CacheManager.php:35
‪TYPO3\CMS\Core\Tests\Unit\Imaging\IconTest\tearDown
‪tearDown()
Definition: IconTest.php:63
‪TYPO3\CMS\Core\Tests\Unit\Imaging\IconTest\getIdentifierReturnsCorrectIdentifier
‪getIdentifierReturnsCorrectIdentifier()
Definition: IconTest.php:81
‪TYPO3\CMS\Core\Tests\Unit\Imaging\IconTest\$overlayIdentifier
‪string $overlayIdentifier
Definition: IconTest.php:44
‪TYPO3\CMS\Core\Type\Icon\IconState
Definition: IconState.php:24
‪TYPO3\CMS\Core\Cache\Frontend\FrontendInterface
Definition: FrontendInterface.php:22
‪TYPO3\CMS\Core\Tests\Unit\Imaging\IconTest\getStateReturnsCorrectIdentifier
‪getStateReturnsCorrectIdentifier()
Definition: IconTest.php:105
‪TYPO3\CMS\Core\Tests\Unit\Imaging\IconTest
Definition: IconTest.php:33
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46
‪TYPO3\CMS\Core\Tests\Unit\Imaging\IconTest\renderAndCastToStringReturnsTheSameCode
‪renderAndCastToStringReturnsTheSameCode()
Definition: IconTest.php:73
‪TYPO3\CMS\Core\Tests\Unit\Imaging\IconTest\$iconIdentifier
‪string $iconIdentifier
Definition: IconTest.php:40
‪TYPO3\CMS\Core\Tests\Unit\Imaging\IconTest\getOverlayIdentifierReturnsCorrectIdentifier
‪getOverlayIdentifierReturnsCorrectIdentifier()
Definition: IconTest.php:89