‪TYPO3CMS  10.4
WidgetRequestHandlerTest.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
18 use Prophecy\Argument;
26 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
27 
31 class ‪WidgetRequestHandlerTest extends UnitTestCase
32 {
36  protected ‪$widgetRequestHandler;
37 
41  protected function ‪setUp(): void
42  {
43  parent::setUp();
44  $this->widgetRequestHandler = $this->getAccessibleMock(WidgetRequestHandler::class, ['dummy'], [], '', false);
45  }
46 
51  {
52  $_GET['fluid-widget-id'] = 123;
53  self::assertTrue($this->widgetRequestHandler->canHandleRequest());
54  }
55 
60  {
61  $_GET['some-other-id'] = 123;
62  self::assertFalse($this->widgetRequestHandler->canHandleRequest());
63  }
64 
69  {
70  $defaultWebRequestHandler = $this->getMockBuilder(AbstractRequestHandler::class)
71  ->setMethods(['handleRequest'])
72  ->disableOriginalConstructor()
73  ->getMock();
74  self::assertTrue($this->widgetRequestHandler->getPriority() > $defaultWebRequestHandler->getPriority());
75  }
76 
80  public function ‪handleRequestCallsExpectedMethods()
81  {
82  $handler = new ‪WidgetRequestHandler();
83  $request = $this->createMock(Request::class);
84  $requestBuilder = $this->getMockBuilder(WidgetRequestBuilder::class)
85  ->setMethods(['build'])
86  ->getMock();
87  $requestBuilder->expects(self::once())->method('build')->willReturn($request);
88  $objectManager = $this->prophesize(ObjectManager::class);
89  $handler->injectObjectManager($objectManager->reveal());
90  $objectManager->get(Argument::any())->willReturn($this->createMock(Response::class));
91  $requestDispatcher = $this->getMockBuilder(Dispatcher::class)
92  ->setMethods(['dispatch'])
93  ->disableOriginalConstructor()
94  ->getMock();
95  $requestDispatcher->expects(self::once())->method('dispatch')->with($request);
96  $handler->injectWidgetRequestBuilder($requestBuilder);
97  $handler->injectDispatcher($requestDispatcher);
98  $handler->handleRequest();
99  }
100 }
‪TYPO3\CMS\Fluid\Tests\Unit\Core\Widget\WidgetRequestHandlerTest
Definition: WidgetRequestHandlerTest.php:32
‪TYPO3\CMS\Fluid\Tests\Unit\Core\Widget\WidgetRequestHandlerTest\canHandleRequestReturnsFalseIfGetParameterIsNotSet
‪canHandleRequestReturnsFalseIfGetParameterIsNotSet()
Definition: WidgetRequestHandlerTest.php:58
‪TYPO3\CMS\Extbase\Mvc\Dispatcher
Definition: Dispatcher.php:35
‪TYPO3\CMS\Fluid\Core\Widget\WidgetRequestBuilder
Definition: WidgetRequestBuilder.php:28
‪TYPO3\CMS\Fluid\Tests\Unit\Core\Widget\WidgetRequestHandlerTest\handleRequestCallsExpectedMethods
‪handleRequestCallsExpectedMethods()
Definition: WidgetRequestHandlerTest.php:79
‪TYPO3\CMS\Fluid\Core\Widget\WidgetRequestHandler
Definition: WidgetRequestHandler.php:32
‪TYPO3\CMS\Fluid\Tests\Unit\Core\Widget\WidgetRequestHandlerTest\canHandleRequestReturnsTrueIfCorrectGetParameterIsSet
‪canHandleRequestReturnsTrueIfCorrectGetParameterIsSet()
Definition: WidgetRequestHandlerTest.php:49
‪TYPO3\CMS\Fluid\Tests\Unit\Core\Widget\WidgetRequestHandlerTest\$widgetRequestHandler
‪TYPO3 CMS Fluid Core Widget WidgetRequestHandler $widgetRequestHandler
Definition: WidgetRequestHandlerTest.php:35
‪TYPO3\CMS\Extbase\Mvc\Web\Response
Definition: Response.php:26
‪TYPO3\CMS\Extbase\Mvc\Web\AbstractRequestHandler
Definition: AbstractRequestHandler.php:28
‪TYPO3\CMS\Extbase\Mvc\Web\Request
Definition: Request.php:23
‪TYPO3\CMS\Fluid\Tests\Unit\Core\Widget\WidgetRequestHandlerTest\setUp
‪setUp()
Definition: WidgetRequestHandlerTest.php:40
‪TYPO3\CMS\Fluid\Tests\Unit\Core\Widget
Definition: AbstractWidgetControllerTest.php:16
‪TYPO3\CMS\Fluid\Tests\Unit\Core\Widget\WidgetRequestHandlerTest\priorityIsHigherThanDefaultRequestHandler
‪priorityIsHigherThanDefaultRequestHandler()
Definition: WidgetRequestHandlerTest.php:67
‪TYPO3\CMS\Extbase\Object\ObjectManager
Definition: ObjectManager.php:28