Skip to content

Commit 9139009

Browse files
committed
updated the tests
1 parent 51deefa commit 9139009

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

spec/LoggerPluginSpec.php

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,14 @@ function it_logs_request_and_response(
3434
LoggerInterface $logger,
3535
Formatter $formatter,
3636
RequestInterface $request,
37-
ResponseInterface $response
37+
ResponseInterface $response,
38+
$milliseconds
3839
) {
3940
$formatter->formatRequest($request)->willReturn('GET / 1.1');
4041
$formatter->formatResponse($response)->willReturn('200 OK 1.1');
4142

4243
$logger->info("Sending request:\nGET / 1.1", ['request' => $request])->shouldBeCalled();
43-
$logger->info("Received response:\n200 OK 1.1\n\nfor request:\nGET / 1.1", ['request' => $request, 'response' => $response])->shouldBeCalled();
44+
$logger->info("Received response:\n200 OK 1.1\n\nfor request:\nGET / 1.1", ['request' => $request, 'response' => $response, 'milliseconds' => $milliseconds])->shouldBeCalled();
4445

4546
$next = function () use ($response) {
4647
return new FulfilledPromise($response->getWrappedObject());
@@ -49,14 +50,14 @@ function it_logs_request_and_response(
4950
$this->handleRequest($request, $next, function () {});
5051
}
5152

52-
function it_logs_exception(LoggerInterface $logger, Formatter $formatter, RequestInterface $request)
53+
function it_logs_exception(LoggerInterface $logger, Formatter $formatter, RequestInterface $request, $milliseconds)
5354
{
5455
$formatter->formatRequest($request)->willReturn('GET / 1.1');
5556

5657
$exception = new NetworkException('Cannot connect', $request->getWrappedObject());
5758

5859
$logger->info("Sending request:\nGET / 1.1", ['request' => $request])->shouldBeCalled();
59-
$logger->error("Error:\nCannot connect\nwhen sending request:\nGET / 1.1", ['request' => $request, 'exception' => $exception])->shouldBeCalled();
60+
$logger->error("Error:\nCannot connect\nwhen sending request:\nGET / 1.1", ['request' => $request, 'exception' => $exception, 'milliseconds' => $milliseconds])->shouldBeCalled();
6061

6162
$next = function () use ($exception) {
6263
return new RejectedPromise($exception);
@@ -69,7 +70,8 @@ function it_logs_response_within_exception(
6970
LoggerInterface $logger,
7071
Formatter $formatter,
7172
RequestInterface $request,
72-
ResponseInterface $response
73+
ResponseInterface $response,
74+
$milliseconds
7375
) {
7476
$formatter->formatRequest($request)->willReturn('GET / 1.1');
7577
$formatter->formatResponse($response)->willReturn('403 Forbidden 1.1');
@@ -78,9 +80,10 @@ function it_logs_response_within_exception(
7880

7981
$logger->info("Sending request:\nGET / 1.1", ['request' => $request])->shouldBeCalled();
8082
$logger->error("Error:\nForbidden\nwith response:\n403 Forbidden 1.1\n\nwhen sending request:\nGET / 1.1", [
81-
'request' => $request,
82-
'response' => $response,
83-
'exception' => $exception
83+
'request' => $request,
84+
'response' => $response,
85+
'exception' => $exception,
86+
'milliseconds' => $milliseconds
8487
])->shouldBeCalled();
8588

8689
$next = function () use ($exception) {

0 commit comments

Comments
 (0)