summaryrefslogtreecommitdiff
path: root/tests/Unit/Middleware
diff options
context:
space:
mode:
authorIgor Scheller <igor.scheller@igorshp.de>2018-12-18 02:16:25 +0100
committermsquare <msquare@notrademark.de>2018-12-19 22:36:42 +0100
commit3c8d0eeb440b8c263686ba81df7be87290ad9695 (patch)
tree5c7c944be88d8b9808ae53a8db31a1ec10c56346 /tests/Unit/Middleware
parent2570418e9ff95ebffdaabb4945ec611104891849 (diff)
ErrorHandler: Don't wrap the response if a content-type is defined
Diffstat (limited to 'tests/Unit/Middleware')
-rw-r--r--tests/Unit/Middleware/ErrorHandlerTest.php20
1 files changed, 19 insertions, 1 deletions
diff --git a/tests/Unit/Middleware/ErrorHandlerTest.php b/tests/Unit/Middleware/ErrorHandlerTest.php
index c0834591..cce752d1 100644
--- a/tests/Unit/Middleware/ErrorHandlerTest.php
+++ b/tests/Unit/Middleware/ErrorHandlerTest.php
@@ -32,6 +32,10 @@ class ErrorHandlerTest extends TestCase
$psrResponse->expects($this->once())
->method('getStatusCode')
->willReturn(505);
+ $psrResponse->expects($this->once())
+ ->method('getHeader')
+ ->with('content-type')
+ ->willReturn([]);
$errorHandler = new ErrorHandler($twigLoader);
@@ -41,13 +45,22 @@ class ErrorHandlerTest extends TestCase
/** @var Response|MockObject $response */
$response = $this->createMock(Response::class);
- $response->expects($this->exactly(3))
+ $response->expects($this->exactly(4))
->method('getStatusCode')
->willReturnOnConsecutiveCalls(
200,
418,
+ 505,
505
);
+ $response->expects($this->exactly(4))
+ ->method('getHeader')
+ ->willReturnOnConsecutiveCalls(
+ [],
+ [],
+ [],
+ ['application/json']
+ );
$returnResponseHandler->setResponse($response);
$return = $errorHandler->process($request, $returnResponseHandler);
@@ -85,6 +98,7 @@ class ErrorHandlerTest extends TestCase
$errorHandler->process($request, $returnResponseHandler);
$errorHandler->process($request, $returnResponseHandler);
+ $errorHandler->process($request, $returnResponseHandler);
}
/**
@@ -104,6 +118,10 @@ class ErrorHandlerTest extends TestCase
$psrResponse->expects($this->once())
->method('getStatusCode')
->willReturn(300);
+ $psrResponse->expects($this->once())
+ ->method('getHeader')
+ ->with('content-type')
+ ->willReturn([]);
$returnResponseHandler->expects($this->once())
->method('handle')