‪TYPO3CMS  9.5
WidgetRequestHandlerTest.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  */
22 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
23 
27 class ‪WidgetRequestHandlerTest extends UnitTestCase
28 {
32  protected ‪$widgetRequestHandler;
33 
37  protected function ‪setUp()
38  {
39  $this->widgetRequestHandler = $this->getAccessibleMock(\‪TYPO3\CMS\Fluid\Core\Widget\WidgetRequestHandler::class, ['dummy'], [], '', false);
40  }
41 
46  {
47  $_GET['fluid-widget-id'] = 123;
48  $this->assertTrue($this->widgetRequestHandler->canHandleRequest());
49  }
50 
55  {
56  $_GET['some-other-id'] = 123;
57  $this->assertFalse($this->widgetRequestHandler->canHandleRequest());
58  }
59 
64  {
65  $defaultWebRequestHandler = $this->getMockBuilder(\‪TYPO3\CMS\‪Extbase\Mvc\Web\AbstractRequestHandler::class)
66  ->setMethods(['handleRequest'])
67  ->disableOriginalConstructor()
68  ->getMock();
69  $this->assertTrue($this->widgetRequestHandler->getPriority() > $defaultWebRequestHandler->getPriority());
70  }
71 
75  public function ‪handleRequestCallsExpectedMethods()
76  {
77  $handler = new ‪WidgetRequestHandler();
78  $request = $this->createMock(Request::class);
79  $requestBuilder = $this->getMockBuilder(WidgetRequestBuilder::class)
80  ->setMethods(['build'])
81  ->getMock();
82  $requestBuilder->expects($this->once())->method('build')->willReturn($request);
83  $objectManager = $this->createMock(ObjectManagerInterface::class);
84  $objectManager->expects($this->once())->method('get')->willReturn($this->createMock(Response::class));
85  $requestDispatcher = $this->getMockBuilder(Dispatcher::class)
86  ->setMethods(['dispatch'])
87  ->disableOriginalConstructor()
88  ->getMock();
89  $requestDispatcher->expects($this->once())->method('dispatch')->with($request);
90  $this->inject($handler, 'widgetRequestBuilder', $requestBuilder);
91  $this->inject($handler, 'dispatcher', $requestDispatcher);
92  $this->inject($handler, 'objectManager', $objectManager);
93  $handler->handleRequest();
94  }
95 }
‪TYPO3\CMS\Fluid\Tests\Unit\Core\Widget\WidgetRequestHandlerTest
Definition: WidgetRequestHandlerTest.php:28
‪TYPO3\CMS\Extbase\Annotation
Definition: IgnoreValidation.php:4
‪TYPO3\CMS\Extbase\Mvc\Dispatcher
Definition: Dispatcher.php:23
‪TYPO3
‪TYPO3\CMS\Fluid\Core\Widget\WidgetRequestBuilder
Definition: WidgetRequestBuilder.php:26
‪TYPO3\CMS\Fluid\Tests\Unit\Core\Widget\WidgetRequestHandlerTest\handleRequestCallsExpectedMethods
‪handleRequestCallsExpectedMethods()
Definition: WidgetRequestHandlerTest.php:74
‪TYPO3\CMS\Fluid\Core\Widget\WidgetRequestHandler
Definition: WidgetRequestHandler.php:25
‪TYPO3\CMS\Extbase\Object\ObjectManagerInterface
Definition: ObjectManagerInterface.php:23
‪TYPO3\CMS\Fluid\Tests\Unit\Core\Widget\WidgetRequestHandlerTest\canHandleRequestReturnsTrueIfCorrectGetParameterIsSet
‪canHandleRequestReturnsTrueIfCorrectGetParameterIsSet()
Definition: WidgetRequestHandlerTest.php:44
‪TYPO3\CMS\Fluid\Tests\Unit\Core\Widget\WidgetRequestHandlerTest\$widgetRequestHandler
‪TYPO3 CMS Fluid Core Widget WidgetRequestHandler $widgetRequestHandler
Definition: WidgetRequestHandlerTest.php:31
‪TYPO3\CMS\Extbase\Mvc\Web\Response
Definition: Response.php:25
‪TYPO3\CMS\Fluid\Tests\Unit\Core\Widget\WidgetRequestHandlerTest\canHandleRequestReturnsFalsefGetParameterIsNotSet
‪canHandleRequestReturnsFalsefGetParameterIsNotSet()
Definition: WidgetRequestHandlerTest.php:53
‪TYPO3\CMS\Extbase\Mvc\Web\Request
Definition: Request.php:21
‪TYPO3\CMS\Fluid\Tests\Unit\Core\Widget\WidgetRequestHandlerTest\setUp
‪setUp()
Definition: WidgetRequestHandlerTest.php:36
‪TYPO3\CMS\Fluid\Tests\Unit\Core\Widget
Definition: AbstractWidgetControllerTest.php:2
‪TYPO3\CMS\Fluid\Tests\Unit\Core\Widget\WidgetRequestHandlerTest\priorityIsHigherThanDefaultRequestHandler
‪priorityIsHigherThanDefaultRequestHandler()
Definition: WidgetRequestHandlerTest.php:62