TYPO3CMS  8
 All Classes Namespaces Files Functions Variables Pages
IconForRecordViewHelperTest.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Core\Tests\Unit\ViewHelpers;
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;
25 use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
26 
31 {
35  protected $iconProphecy;
36 
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 
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 }
static addInstance($className, $instance)