/** * @test */ public function setDispatchedEmitsSignalIfDispatched() { $mockDispatcher = $this->getMock(\TYPO3\Flow\SignalSlot\Dispatcher::class); $mockDispatcher->expects($this->once())->method('dispatch')->with(\TYPO3\Flow\Mvc\ActionRequest::class, 'requestDispatched', array($this->actionRequest)); $mockObjectManager = $this->getMock(\TYPO3\Flow\Object\ObjectManagerInterface::class); $mockObjectManager->expects($this->any())->method('get')->will($this->returnValue($mockDispatcher)); $this->inject($this->actionRequest, 'objectManager', $mockObjectManager); $this->actionRequest->setDispatched(true); }
/** * @test */ public function setDispatchedEmitsSignalIfDispatched() { $mockDispatcher = $this->getMock('TYPO3\\Flow\\SignalSlot\\Dispatcher'); $mockDispatcher->expects($this->once())->method('dispatch')->with('TYPO3\\Flow\\Mvc\\ActionRequest', 'requestDispatched', array($this->actionRequest)); $mockObjectManager = $this->getMock('TYPO3\\Flow\\Object\\ObjectManagerInterface'); $mockObjectManager->expects($this->any())->method('get')->will($this->returnValue($mockDispatcher)); $this->inject($this->actionRequest, 'objectManager', $mockObjectManager); $this->actionRequest->setDispatched(TRUE); }
/** * Initializes the controller * * This method should be called by the concrete processRequest() method. * * @param \TYPO3\Flow\Mvc\RequestInterface $request * @param \TYPO3\Flow\Mvc\ResponseInterface $response * @throws \TYPO3\Flow\Mvc\Exception\UnsupportedRequestTypeException */ protected function initializeController(\TYPO3\Flow\Mvc\RequestInterface $request, \TYPO3\Flow\Mvc\ResponseInterface $response) { if (!$request instanceof ActionRequest) { throw new \TYPO3\Flow\Mvc\Exception\UnsupportedRequestTypeException(get_class($this) . ' only supports action requests – requests of type "' . get_class($request) . '" given.', 1187701131); } $this->request = $request; $this->request->setDispatched(true); $this->response = $response; $this->uriBuilder = new UriBuilder(); $this->uriBuilder->setRequest($this->request); $this->arguments = new Arguments(array()); $this->controllerContext = new ControllerContext($this->request, $this->response, $this->arguments, $this->uriBuilder); $mediaType = $request->getHttpRequest()->getNegotiatedMediaType($this->supportedMediaTypes); if ($mediaType === null) { $this->throwStatus(406); } if ($request->getFormat() === null) { $this->request->setFormat(MediaTypes::getFilenameExtensionFromMediaType($mediaType)); } }
/** * The Resource Information most likely needs an UriBuilder, so having a * ControllerContext in place might come in handy. * * @return void */ protected function initializeControllerContext() { $request = new ActionRequest(Request::createFromEnvironment()); $request->setDispatched(true); $response = new Response(); $uriBuilder = new UriBuilder(); $uriBuilder->setRequest($request); $arguments = new Arguments(array()); $this->controllerContext = new ControllerContext($request, $response, $arguments, $uriBuilder); }
/** * @test */ public function cloneResetsTheStatusToNotDispatched() { $httpRequest = HttpRequest::create(new Uri('http://foo.com')); $originalRequest = new ActionRequest($httpRequest); $originalRequest->setDispatched(TRUE); $cloneRequest = clone $originalRequest; $this->assertTrue($originalRequest->isDispatched()); $this->assertFalse($cloneRequest->isDispatched()); }