public function testCreateFromApiProblemException() { $apiProblem = ApiProblem::createFromScalar(404, 'Entity not found'); $exception = new ApiProblemException($apiProblem); $apiProblem = ApiProblem::createFromException($exception); $this->assertApiProblem($apiProblem, ['title' => 'Not Found', 'status' => 404, 'detail' => 'Entity not found', 'type' => 'http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html']); }
public function testCreate() { $apiProblem = ApiProblem::createFromScalar(400, 'You are wrong'); $response = $this->factory->createResponse($apiProblem); $this->assertInstanceOf(ResponseInterface::class, $response); $this->assertSame('application/problem+json', $response->getHeaderLine('Content-type')); $this->assertSame(400, $response->getStatusCode()); $json = '{"title":"Bad Request","status":400,"detail":"You are wrong","type":"http:\\/\\/www.w3.org\\/Protocols\\/rfc2616\\/rfc2616-sec10.html"}'; $this->assertSame($json, (string) $response->getBody()); }
protected function setUp() { $apiProblem = ApiProblem::createFromScalar(404, 'Boo'); $prevException = new \LogicException('Not found entity'); $this->exception = new ApiProblemException($apiProblem, $prevException); }