From d15946df2dfb0ae2f0ca9371e5c8071df91ab45a Mon Sep 17 00:00:00 2001 From: Igor Scheller Date: Mon, 8 Oct 2018 19:30:37 +0200 Subject: Changed `src/` code and templates to use the new user model --- tests/Unit/Exceptions/Handlers/WhoopsTest.php | 32 +++++++++++++++++++++------ 1 file changed, 25 insertions(+), 7 deletions(-) (limited to 'tests/Unit/Exceptions/Handlers/WhoopsTest.php') diff --git a/tests/Unit/Exceptions/Handlers/WhoopsTest.php b/tests/Unit/Exceptions/Handlers/WhoopsTest.php index 4062979b..4949c45a 100644 --- a/tests/Unit/Exceptions/Handlers/WhoopsTest.php +++ b/tests/Unit/Exceptions/Handlers/WhoopsTest.php @@ -5,6 +5,7 @@ namespace Engelsystem\Test\Unit\Exceptions\handlers; use Engelsystem\Application; use Engelsystem\Exceptions\Handlers\Whoops; +use Engelsystem\Helpers\Authenticator; use Engelsystem\Http\Request; use Exception; use PHPUnit\Framework\TestCase; @@ -23,15 +24,23 @@ class WhoopsTest extends TestCase { /** @var Application|Mock $app */ $app = $this->createMock(Application::class); + /** @var Authenticator|Mock $auth */ + $auth = $this->createMock(Authenticator::class); /** @var Request|Mock $request */ $request = $this->createMock(Request::class); - $request->expects($this->once()) - ->method('isXmlHttpRequest') - ->willReturn(true); /** @var WhoopsRunnerInterface|Mock $whoopsRunner */ $whoopsRunner = $this->getMockForAbstractClass(WhoopsRunnerInterface::class); /** @var PrettyPageHandler|Mock $prettyPageHandler */ $prettyPageHandler = $this->createMock(PrettyPageHandler::class); + /** @var JsonResponseHandler|Mock $jsonResponseHandler */ + $jsonResponseHandler = $this->createMock(JsonResponseHandler::class); + /** @var Exception|Mock $exception */ + $exception = $this->createMock(Exception::class); + + $request->expects($this->once()) + ->method('isXmlHttpRequest') + ->willReturn(true); + $prettyPageHandler ->expects($this->atLeastOnce()) ->method('setApplicationPaths'); @@ -41,16 +50,13 @@ class WhoopsTest extends TestCase $prettyPageHandler ->expects($this->once()) ->method('addDataTable'); - /** @var JsonResponseHandler|Mock $jsonResponseHandler */ - $jsonResponseHandler = $this->createMock(JsonResponseHandler::class); + $jsonResponseHandler->expects($this->once()) ->method('setJsonApi') ->with(true); $jsonResponseHandler->expects($this->once()) ->method('addTraceToOutput') ->with(true); - /** @var Exception|Mock $exception */ - $exception = $this->createMock(Exception::class); $app->expects($this->exactly(3)) ->method('make') @@ -64,6 +70,18 @@ class WhoopsTest extends TestCase $prettyPageHandler, $jsonResponseHandler ); + $app->expects($this->once()) + ->method('has') + ->with('authenticator') + ->willReturn(true); + $app->expects($this->once()) + ->method('get') + ->with('authenticator') + ->willReturn($auth); + + $auth->expects($this->once()) + ->method('user') + ->willReturn(null); $whoopsRunner ->expects($this->exactly(2)) -- cgit v1.2.3-54-g00ecf