TYPO3 CMS  TYPO3_7-6
WidgetRequestHandlerTest.php
Go to the documentation of this file.
1 <?php
3 
4 /* *
5  * This script is backported from the FLOW3 package "TYPO3.Fluid". *
6  * *
7  * It is free software; you can redistribute it and/or modify it under *
8  * the terms of the GNU Lesser General Public License, either version 3 *
9  * of the License, or (at your option) any later version. *
10  * *
11  * *
12  * This script is distributed in the hope that it will be useful, but *
13  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- *
14  * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser *
15  * General Public License for more details. *
16  * *
17  * You should have received a copy of the GNU Lesser General Public *
18  * License along with the script. *
19  * If not, see http://www.gnu.org/licenses/lgpl.html *
20  * *
21  * The TYPO3 project - inspiring people to share! *
22  * */
29 
34 {
39 
43  protected function setUp()
44  {
45  $this->widgetRequestHandler = $this->getAccessibleMock(\TYPO3\CMS\Fluid\Core\Widget\WidgetRequestHandler::class, ['dummy'], [], '', false);
46  }
47 
52  {
53  $_GET['fluid-widget-id'] = 123;
54  $this->assertTrue($this->widgetRequestHandler->canHandleRequest());
55  }
56 
61  {
62  $_GET['some-other-id'] = 123;
63  $this->assertFalse($this->widgetRequestHandler->canHandleRequest());
64  }
65 
70  {
71  $defaultWebRequestHandler = $this->getMock(\TYPO3\CMS\Extbase\Mvc\Web\AbstractRequestHandler::class, ['handleRequest'], [], '', false);
72  $this->assertTrue($this->widgetRequestHandler->getPriority() > $defaultWebRequestHandler->getPriority());
73  }
74 
79  {
80  $handler = new WidgetRequestHandler();
81  $request = $this->getMock(Request::class);
82  $requestBuilder = $this->getMock(WidgetRequestBuilder::class, ['build']);
83  $requestBuilder->expects($this->once())->method('build')->willReturn($request);
84  $objectManager = $this->getMock(ObjectManagerInterface::class);
85  $objectManager->expects($this->once())->method('get')->willReturn($this->getMock(Response::class));
86  $requestDispatcher = $this->getMock(Dispatcher::class, ['dispatch'], [], '', false);
87  $requestDispatcher->expects($this->once())->method('dispatch')->with($request);
88  $this->inject($handler, 'widgetRequestBuilder', $requestBuilder);
89  $this->inject($handler, 'dispatcher', $requestDispatcher);
90  $this->inject($handler, 'objectManager', $objectManager);
91  $handler->handleRequest();
92  }
93 }
inject($target, $name, $dependency)
getAccessibleMock( $originalClassName, $methods=[], array $arguments=[], $mockClassName='', $callOriginalConstructor=true, $callOriginalClone=true, $callAutoload=true)