‪TYPO3CMS  11.5
IconTest.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;
22 use Psr\Container\ContainerInterface;
23 use Psr\EventDispatcher\EventDispatcherInterface;
29 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
30 
34 class ‪IconTest extends UnitTestCase
35 {
36  use ProphecyTrait;
37 
38  protected ?‪Icon ‪$subject;
39  protected string ‪$iconIdentifier = 'actions-close';
40  protected string ‪$overlayIdentifier = 'overlay-readonly';
41 
45  protected function ‪setUp(): void
46  {
47  parent::setUp();
48  $cacheFrontendProphecy = $this->prophesize(FrontendInterface::class);
49  $cacheFrontendProphecy->get(Argument::cetera())->willReturn(false);
50  $cacheFrontendProphecy->set(Argument::cetera())->willReturn(null);
51  $eventDispatcherProphecy = $this->prophesize(EventDispatcherInterface::class);
52  $containerProphecy = $this->prophesize(ContainerInterface::class);
53  $iconFactory = new ‪IconFactory($eventDispatcherProphecy->reveal(), new ‪IconRegistry($cacheFrontendProphecy->reveal(), 'BackendIcons'), $containerProphecy->reveal());
54  $this->subject = $iconFactory->getIcon($this->iconIdentifier, ‪Icon::SIZE_SMALL, $this->overlayIdentifier, ‪IconState::cast(‪IconState::STATE_DISABLED));
55  }
56 
60  public function ‪renderAndCastToStringReturnsTheSameCode(): void
61  {
62  self::assertEquals($this->subject->render(), (string)$this->subject);
63  }
64 
68  public function ‪getIdentifierReturnsCorrectIdentifier(): void
69  {
70  self::assertEquals($this->iconIdentifier, $this->subject->getIdentifier());
71  }
72 
77  {
78  self::assertEquals($this->overlayIdentifier, $this->subject->getOverlayIcon()->getIdentifier());
79  }
80 
84  public function ‪getSizeIdentifierReturnsCorrectIdentifier(): void
85  {
86  self::assertEquals(‪Icon::SIZE_SMALL, $this->subject->getSize());
87  }
88 
92  public function ‪getStateReturnsCorrectIdentifier(): void
93  {
94  self::assertTrue($this->subject->getState()->equals(‪IconState::STATE_DISABLED));
95  }
96 }
‪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:37
‪TYPO3\CMS\Core\Imaging\Icon
Definition: Icon.php:26
‪TYPO3\CMS\Core\Tests\Unit\Imaging\IconTest\getSizeIdentifierReturnsCorrectIdentifier
‪getSizeIdentifierReturnsCorrectIdentifier()
Definition: IconTest.php:83
‪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:44
‪TYPO3\CMS\Core\Imaging\IconFactory
Definition: IconFactory.php:34
‪TYPO3\CMS\Core\Tests\Unit\Imaging
Definition: DimensionTest.php:18
‪TYPO3\CMS\Core\Type\Enumeration\cast
‪static static cast($value)
Definition: Enumeration.php:186
‪TYPO3\CMS\Core\Imaging\IconRegistry
Definition: IconRegistry.php:32
‪TYPO3\CMS\Core\Tests\Unit\Imaging\IconTest\getIdentifierReturnsCorrectIdentifier
‪getIdentifierReturnsCorrectIdentifier()
Definition: IconTest.php:67
‪TYPO3\CMS\Core\Tests\Unit\Imaging\IconTest\$overlayIdentifier
‪string $overlayIdentifier
Definition: IconTest.php:39
‪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:91
‪TYPO3\CMS\Core\Tests\Unit\Imaging\IconTest
Definition: IconTest.php:35
‪TYPO3\CMS\Core\Tests\Unit\Imaging\IconTest\renderAndCastToStringReturnsTheSameCode
‪renderAndCastToStringReturnsTheSameCode()
Definition: IconTest.php:59
‪TYPO3\CMS\Core\Tests\Unit\Imaging\IconTest\$iconIdentifier
‪string $iconIdentifier
Definition: IconTest.php:38
‪TYPO3\CMS\Core\Tests\Unit\Imaging\IconTest\getOverlayIdentifierReturnsCorrectIdentifier
‪getOverlayIdentifierReturnsCorrectIdentifier()
Definition: IconTest.php:75