Skip to content

Commit b588404

Browse files
author
Witold Wasiczko
committed
Fix response message to log
1 parent 2788893 commit b588404

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/LogMiddleware.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function __invoke(ServerRequest $request, Response $response, callable $n
4747
{
4848
$outResponse = $next($request, $response);
4949

50-
$messages = $this->formatter->format($request, $response);
50+
$messages = $this->formatter->format($request, $outResponse);
5151

5252
if (!is_string($messages)) {
5353
throw new \UnexpectedValueException(sprintf('%s must return string', HttpMessagesFormatter::class));

test/LogMiddlewareTest.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ protected function setUp()
2424
{
2525
$this->request = $this->getMock(ServerRequestInterface::class);
2626
$this->response = $this->getMock(ResponseInterface::class);
27+
$this->nextResponse = clone $this->response;
2728
$this->next = function () {
28-
return $this->response;
29+
return $this->nextResponse;
2930
};
3031

3132
$this->formatter = $this->getMock(HttpMessagesFormatter::class);
@@ -37,12 +38,12 @@ protected function setUp()
3738

3839
public function testLogMessage()
3940
{
40-
$this->formatter->expects($this->once())->method('format')->with($this->request, $this->response)->willReturn('boo');
41+
$this->formatter->expects($this->once())->method('format')->with($this->request, $this->nextResponse)->willReturn('boo');
4142
$this->logger->expects($this->once())->method('log')->with($this->level, 'boo');
4243

4344
$response = $this->executeMiddleware();
4445

45-
$this->assertSame($this->response, $response);
46+
$this->assertSame($this->nextResponse, $response);
4647
}
4748

4849
/**

0 commit comments

Comments
 (0)