‪TYPO3CMS  ‪main
IconForRecordViewHelperTest.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 PHPUnit\Framework\Attributes\Test;
23 use TYPO3\CMS\Core\Imaging\IconSize;
26 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
27 use TYPO3Fluid\Fluid\View\TemplateView;
28 
29 final class ‪IconForRecordViewHelperTest extends FunctionalTestCase
30 {
31  protected bool ‪$initializeDatabase = false;
32 
33  #[Test]
35  {
36  $iconMock = $this->createMock(Icon::class);
37  $iconMock->method('render')->willReturn('icon html');
38  $iconMock->expects(self::atLeastOnce())->method('render')->with('inline');
39  $iconFactoryMock = $this->createMock(IconFactory::class);
40  $iconFactoryMock->method('getIconForRecord')->with(self::anything())->willReturn($iconMock);
41  $iconFactoryMock->expects(self::atLeastOnce())->method('getIconForRecord')
42  ->with('tt_content', ['uid' => 123], IconSize::LARGE->value);
43  GeneralUtility::addInstance(IconFactory::class, $iconFactoryMock);
44 
45  $context = $this->get(RenderingContextFactory::class)->create();
46  $context->getTemplatePaths()->setTemplateSource(
47  '<core:iconForRecord table="tt_content" row="{uid: 123}" size="large" alternativeMarkupIdentifier="inline" />'
48  );
49  (new TemplateView($context))->render();
50  }
51 }
‪TYPO3\CMS\Core\Imaging\Icon
Definition: Icon.php:27
‪TYPO3\CMS\Core\Tests\Functional\ViewHelpers\IconForRecordViewHelperTest\renderRendersIconCallingIconFactoryAccordingToGivenArguments
‪renderRendersIconCallingIconFactoryAccordingToGivenArguments()
Definition: IconForRecordViewHelperTest.php:34
‪TYPO3\CMS\Core\Imaging\IconFactory
Definition: IconFactory.php:34
‪TYPO3\CMS\Core\Tests\Functional\ViewHelpers\IconForRecordViewHelperTest\$initializeDatabase
‪bool $initializeDatabase
Definition: IconForRecordViewHelperTest.php:31
‪TYPO3\CMS\Core\Tests\Functional\ViewHelpers
Definition: IconForRecordViewHelperTest.php:18
‪TYPO3\CMS\Fluid\Core\Rendering\RenderingContextFactory
Definition: RenderingContextFactory.php:51
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:52
‪TYPO3\CMS\Core\Tests\Functional\ViewHelpers\IconForRecordViewHelperTest
Definition: IconForRecordViewHelperTest.php:30