WhoopsTest: Fixed non unique setApplicationPaths mocks

This commit is contained in:
Igor Scheller 2020-06-05 10:48:48 +02:00
parent 4a6f18d41f
commit 2e1fbfb16d
1 changed files with 9 additions and 31 deletions

View File

@ -6,9 +6,9 @@ use Engelsystem\Application;
use Engelsystem\Exceptions\Handlers\Whoops;
use Engelsystem\Helpers\Authenticator;
use Engelsystem\Http\Request;
use Engelsystem\Test\Unit\TestCase;
use Exception;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Whoops\Handler\JsonResponseHandler;
use Whoops\Handler\PrettyPageHandler;
use Whoops\Run as WhoopsRunner;
@ -40,26 +40,13 @@ class WhoopsTest extends TestCase
/** @var Exception|MockObject $exception */
$exception = $this->createMock(Exception::class);
$request->expects($this->once())
->method('isXmlHttpRequest')
->willReturn(true);
$this->setExpects($request, 'isXmlHttpRequest', null, true);
$prettyPageHandler
->expects($this->atLeastOnce())
->method('setApplicationPaths');
$prettyPageHandler
->expects($this->once())
->method('setApplicationPaths');
$prettyPageHandler
->expects($this->once())
->method('addDataTable');
$this->setExpects($prettyPageHandler, 'setApplicationPaths');
$this->setExpects($prettyPageHandler, 'addDataTable');
$jsonResponseHandler->expects($this->once())
->method('setJsonApi')
->with(true);
$jsonResponseHandler->expects($this->once())
->method('addTraceToOutput')
->with(true);
$this->setExpects($jsonResponseHandler, 'setJsonApi', [true]);
$this->setExpects($jsonResponseHandler, 'addTraceToOutput', [true]);
$app->expects($this->exactly(3))
->method('make')
@ -93,18 +80,9 @@ class WhoopsTest extends TestCase
[$prettyPageHandler],
[$jsonResponseHandler]
);
$whoopsRunner
->expects($this->once())
->method('writeToOutput')
->with(false);
$whoopsRunner
->expects($this->once())
->method('allowQuit')
->with(false);
$whoopsRunner
->expects($this->once())
->method('handleException')
->with($exception);
$this->setExpects($whoopsRunner, 'writeToOutput', [false]);
$this->setExpects($whoopsRunner, 'allowQuit', [false]);
$this->setExpects($whoopsRunner, 'handleException', [$exception]);
$handler = new Whoops($app);
$handler->render($request, $exception);