TYPO3 CMS  TYPO3_8-7
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 
26 
30 class IconForRecordViewHelperTest extends ViewHelperBaseTestcase
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 
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 }
static addInstance($className, $instance)