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