Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion tests/Handlers/ErrorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,25 @@ public function errorProvider()
public function testError($acceptHeader, $contentType, $startOfBody)
{
$error = new Error();
$e = new \Exception("Oops");
$e = new \Exception("Oops", 1, new \Exception('Previous oops'));

/** @var Response $res */
$res = $error->__invoke($this->getRequest('GET', $acceptHeader), new Response(), $e);

$this->assertSame(500, $res->getStatusCode());
$this->assertSame($contentType, $res->getHeaderLine('Content-Type'));
$this->assertEquals(0, strpos((string)$res->getBody(), $startOfBody));
}

/**
* Test invalid method returns the correct code and content type with details
*
* @dataProvider errorProvider
*/
public function testErrorDisplayDetails($acceptHeader, $contentType, $startOfBody)
{
$error = new Error(true);
$e = new \Exception('Oops', 1, new \Exception('Opps before'));

/** @var Response $res */
$res = $error->__invoke($this->getRequest('GET', $acceptHeader), new Response(), $e);
Expand Down