Skip to content
This repository was archived by the owner on Mar 23, 2024. It is now read-only.

Commit 22138e2

Browse files
committed
🚿
1 parent 29056cf commit 22138e2

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

tests/OAuthTestHttpClient.php

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,15 @@
1212

1313
namespace chillerlan\OAuthTest;
1414

15-
use chillerlan\HTTP\{Psr18\CurlClient, Psr7};
15+
use chillerlan\HTTP\{Psr18\CurlClient, Psr18\LoggingClient};
1616
use chillerlan\Settings\SettingsContainerInterface;
1717
use Psr\Http\Client\ClientInterface;
1818
use Psr\Http\Message\{RequestInterface, ResponseInterface};
19-
use Psr\Log\{LoggerAwareInterface, LoggerAwareTrait, LoggerInterface, NullLogger};
19+
use Psr\Log\{LoggerAwareInterface, LoggerInterface, NullLogger};
20+
21+
use function usleep;
2022

2123
class OAuthTestHttpClient implements ClientInterface, LoggerAwareInterface{
22-
use LoggerAwareTrait;
2324

2425
/**
2526
* @var \chillerlan\Settings\SettingsContainerInterface
@@ -40,9 +41,19 @@ class OAuthTestHttpClient implements ClientInterface, LoggerAwareInterface{
4041
*/
4142
public function __construct(SettingsContainerInterface $options, ClientInterface $http = null, LoggerInterface $logger = null){
4243
$this->options = $options;
43-
$this->client = $http ?? new CurlClient($this->options);
44+
$this->client = new LoggingClient(
45+
$http ?? new CurlClient($this->options),
46+
$logger ?? new NullLogger
47+
);
48+
}
4449

45-
$this->setLogger($logger ?? new NullLogger);
50+
/**
51+
* @param \Psr\Log\LoggerInterface $logger
52+
*
53+
* @return void
54+
*/
55+
public function setLogger(LoggerInterface $logger):void{
56+
$this->client->setLogger($logger);
4657
}
4758

4859
/**
@@ -51,15 +62,9 @@ public function __construct(SettingsContainerInterface $options, ClientInterface
5162
* @return \Psr\Http\Message\ResponseInterface
5263
*/
5364
public function sendRequest(RequestInterface $request):ResponseInterface{
54-
\usleep($this->options->sleep * 1000000);
55-
56-
$response = $this->client->sendRequest($request);
57-
58-
$this->logger->debug("\n-----REQUEST------\n".Psr7\message_to_string($request));
59-
$this->logger->debug("\n-----RESPONSE-----\n".Psr7\message_to_string($response));
65+
usleep($this->options->sleep * 1000000);
6066

61-
$response->getBody()->rewind();
62-
return $response;
67+
return $this->client->sendRequest($request);
6368
}
6469

6570
}

0 commit comments

Comments
 (0)