/** * @test */ public function dispatchContinuesWithNextRequestFoundInAForwardException() { $httpRequest = Request::create(new Uri('http://localhost')); $httpResponse = new Response(); $mainRequest = $httpRequest->createActionRequest(); $subRequest = new ActionRequest($mainRequest); $nextRequest = $httpRequest->createActionRequest(); $mainRequest->setDispatched(TRUE); $mainRequest->setControllerSubPackageKey('main'); $subRequest->setControllerSubPackageKey('sub'); $nextRequest->setControllerSubPackageKey('next'); $mockController = $this->getMock('TYPO3\\FLOW3\\Mvc\\Controller\\ControllerInterface', array('processRequest')); $mockController->expects($this->at(0))->method('processRequest')->will($this->returnCallback(function (ActionRequest $request) use($nextRequest) { $request->setDispatched(TRUE); $forwardException = new ForwardException(); $forwardException->setNextRequest($nextRequest); throw $forwardException; })); $mockController->expects($this->at(1))->method('processRequest')->will($this->returnCallback(function (ActionRequest $request) use($nextRequest) { // NOTE: PhpUnit creates a clone of $nextRequest, thus $request is not the same instance as expected. if ($request == $nextRequest) { $nextRequest->setDispatched(TRUE); } })); $dispatcher = $this->getMock('TYPO3\\FLOW3\\Mvc\\Dispatcher', array('resolveController', 'emitAfterControllerInvocation'), array(), '', FALSE); $dispatcher->expects($this->any())->method('resolveController')->will($this->returnValue($mockController)); $dispatcher->dispatch($subRequest, $httpResponse); }