‪TYPO3CMS  9.5
IconTest.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 
17 use Prophecy\Argument;
24 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
25 
29 class ‪IconTest extends UnitTestCase
30 {
34  protected ‪$subject;
35 
39  protected ‪$iconIdentifier = 'actions-close';
40 
44  protected ‪$overlayIdentifier = 'overlay-readonly';
45 
49  protected function ‪setUp()
50  {
51  $cacheManagerProphecy = $this->prophesize(CacheManager::class);
52  GeneralUtility::setSingletonInstance(CacheManager::class, $cacheManagerProphecy->reveal());
53  $cacheFrontendProphecy = $this->prophesize(FrontendInterface::class);
54  $cacheManagerProphecy->getCache('assets')->willReturn($cacheFrontendProphecy->reveal());
55  $cacheFrontendProphecy->get(Argument::cetera())->willReturn(false);
56  $cacheFrontendProphecy->set(Argument::cetera())->willReturn(null);
57  $iconFactory = new ‪IconFactory();
58  $this->subject = $iconFactory->getIcon($this->iconIdentifier, ‪Icon::SIZE_SMALL, $this->overlayIdentifier, ‪IconState::cast(‪IconState::STATE_DISABLED));
59  }
60 
61  public function ‪tearDown()
62  {
63  // Drop cache manager singleton again
64  GeneralUtility::purgeInstances();
65  parent::tearDown();
66  }
67 
72  {
73  $this->assertEquals($this->subject->render(), (string)$this->subject);
74  }
75 
80  {
81  $this->assertEquals($this->iconIdentifier, $this->subject->getIdentifier());
82  }
83 
88  {
89  $this->assertEquals($this->overlayIdentifier, $this->subject->getOverlayIcon()->getIdentifier());
90  }
91 
96  {
97  $this->assertEquals(‪Icon::SIZE_SMALL, $this->subject->getSize());
98  }
99 
103  public function ‪getStateReturnsCorrectIdentifier()
104  {
105  $this->assertTrue($this->subject->getState()->equals(‪IconState::STATE_DISABLED));
106  }
107 }
‪TYPO3\CMS\Core\Imaging\Icon\SIZE_SMALL
‪const SIZE_SMALL
Definition: Icon.php:29
‪TYPO3\CMS\Core\Tests\Unit\Imaging\IconTest\$subject
‪Icon $subject
Definition: IconTest.php:33
‪TYPO3\CMS\Core\Imaging\Icon
Definition: Icon.php:25
‪TYPO3\CMS\Core\Tests\Unit\Imaging\IconTest\getSizedentifierReturnsCorrectIdentifier
‪getSizedentifierReturnsCorrectIdentifier()
Definition: IconTest.php:92
‪TYPO3\CMS\Core\Type\Icon\IconState\STATE_DISABLED
‪const STATE_DISABLED
Definition: IconState.php:34
‪TYPO3\CMS\Core\Tests\Unit\Imaging\IconTest\setUp
‪setUp()
Definition: IconTest.php:46
‪TYPO3\CMS\Core\Imaging\IconFactory
Definition: IconFactory.php:31
‪TYPO3\CMS\Core\Tests\Unit\Imaging
Definition: DimensionTest.php:2
‪TYPO3\CMS\Core\Type\Enumeration\cast
‪static static cast($value)
Definition: Enumeration.php:182
‪TYPO3\CMS\Core\Cache\CacheManager
Definition: CacheManager.php:34
‪TYPO3\CMS\Core\Tests\Unit\Imaging\IconTest\tearDown
‪tearDown()
Definition: IconTest.php:58
‪TYPO3\CMS\Core\Tests\Unit\Imaging\IconTest\getIdentifierReturnsCorrectIdentifier
‪getIdentifierReturnsCorrectIdentifier()
Definition: IconTest.php:76
‪TYPO3\CMS\Core\Tests\Unit\Imaging\IconTest\$overlayIdentifier
‪string $overlayIdentifier
Definition: IconTest.php:41
‪TYPO3\CMS\Core\Type\Icon\IconState
Definition: IconState.php:23
‪TYPO3\CMS\Core\Cache\Frontend\FrontendInterface
Definition: FrontendInterface.php:21
‪TYPO3\CMS\Core\Tests\Unit\Imaging\IconTest\getStateReturnsCorrectIdentifier
‪getStateReturnsCorrectIdentifier()
Definition: IconTest.php:100
‪TYPO3\CMS\Core\Tests\Unit\Imaging\IconTest
Definition: IconTest.php:30
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45
‪TYPO3\CMS\Core\Tests\Unit\Imaging\IconTest\renderAndCastToStringReturnsTheSameCode
‪renderAndCastToStringReturnsTheSameCode()
Definition: IconTest.php:68
‪TYPO3\CMS\Core\Tests\Unit\Imaging\IconTest\$iconIdentifier
‪string $iconIdentifier
Definition: IconTest.php:37
‪TYPO3\CMS\Core\Tests\Unit\Imaging\IconTest\getOverlayIdentifierReturnsCorrectIdentifier
‪getOverlayIdentifierReturnsCorrectIdentifier()
Definition: IconTest.php:84