[BUGFIX] Remove competing injects from WidgetRequestHandler
[Packages/TYPO3.CMS.git] / typo3 / sysext / fluid / Tests / Unit / Core / Widget / WidgetRequestHandlerTest.php
index e86c0a3..3181460 100644 (file)
@@ -20,6 +20,12 @@ namespace TYPO3\CMS\Fluid\Tests\Unit\Core\Widget;
  *                                                                        *
  * The TYPO3 project - inspiring people to share!                         *
  *                                                                        */
+use TYPO3\CMS\Extbase\Mvc\Dispatcher;
+use TYPO3\CMS\Extbase\Mvc\Web\Request;
+use TYPO3\CMS\Extbase\Mvc\Web\Response;
+use TYPO3\CMS\Extbase\Object\ObjectManagerInterface;
+use TYPO3\CMS\Fluid\Core\Widget\WidgetRequestBuilder;
+use TYPO3\CMS\Fluid\Core\Widget\WidgetRequestHandler;
 
 /**
  * Test case
@@ -65,4 +71,23 @@ class WidgetRequestHandlerTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
         $defaultWebRequestHandler = $this->getMock(\TYPO3\CMS\Extbase\Mvc\Web\AbstractRequestHandler::class, array('handleRequest'), array(), '', false);
         $this->assertTrue($this->widgetRequestHandler->getPriority() > $defaultWebRequestHandler->getPriority());
     }
+
+    /**
+     * @test
+     */
+    public function handleRequestCallsExpectedMethods()
+    {
+        $handler = new WidgetRequestHandler();
+        $request = $this->getMock(Request::class);
+        $requestBuilder = $this->getMock(WidgetRequestBuilder::class, array('build'));
+        $requestBuilder->expects($this->once())->method('build')->willReturn($request);
+        $objectManager = $this->getMock(ObjectManagerInterface::class);
+        $objectManager->expects($this->once())->method('get')->willReturn($this->getMock(Response::class));
+        $requestDispatcher = $this->getMock(Dispatcher::class, array('dispatch'), array(), '', false);
+        $requestDispatcher->expects($this->once())->method('dispatch')->with($request);
+        $this->inject($handler, 'widgetRequestBuilder', $requestBuilder);
+        $this->inject($handler, 'dispatcher', $requestDispatcher);
+        $this->inject($handler, 'objectManager', $objectManager);
+        $handler->handleRequest();
+    }
 }