Skip to content

Commit

Permalink
Revert "Remove test that wasn't reverted properly."
Browse files Browse the repository at this point in the history
This reverts commit 288a307.
  • Loading branch information
markstory committed Apr 26, 2018
1 parent 1482be1 commit e4dee68
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/TestCase/Error/Middleware/ErrorHandlerMiddlewareTest.php
Expand Up @@ -147,6 +147,29 @@ public function testHandleException()
$this->assertContains('was not found', '' . $result->getBody());
}

/**
* Test rendering an error page holds onto the original request.
*
* @return void
*/
public function testHandleExceptionPreserveRequest()
{
$request = ServerRequestFactory::fromGlobals();
$request = $request->withHeader('Accept', 'application/json');

$response = new Response();
$middleware = new ErrorHandlerMiddleware();
$next = function ($req, $res) {
throw new \Cake\Http\Exception\NotFoundException('whoops');
};
$result = $middleware($request, $response, $next);
$this->assertInstanceOf('Cake\Http\Response', $result);
$this->assertNotSame($result, $response);
$this->assertEquals(404, $result->getStatusCode());
$this->assertContains('"message": "whoops"', '' . $result->getBody());
$this->assertEquals('application/json; charset=UTF-8', $result->getHeaderLine('Content-type'));
}

/**
* Test handling PHP 7's Error instance.
*
Expand Down

0 comments on commit e4dee68

Please sign in to comment.