[BUGFIX] Remove competing injects from WidgetRequestHandler 25/47325/2
authorAlexander Jahn <jahn.typo3@googlemail.com>
Wed, 9 Mar 2016 11:12:38 +0000 (12:12 +0100)
committerJan Helke <typo3@helke.de>
Fri, 18 Mar 2016 17:20:56 +0000 (18:20 +0100)
Removing @injects introduced explicit injectFunctions
into WidgetRequestHandler.
These functions were named after the object they inject.
This resulted in two methods injecting different objects into the same
property and in the end the parent class' function reverted the local
implementation.

Change-Id: I345d04f150fe6413ffc67c159c43cdda7e979e7b
Resolves: #74536
Related: #73018
Releases: master, 7.6
Reviewed-on: https://review.typo3.org/47325
Reviewed-by: Jan Helke <typo3@helke.de>
Tested-by: Jan Helke <typo3@helke.de>
typo3/sysext/fluid/Classes/Core/Widget/WidgetRequestHandler.php
typo3/sysext/fluid/Tests/Unit/Core/Widget/WidgetRequestHandlerTest.php

index 5c47322..21f3dca 100644 (file)
@@ -62,6 +62,14 @@ class WidgetRequestHandler extends \TYPO3\CMS\Extbase\Mvc\Web\AbstractRequestHan
     /**
      * @param \TYPO3\CMS\Extbase\Mvc\Web\RequestBuilder $requestBuilder
      */
+    public function injectRequestBuilder(\TYPO3\CMS\Extbase\Mvc\Web\RequestBuilder $requestBuilder)
+    {
+        // This method intentionally left blank
+    }
+
+    /**
+     * @param \TYPO3\CMS\Fluid\Core\Widget\WidgetRequestBuilder $requestBuilder
+     */
     public function injectWidgetRequestBuilder(\TYPO3\CMS\Fluid\Core\Widget\WidgetRequestBuilder $requestBuilder)
     {
         $this->requestBuilder = $requestBuilder;
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();
+    }
 }