‪TYPO3CMS  11.5
RenderingContextTest.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 
22 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
23 use TYPO3Fluid\Fluid\Core\Variables\StandardVariableProvider;
24 use TYPO3Fluid\Fluid\Core\ViewHelper\ViewHelperVariableContainer;
25 
29 class ‪RenderingContextTest extends UnitTestCase
30 {
36  protected ‪$renderingContext;
37 
38  protected function ‪setUp(): void
39  {
40  parent::setUp();
41  $this->renderingContext = $this->getMockBuilder(RenderingContext::class)
42  ->addMethods(['dummy'])
43  ->disableOriginalConstructor()
44  ->getMock();
45  }
46 
51  {
52  $templateVariableContainer = $this->createMock(StandardVariableProvider::class);
53  $this->renderingContext->setVariableProvider($templateVariableContainer);
54  self::assertSame($this->renderingContext->getVariableProvider(), $templateVariableContainer, 'Template Variable Container could not be read out again.');
55  }
56 
61  {
62  $viewHelperVariableContainer = $this->createMock(ViewHelperVariableContainer::class);
63  $this->renderingContext->setViewHelperVariableContainer($viewHelperVariableContainer);
64  self::assertSame($viewHelperVariableContainer, $this->renderingContext->getViewHelperVariableContainer());
65  }
66 
73  public function ‪setControllerActionProcessesInputCorrectly($input, $expected): void
74  {
75  $subject = $this->getMockBuilder(RenderingContext::class)
76  ->addMethods(['dummy'])
77  ->disableOriginalConstructor()
78  ->getMock();
79  $request = $this->getMockBuilder(Request::class)->getMock();
80  $request->expects(self::exactly(2))->method('setControllerActionName')->with(lcfirst($expected));
81  $request->expects(self::exactly(2))->method('getControllerActionName')->willReturn(lcfirst($expected));
82  $subject->setRequest($request);
83  $subject->setControllerAction($input);
84  self::assertSame(lcfirst($expected), $subject->getControllerAction());
85  }
86 
90  public function ‪getControllerActionTestValues(): array
91  {
92  return [
93  ['default', 'default'],
94  ['default.html', 'default'],
95  ['default.sub.html', 'default'],
96  ['Sub/Default', 'Sub/Default'],
97  ['Sub/Default.html', 'Sub/Default'],
98  ['Sub/Default.sub.html', 'Sub/Default'],
99  ];
100  }
101 }
‪TYPO3\CMS\Fluid\Tests\Unit\Core\Rendering\RenderingContextTest\$renderingContext
‪RenderingContext $renderingContext
Definition: RenderingContextTest.php:35
‪TYPO3\CMS\Fluid\Tests\Unit\Core\Rendering\RenderingContextTest
Definition: RenderingContextTest.php:30
‪TYPO3\CMS\Fluid\Tests\Unit\Core\Rendering\RenderingContextTest\setControllerActionProcessesInputCorrectly
‪setControllerActionProcessesInputCorrectly($input, $expected)
Definition: RenderingContextTest.php:72
‪TYPO3\CMS\Fluid\Tests\Unit\Core\Rendering\RenderingContextTest\setUp
‪setUp()
Definition: RenderingContextTest.php:37
‪TYPO3\CMS\Fluid\Tests\Unit\Core\Rendering
Definition: RenderingContextTest.php:18
‪TYPO3\CMS\Fluid\Tests\Unit\Core\Rendering\RenderingContextTest\getControllerActionTestValues
‪array getControllerActionTestValues()
Definition: RenderingContextTest.php:89
‪TYPO3\CMS\Fluid\Tests\Unit\Core\Rendering\RenderingContextTest\viewHelperVariableContainerCanBeReadCorrectly
‪viewHelperVariableContainerCanBeReadCorrectly()
Definition: RenderingContextTest.php:59
‪TYPO3\CMS\Fluid\Core\Rendering\RenderingContext
Definition: RenderingContext.php:37
‪TYPO3\CMS\Extbase\Mvc\Request
Definition: Request.php:39
‪TYPO3\CMS\Fluid\Tests\Unit\Core\Rendering\RenderingContextTest\templateVariableContainerCanBeReadCorrectly
‪templateVariableContainerCanBeReadCorrectly()
Definition: RenderingContextTest.php:49