Skip to content
Snippets Groups Projects

Feature/first release

Merged Krzysztof Dyszczyk requested to merge feature/first-release into master
2 unresolved threads
1 file
+ 67
0
Compare changes
  • Side-by-side
  • Inline
<?php
use WPDesk\ApiClient\Client\ClientFactory;
class TestClientFactory extends \PHPUnit\Framework\TestCase
{
/**
* Prepare client options.
*
* @param bool $isCachedClient
*
* @return \Mockery\MockInterface|\WPDesk\ApiClient\Client\ApiClientOptions
*/
private function prepareOptions($isCachedClient = false)
{
$options = Mockery::mock(\WPDesk\ApiClient\Client\ApiClientOptions::class);
$options->shouldReceive('getHttpClientClass')
->withAnyArgs()
->andReturn(\WPDesk\HttpClient\Curl\CurlClient::class);
$options->shouldReceive('getSerializerClass')
->withAnyArgs()
->andReturn(\WPDesk\ApiClient\Serializer\JsonSerializer::class);
$options->shouldReceive('getLogger')
->withAnyArgs()
->andReturn(new \Psr\Log\NullLogger());
$options->shouldReceive('getApiUrl')
->withAnyArgs()
->andReturn('https://app.flexibleshipping.com/api/v1');
$options->shouldReceive('getDefaultRequestHeaders')
->withAnyArgs()
->andReturn(array());
$options->shouldReceive('isCachedClient')
->withAnyArgs()
->andReturn($isCachedClient);
return $options;
}
/**
* Test createClient method.
*/
public function testCreateClient()
{
$clientFactory = new ClientFactory();
$client = $clientFactory->createClient($this->prepareOptions());
$this->assertInstanceOf(\WPDesk\ApiClient\Client\ClientImplementation::class, $client);
}
/**
* Test createClient method.
*/
public function testCreateClientCached()
{
$clientFactory = new ClientFactory();
$client = $clientFactory->createClient($this->prepareOptions(true));
$this->assertInstanceOf(\WPDesk\ApiClient\Client\CachedClient::class, $client);
}
}
\ No newline at end of file
Loading