Inject the request engine
public setRequestEngine ( Neos\Flow\Http\Client\RequestEngineInterface $requestEngine ) : void | ||
$requestEngine | Neos\Flow\Http\Client\RequestEngineInterface | |
Résultat | void |
/** * Sets up a virtual browser and web environment for seamless HTTP and MVC * related tests. * * @return void */ protected function setupHttp() { $this->browser = new \Neos\Flow\Http\Client\Browser(); $this->browser->setRequestEngine(new \Neos\Flow\Http\Client\InternalRequestEngine()); $this->router = $this->browser->getRequestEngine()->getRouter(); $this->router->setRoutesConfiguration(null); $requestHandler = self::$bootstrap->getActiveRequestHandler(); $request = Request::create(new \Neos\Flow\Http\Uri('http://localhost/typo3/flow/test')); $componentContext = new ComponentContext($request, new \Neos\Flow\Http\Response()); $requestHandler->setComponentContext($componentContext); }
/** * @test * @expectedException \Neos\Flow\Http\Client\InfiniteRedirectionException */ public function browserHaltsOnExceedingMaximumRedirections() { $requestEngine = $this->createMock(Client\RequestEngineInterface::class); for ($i = 0; $i <= 10; $i++) { $response = new Http\Response(); $response->setHeader('Location', 'http://localhost/this/willLead/you/knowhere/' . $i); $response->setStatus(301); $requestEngine->expects($this->at($i))->method('sendRequest')->will($this->returnValue($response)); } $this->browser->setRequestEngine($requestEngine); $this->browser->request('http://localhost/some/initialRequest'); }