Skip to content

Commit

Permalink
Merge 638bc7b into 954472c
Browse files Browse the repository at this point in the history
  • Loading branch information
epitomus committed May 16, 2016
2 parents 954472c + 638bc7b commit 94d3f5f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Slim/Handlers/AbstractError.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ protected function writeToErrorLog($throwable)

$message = 'Slim Application Error:' . PHP_EOL;
$message .= $this->renderThrowableAsText($throwable);
while ($error = $throwable->getPrevious()) {
while ($throwable = $throwable->getPrevious()) {
$message .= PHP_EOL . 'Previous error:' . PHP_EOL;
$message .= $this->renderThrowableAsText($throwable);
}
Expand Down
19 changes: 19 additions & 0 deletions tests/Handlers/ErrorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,25 @@ public function testError($acceptHeader, $contentType, $startOfBody)
$this->assertEquals(0, strpos((string)$res->getBody(), $startOfBody));
}

/**
* Test the exception rendering runs to completion (no infinite loop)
*
* @dataProvider errorProvider
*/
public function testErrorExceptionWithPrevious($acceptHeader, $contentType, $startOfBody)
{
$error = new Error();
$e = new \Exception("Oops", 1, new \Exception());

/** @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));
// if we have reached this point, there is no infinite loop, otherwise an out of memory error will occur
}

/**
* @param string $method
* @return \PHPUnit_Framework_MockObject_MockObject|\Slim\Http\Request
Expand Down

0 comments on commit 94d3f5f

Please sign in to comment.