/** * Resets the managed objects */ public function reassignRequest() { $request = $this->dispatcher->getRequest(); if ($this->authenticationProvider) { $this->authenticationProvider->setRequest($request); } if ($this->accessController) { $this->accessController->setRequest($request); } }
/** * @test */ public function createSuccessResponseTest() { $_GET['u'] = 'MyExt-MyModel/1.json'; $response = $this->fixture->createSuccessResponse('Everything ok', 200); $this->assertEquals(200, $response->status()); $this->assertEquals('{"message":"Everything ok"}', $response->content()); $this->fixture->getRequest()->format('html'); $response = $this->fixture->createSuccessResponse('HTML format is currently not supported', 200); $this->assertEquals(200, $response->status()); $this->assertEquals('Unsupported format: html', $response->content()); $this->fixture->getRequest()->format('blur'); $response = $this->fixture->createSuccessResponse('This will default to JSON', 200); $this->assertEquals(200, $response->status()); $this->assertEquals('{"message":"This will default to JSON"}', $response->content()); $response = $this->fixture->createSuccessResponse(NULL, 200); $this->assertEquals(200, $response->status()); $this->assertEquals('{"message":"OK"}', $response->content()); // This will be an error $response = $this->fixture->createSuccessResponse(NULL, 404); $this->assertEquals(404, $response->status()); $this->assertEquals('{"error":"Not Found"}', $response->content()); }