‪TYPO3CMS  10.4
IconForRecordViewHelperTest.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 Prophecy\Prophecy\ObjectProphecy;
25 use TYPO3\TestingFramework\Fluid\Unit\ViewHelpers\ViewHelperBaseTestcase;
26 use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
27 
31 class ‪IconForRecordViewHelperTest extends ViewHelperBaseTestcase
32 {
36  protected ‪$iconProphecy;
37 
41  protected ‪$iconFactoryProphecy;
42 
46  protected ‪$viewHelper;
47 
48  protected function ‪setUp(): void
49  {
50  parent::setUp();
51  $this->iconProphecy = $this->prophesize(Icon::class);
52  $this->iconProphecy->render(Argument::any())->willReturn('icon html');
53  $this->iconFactoryProphecy = $this->prophesize(IconFactory::class);
54  $this->iconFactoryProphecy->getIconForRecord(Argument::cetera())->willReturn($this->iconProphecy->reveal());
55  GeneralUtility::addInstance(IconFactory::class, $this->iconFactoryProphecy->reveal());
56  }
57 
62  {
63  $renderingContextProphecy = $this->prophesize(RenderingContextInterface::class);
64 
65  $row = ['uid' => 123];
66  $arguments = [
67  'table' => 'tt_content',
68  'row' => $row,
69  'size' => ‪Icon::SIZE_LARGE,
70  'alternativeMarkupIdentifier' => 'inline'
71  ];
72  $iconForRecordViewHelper = new ‪IconForRecordViewHelper();
73  $iconForRecordViewHelper->setRenderingContext($renderingContextProphecy->reveal());
74  $iconForRecordViewHelper->setArguments($arguments);
75  $iconForRecordViewHelper->render();
76 
77  $this->iconFactoryProphecy->getIconForRecord('tt_content', $row, ‪Icon::SIZE_LARGE)->shouldHaveBeenCalled();
78  $this->iconProphecy->render('inline')->shouldHaveBeenCalled();
79  }
80 }
‪TYPO3\CMS\Core\ViewHelpers\IconForRecordViewHelper
Definition: IconForRecordViewHelper.php:44
‪TYPO3\CMS\Core\Tests\Unit\ViewHelpers\IconForRecordViewHelperTest\setUp
‪setUp()
Definition: IconForRecordViewHelperTest.php:45
‪TYPO3\CMS\Core\Imaging\Icon
Definition: Icon.php:26
‪TYPO3\CMS\Core\Imaging\IconFactory
Definition: IconFactory.php:33
‪TYPO3\CMS\Core\Tests\Unit\ViewHelpers
Definition: IconForRecordViewHelperTest.php:16
‪TYPO3\CMS\Core\Tests\Unit\ViewHelpers\IconForRecordViewHelperTest\$iconFactoryProphecy
‪IconFactory ObjectProphecy $iconFactoryProphecy
Definition: IconForRecordViewHelperTest.php:39
‪TYPO3\CMS\Core\Tests\Unit\ViewHelpers\IconForRecordViewHelperTest
Definition: IconForRecordViewHelperTest.php:32
‪TYPO3\CMS\Core\Tests\Unit\ViewHelpers\IconForRecordViewHelperTest\$viewHelper
‪IconViewHelper $viewHelper
Definition: IconForRecordViewHelperTest.php:43
‪TYPO3\CMS\Core\Tests\Unit\ViewHelpers\IconForRecordViewHelperTest\renderRendersIconByWayOfTheIconFactoryAccordingToGivenArguments
‪renderRendersIconByWayOfTheIconFactoryAccordingToGivenArguments()
Definition: IconForRecordViewHelperTest.php:58
‪TYPO3\CMS\Core\Tests\Unit\ViewHelpers\IconForRecordViewHelperTest\$iconProphecy
‪Icon ObjectProphecy $iconProphecy
Definition: IconForRecordViewHelperTest.php:35
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46
‪TYPO3\CMS\Core\ViewHelpers\IconViewHelper
Definition: IconViewHelper.php:57
‪TYPO3\CMS\Core\Imaging\Icon\SIZE_LARGE
‪const SIZE_LARGE
Definition: Icon.php:40