Skip to content
Snippets Groups Projects
Commit a34f5f6d authored by Grzegorz Rola's avatar Grzegorz Rola
Browse files

Merge branch 'feature/log-context' into 'master'

Feature/log context

See merge request !2
parents d04bc162 5d488c1c
No related branches found
Tags 1.0.2
1 merge request!2Feature/log context
Pipeline #5081 passed with stages
in 3 minutes and 27 seconds
......@@ -29,4 +29,9 @@ interface ApiClientOptions extends HttpClientOptions, SerializerOptions
*/
public function isCachedClient();
/**
* @return string
*/
public function getApiClientClass();
}
\ No newline at end of file
......@@ -17,7 +17,9 @@ class ClientFactory
$httpClientFactory = new HttpClientFactory();
$serializerFactory = new SerializerFactory();
$client = new ClientImplementation(
$className = $options->getApiClientClass();
$client = new $className(
$httpClientFactory->createClient($options),
$serializerFactory->createSerializer($options),
$options->getLogger(),
......
......@@ -18,6 +18,8 @@ class ClientImplementation implements Client, LoggerAwareInterface
const DEFAULT_TIMEOUT = 10;
const LIBRARY_LOGIN_CONTEXT = 'wp-api-client';
/** @var HttpClient */
private $client;
......@@ -201,7 +203,7 @@ class ClientImplementation implements Client, LoggerAwareInterface
protected function getLoggerContext($additional_context = '')
{
$context = [
Platform::LIBARY_LOGIN_CONTEXT,
self::LIBRARY_LOGIN_CONTEXT,
self::class
];
if ($additional_context !== '') {
......
......@@ -15,6 +15,10 @@ class TestClientFactory extends \PHPUnit\Framework\TestCase
private function prepareOptions($isCachedClient = false)
{
$options = Mockery::mock(\WPDesk\ApiClient\Client\ApiClientOptions::class);
$options->shouldReceive('getApiClientClass')
->withAnyArgs()
->andReturn(\WPDesk\ApiClient\Client\ClientImplementation::class);
$options->shouldReceive('getHttpClientClass')
->withAnyArgs()
->andReturn(\WPDesk\HttpClient\Curl\CurlClient::class);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment