AcquiadamClientFactoryTest.php in Media: Acquia DAM 8
File
tests/src/Unit/AcquiadamClientFactoryTest.php
View source
<?php
namespace Drupal\Tests\media_acquiadam\Unit;
use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\Core\Session\AccountProxyInterface;
use Drupal\media_acquiadam\Client;
use Drupal\media_acquiadam\ClientFactory;
use Drupal\Tests\media_acquiadam\Traits\AcquiadamConfigTrait;
use Drupal\Tests\UnitTestCase;
use Drupal\user\UserDataInterface;
use GuzzleHttp\ClientInterface;
class AcquiadamClientFactoryTest extends UnitTestCase {
use AcquiadamConfigTrait;
protected $container;
protected $clientFactory;
public function testFactoryGetBackground() {
$client = $this->clientFactory
->get('background');
$this
->assertInstanceOf(Client::class, $client);
}
public function testFactoryGetCurrent() {
$client = $this->clientFactory
->get('current');
$this
->assertInstanceOf(Client::class, $client);
}
public function testFactoryGetWithCredentials() {
$client = $this->clientFactory
->getWithCredentials('nothing', 'nothing', 'nothing', 'nothing');
$this
->assertInstanceOf(Client::class, $client);
}
protected function setUp() {
parent::setUp();
$current_user = $this
->getMockBuilder(AccountProxyInterface::class)
->disableOriginalConstructor()
->getMock();
$http_client = $this
->getMockBuilder(ClientInterface::class)
->disableOriginalConstructor()
->getMock();
$user_data = $this
->getMockBuilder(UserDataInterface::class)
->disableOriginalConstructor()
->getMock();
$this->container = new ContainerBuilder();
$this->container
->set('string_translation', $this
->getStringTranslationStub());
$this->container
->set('config.factory', $this
->getConfigFactoryStub());
$this->container
->set('http_client', $http_client);
$this->container
->set('user.data', $user_data);
$this->container
->set('current_user', $current_user);
\Drupal::setContainer($this->container);
$this->clientFactory = ClientFactory::create($this->container);
}
}