79efb0a86fa4fd5a22e5baeee54dfaf1feb1c7eb
[Packages/TYPO3.CMS.git] / typo3 / sysext / fluid / Tests / Unit / Core / Widget / AbstractWidgetControllerTest.php
1 <?php
2
3 /* *
4 * This script belongs to the FLOW3 package "Fluid". *
5 * *
6 * It is free software; you can redistribute it and/or modify it under *
7 * the terms of the GNU Lesser General Public License as published by the *
8 * Free Software Foundation, either version 3 of the License, or (at your *
9 * option) any later version. *
10 * *
11 * This script is distributed in the hope that it will be useful, but *
12 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- *
13 * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser *
14 * General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU Lesser General Public *
17 * License along with the script. *
18 * If not, see http://www.gnu.org/licenses/lgpl.html *
19 * *
20 * The TYPO3 project - inspiring people to share! *
21 * */
22
23 /**
24 * Testcase for AbstractWidgetController
25 *
26 * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
27 */
28 class Tx_Fluid_Tests_Unit_Core_Widget_AbstractWidgetControllerTest extends Tx_Extbase_Tests_Unit_BaseTestCase {
29
30 /**
31 * @test
32 * @author Sebastian Kurfürst <sebastian@typo3.org>
33 */
34 public function canHandleWidgetRequest() {
35 $request = $this->getMock('Tx_Fluid_Core_Widget_WidgetRequest', array('dummy'), array(), '', FALSE);
36 $abstractWidgetController = $this->getMock('Tx_Fluid_Core_Widget_AbstractWidgetController', array('dummy'), array(), '', FALSE);
37 $this->assertTrue($abstractWidgetController->canProcessRequest($request));
38 }
39
40 /**
41 * @test
42 * @author Sebastian Kurfürst <sebastian@typo3.org>
43 * @author Bastian Waidelich <bastian@typo3.org>
44 */
45 public function processRequestSetsWidgetConfiguration() {
46 $widgetContext = $this->getMock('Tx_Fluid_Core_Widget_WidgetContext');
47 $widgetContext->expects($this->once())->method('getWidgetConfiguration')->will($this->returnValue('myConfiguration'));
48
49 $request = $this->getMock('Tx_Fluid_Core_Widget_WidgetRequest', array(), array(), '', FALSE);
50 $request->expects($this->once())->method('getWidgetContext')->will($this->returnValue($widgetContext));
51
52 $response = $this->getMock('Tx_Extbase_MVC_ResponseInterface');
53
54 $abstractWidgetController = $this->getAccessibleMock('Tx_Fluid_Core_Widget_AbstractWidgetController', array('resolveActionMethodName', 'initializeActionMethodArguments', 'initializeActionMethodValidators', 'initializeAction', 'checkRequestHash', 'mapRequestArgumentsToControllerArguments', 'buildControllerContext', 'resolveView', 'callActionMethod'), array(), '', FALSE);
55
56 $mockUriBuilder = $this->getMock('Tx_Extbase_MVC_Web_Routing_UriBuilder');
57
58 $objectManager = $this->getMock('Tx_Extbase_Object_ObjectManagerInterface');
59 $objectManager->expects($this->any())->method('create')->with('Tx_Extbase_MVC_Web_Routing_UriBuilder')->will($this->returnValue($mockUriBuilder));
60 $abstractWidgetController->_set('objectManager', $objectManager);
61
62 $abstractWidgetController->processRequest($request, $response);
63
64 $widgetConfiguration = $abstractWidgetController->_get('widgetConfiguration');
65 $this->assertEquals('myConfiguration', $widgetConfiguration);
66 }
67 }
68 ?>