womtfix/negative-werte #12

Merged
TorstenHettstedt merged 4 commits from womtfix/negative-werte into master 2021-04-15 12:25:33 +02:00
Showing only changes of commit 0bd8932fa1 - Show all commits
+20 -1
View File
@@ -12,6 +12,9 @@ use Psr\Http\Message\StreamInterface;
use Psr\Log\LoggerInterface;
use Slim\App;
use Slim\Exception\HttpException;
use Slim\Interfaces\RouteParserInterface;
use Slim\Routing\RouteContext;
use Slim\Routing\RoutingResults;
use TorstenHettstedt\TimekeepingApi\Middleware\ErrorHandler;
class ErrorHandlerTest extends Unit
@@ -28,6 +31,7 @@ class ErrorHandlerTest extends Unit
protected function _before(): void
{
parent::_before();
/** @noinspection PhpFieldAssignmentTypeMismatchInspection */
$this->app = $this->makeEmpty(App::class, [
'getResponseFactory' => $this->makeEmpty(ResponseFactoryInterface::class, [
'createResponse' => $this->makeEmpty(ResponseInterface::class, [
@@ -40,7 +44,16 @@ class ErrorHandlerTest extends Unit
]),
]),
]);
$this->request = $this->makeEmpty(ServerRequestInterface::class);
/** @noinspection PhpFieldAssignmentTypeMismatchInspection */
$this->request = $this->makeEmpty(ServerRequestInterface::class, [
'getAttribute' => function($name) {
return match ($name) {
RouteContext::ROUTE_PARSER => $this->makeEmpty(RouteParserInterface::class),
RouteContext::ROUTING_RESULTS => $this->makeEmpty(RoutingResults::class),
default => null,
};
}
]);
}
/**
@@ -48,11 +61,13 @@ class ErrorHandlerTest extends Unit
*/
public function testUseWithLogger(): void
{
/** @noinspection PhpFieldAssignmentTypeMismatchInspection */
$this->exception = $this->make(Exception::class, [
'message' => '',
'code' => 400,
'file' => '/path(to/file',
]);
/** @noinspection PhpFieldAssignmentTypeMismatchInspection */
$this->logger = $this->makeEmpty(LoggerInterface::class, [
'error' => Expected::once(),
]);
@@ -66,12 +81,14 @@ class ErrorHandlerTest extends Unit
*/
public function testUseWithHttpException(): void
{
/** @noinspection PhpFieldAssignmentTypeMismatchInspection */
$this->exception = $this->make(HttpException::class, [
'message' => '',
'code' => 400,
'file' => '/path(to/file',
'getTitle' => Expected::once('The Title'),
]);
/** @noinspection PhpFieldAssignmentTypeMismatchInspection */
$this->logger = $this->makeEmpty(LoggerInterface::class, []);
$middleWare = new ErrorHandler($this->app);
@@ -84,11 +101,13 @@ class ErrorHandlerTest extends Unit
*/
public function testUseWithGeneralException(): void
{
/** @noinspection PhpFieldAssignmentTypeMismatchInspection */
$this->exception = $this->make(Exception::class, [
'message' => '',
'code' => 400,
'file' => '/path(to/file',
]);
/** @noinspection PhpFieldAssignmentTypeMismatchInspection */
$this->logger = $this->makeEmpty(LoggerInterface::class, []);
$middleWare = new ErrorHandler($this->app);