From 92c26718fd0799660515d64feabbbc1cd1d71a35 Mon Sep 17 00:00:00 2001 From: Igor Scheller Date: Tue, 7 Aug 2018 03:06:21 +0200 Subject: exceptions: implemented error rendering return --- tests/Unit/Exceptions/HandlerTest.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'tests/Unit/Exceptions/HandlerTest.php') 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); } /** -- cgit v1.2.3-54-g00ecf