TYPO3 CMS  TYPO3_8-7
WidgetRequestTest.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 
20 class WidgetRequestTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
21 {
26  {
27  $widgetContext = $this->getMockBuilder(\TYPO3\CMS\Fluid\Core\Widget\WidgetContext::class)
28  ->setMethods(['getControllerObjectName'])
29  ->getMock();
30  $widgetContext->expects($this->once())->method('getControllerObjectName')->will($this->returnValue('Tx_Fluid_ControllerObjectName'));
31  $widgetRequest = $this->getMockBuilder(\TYPO3\CMS\Fluid\Core\Widget\WidgetRequest::class)
32  ->setMethods(['setControllerObjectName'])
33  ->getMock();
34  $widgetRequest->expects($this->once())->method('setControllerObjectName')->with('Tx_Fluid_ControllerObjectName');
35  $widgetRequest->setWidgetContext($widgetContext);
36  }
37 
42  {
43  $widgetContext = $this->getMockBuilder(\TYPO3\CMS\Fluid\Core\Widget\WidgetContext::class)
44  ->setMethods(['getParentPluginNamespace', 'getWidgetIdentifier'])
45  ->getMock();
46  $widgetContext->expects($this->once())->method('getParentPluginNamespace')->will($this->returnValue('foo'));
47  $widgetContext->expects($this->once())->method('getWidgetIdentifier')->will($this->returnValue('bar'));
48  $widgetRequest = $this->getAccessibleMock(\TYPO3\CMS\Fluid\Core\Widget\WidgetRequest::class, ['dummy']);
49  $widgetRequest->_set('widgetContext', $widgetContext);
50  $this->assertEquals('foo[bar]', $widgetRequest->getArgumentPrefix());
51  }
52 
56  public function widgetContextCanBeReadAgain()
57  {
58  $widgetContext = $this->createMock(\TYPO3\CMS\Fluid\Core\Widget\WidgetContext::class);
59  $widgetRequest = $this->getMockBuilder(\TYPO3\CMS\Fluid\Core\Widget\WidgetRequest::class)
60  ->setMethods(['setControllerObjectName'])
61  ->getMock();
62  $widgetRequest->setWidgetContext($widgetContext);
63  $this->assertSame($widgetContext, $widgetRequest->getWidgetContext());
64  }
65 }