diff options
author | Igor Scheller <igor.scheller@igorshp.de> | 2018-08-07 03:06:21 +0200 |
---|---|---|
committer | Igor Scheller <igor.scheller@igorshp.de> | 2018-08-14 00:17:19 +0200 |
commit | 92c26718fd0799660515d64feabbbc1cd1d71a35 (patch) | |
tree | 6574a53688e1981aa524ef32ee203f2c6836d968 /tests/Unit | |
parent | 864a086900b92233d7cf76747828163346eabc77 (diff) |
exceptions: implemented error rendering return
Diffstat (limited to 'tests/Unit')
-rw-r--r-- | tests/Unit/Exceptions/HandlerTest.php | 14 | ||||
-rw-r--r-- | tests/Unit/Exceptions/Handlers/WhoopsTest.php | 8 |
2 files changed, 19 insertions, 3 deletions
diff --git a/tests/Unit/Exceptions/HandlerTest.php b/tests/Unit/Exceptions/HandlerTest.php index 40202be8..7987f9d6 100644 --- a/tests/Unit/Exceptions/HandlerTest.php +++ b/tests/Unit/Exceptions/HandlerTest.php @@ -49,15 +49,19 @@ class HandlerTest extends TestCase public function testExceptionHandler() { $exception = new Exception(); + $errorMessage = 'Oh noes, an error!'; /** @var HandlerInterface|Mock $handlerMock */ $handlerMock = $this->getMockForAbstractClass(HandlerInterface::class); - $handlerMock->expects($this->once()) + $handlerMock->expects($this->atLeastOnce()) ->method('report') ->with($exception); - $handlerMock->expects($this->once()) + $handlerMock->expects($this->atLeastOnce()) ->method('render') - ->with($this->isInstanceOf(Request::class), $exception); + ->with($this->isInstanceOf(Request::class), $exception) + ->willReturnCallback(function () use ($errorMessage) { + echo $errorMessage; + }); /** @var Handler|Mock $handler */ $handler = $this->getMockBuilder(Handler::class) @@ -68,7 +72,11 @@ class HandlerTest extends TestCase $handler->setHandler(Handler::ENV_PRODUCTION, $handlerMock); + $this->expectOutputString($errorMessage); $handler->exceptionHandler($exception); + + $return = $handler->exceptionHandler($exception, true); + $this->assertEquals($errorMessage, $return); } /** diff --git a/tests/Unit/Exceptions/Handlers/WhoopsTest.php b/tests/Unit/Exceptions/Handlers/WhoopsTest.php index 261ee83f..4062979b 100644 --- a/tests/Unit/Exceptions/Handlers/WhoopsTest.php +++ b/tests/Unit/Exceptions/Handlers/WhoopsTest.php @@ -74,6 +74,14 @@ class WhoopsTest extends TestCase ); $whoopsRunner ->expects($this->once()) + ->method('writeToOutput') + ->with(false); + $whoopsRunner + ->expects($this->once()) + ->method('allowQuit') + ->with(false); + $whoopsRunner + ->expects($this->once()) ->method('handleException') ->with($exception); |