‪TYPO3CMS  11.5
IconViewHelperTest.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;
27 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
28 
29 class ‪IconViewHelperTest extends FunctionalTestCase
30 {
31  use ProphecyTrait;
32 
36  protected ‪$initializeDatabase = false;
37 
42  {
43  $iconFactoryProphecy = $this->prophesize(IconFactory::class);
44  GeneralUtility::addInstance(IconFactory::class, $iconFactoryProphecy->reveal());
45  $iconProphecy = $this->prophesize(Icon::class);
46  $iconFactoryProphecy->getIcon('myIdentifier', ‪Icon::SIZE_SMALL, null, ‪IconState::cast(‪IconState::STATE_DEFAULT))->shouldBeCalled()->willReturn($iconProphecy->reveal());
47  $iconProphecy->render(null)->shouldBeCalled()->willReturn('htmlFoo');
48 
49  $view = new ‪StandaloneView();
50  $view->setTemplateSource('<core:icon identifier="myIdentifier" size="small" state="default" />');
51  self::assertSame('htmlFoo', $view->render());
52  }
53 
58  {
59  $iconFactoryProphecy = $this->prophesize(IconFactory::class);
60  GeneralUtility::addInstance(IconFactory::class, $iconFactoryProphecy->reveal());
61  $iconProphecy = $this->prophesize(Icon::class);
62  $iconFactoryProphecy->getIcon('myIdentifier', ‪Icon::SIZE_LARGE, null, ‪IconState::cast(‪IconState::STATE_DEFAULT))->shouldBeCalled()->willReturn($iconProphecy->reveal());
63  $iconProphecy->render(null)->shouldBeCalled()->willReturn('htmlFoo');
64 
65  $view = new ‪StandaloneView();
66  $view->setTemplateSource('<core:icon identifier="myIdentifier" size="large" state="default" />');
67  self::assertSame('htmlFoo', $view->render());
68  }
69 
74  {
75  $iconFactoryProphecy = $this->prophesize(IconFactory::class);
76  GeneralUtility::addInstance(IconFactory::class, $iconFactoryProphecy->reveal());
77  $iconProphecy = $this->prophesize(Icon::class);
78  $iconFactoryProphecy->getIcon('myIdentifier', ‪Icon::SIZE_SMALL, null, ‪IconState::cast(‪IconState::STATE_DISABLED))->shouldBeCalled()->willReturn($iconProphecy->reveal());
79  $iconProphecy->render(null)->shouldBeCalled()->willReturn('htmlFoo');
80 
81  $view = new ‪StandaloneView();
82  $view->setTemplateSource('<core:icon identifier="myIdentifier" size="small" state="disabled" />');
83  self::assertSame('htmlFoo', $view->render());
84  }
85 
90  {
91  $iconFactoryProphecy = $this->prophesize(IconFactory::class);
92  GeneralUtility::addInstance(IconFactory::class, $iconFactoryProphecy->reveal());
93  $iconProphecy = $this->prophesize(Icon::class);
94  $iconFactoryProphecy->getIcon('myIdentifier', Argument::any(), 'overlayString', ‪IconState::cast(‪IconState::STATE_DEFAULT))->shouldBeCalled()->willReturn($iconProphecy->reveal());
95  $iconProphecy->render(null)->shouldBeCalled()->willReturn('htmlFoo');
96 
97  $view = new ‪StandaloneView();
98  $view->setTemplateSource('<core:icon identifier="myIdentifier" size="large" state="default" overlay="overlayString" />');
99  self::assertSame('htmlFoo', $view->render());
100  }
101 }
‪TYPO3\CMS\Core\Imaging\Icon\SIZE_SMALL
‪const SIZE_SMALL
Definition: Icon.php:30
‪TYPO3\CMS\Core\Imaging\Icon
Definition: Icon.php:26
‪TYPO3\CMS\Core\Type\Icon\IconState\STATE_DISABLED
‪const STATE_DISABLED
Definition: IconState.php:35
‪TYPO3\CMS\Core\Imaging\IconFactory
Definition: IconFactory.php:34
‪TYPO3\CMS\Core\Tests\Functional\ViewHelpers\IconViewHelperTest\renderCallsIconFactoryWithDefaultSizeAndDefaultStateAndReturnsResult
‪renderCallsIconFactoryWithDefaultSizeAndDefaultStateAndReturnsResult()
Definition: IconViewHelperTest.php:39
‪TYPO3\CMS\Core\Type\Enumeration\cast
‪static static cast($value)
Definition: Enumeration.php:186
‪TYPO3\CMS\Core\Tests\Functional\ViewHelpers\IconViewHelperTest
Definition: IconViewHelperTest.php:30
‪TYPO3\CMS\Core\Type\Icon\IconState\STATE_DEFAULT
‪const STATE_DEFAULT
Definition: IconState.php:30
‪TYPO3\CMS\Core\Tests\Functional\ViewHelpers
Definition: IconForRecordViewHelperTest.php:18
‪TYPO3\CMS\Core\Tests\Functional\ViewHelpers\IconViewHelperTest\renderCallsIconFactoryWithGivenOverlayAndReturnsResult
‪renderCallsIconFactoryWithGivenOverlayAndReturnsResult()
Definition: IconViewHelperTest.php:87
‪TYPO3\CMS\Core\Type\Icon\IconState
Definition: IconState.php:24
‪TYPO3\CMS\Fluid\View\StandaloneView
Definition: StandaloneView.php:31
‪TYPO3\CMS\Core\Tests\Functional\ViewHelpers\IconViewHelperTest\renderCallsIconFactoryWithGivenSizeAndReturnsResult
‪renderCallsIconFactoryWithGivenSizeAndReturnsResult()
Definition: IconViewHelperTest.php:55
‪TYPO3\CMS\Core\Tests\Functional\ViewHelpers\IconViewHelperTest\renderCallsIconFactoryWithGivenStateAndReturnsResult
‪renderCallsIconFactoryWithGivenStateAndReturnsResult()
Definition: IconViewHelperTest.php:71
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:50
‪TYPO3\CMS\Core\Imaging\Icon\SIZE_LARGE
‪const SIZE_LARGE
Definition: Icon.php:40
‪TYPO3\CMS\Core\Tests\Functional\ViewHelpers\IconViewHelperTest\$initializeDatabase
‪bool $initializeDatabase
Definition: IconViewHelperTest.php:34