class AcquiadamClientFactoryTest in Media: Acquia DAM 8
Client factory test.
@group media_acquiadam
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses PhpunitCompatibilityTrait
- class \Drupal\Tests\media_acquiadam\Unit\AcquiadamClientFactoryTest uses AcquiadamConfigTrait
Expanded class hierarchy of AcquiadamClientFactoryTest
File
- tests/
src/ Unit/ AcquiadamClientFactoryTest.php, line 19
Namespace
Drupal\Tests\media_acquiadam\UnitView source
class AcquiadamClientFactoryTest extends UnitTestCase {
use AcquiadamConfigTrait;
/**
* Container builder helper.
*
* @var \Drupal\Core\DependencyInjection\ContainerBuilder
*/
protected $container;
/**
* Media: Acquia DAM client factory.
*
* @var \Drupal\media_acquiadam\ClientFactory
*/
protected $clientFactory;
/**
* Check to make sure that the 'background' option gives us a client.
*/
public function testFactoryGetBackground() {
$client = $this->clientFactory
->get('background');
$this
->assertInstanceOf(Client::class, $client);
}
/**
* Check to make sure that the 'current' option gives us a client.
*/
public function testFactoryGetCurrent() {
$client = $this->clientFactory
->get('current');
$this
->assertInstanceOf(Client::class, $client);
}
/**
* Check to make sure that we can get a client directly.
*/
public function testFactoryGetWithCredentials() {
$client = $this->clientFactory
->getWithCredentials('nothing', 'nothing', 'nothing', 'nothing');
$this
->assertInstanceOf(Client::class, $client);
}
/**
* {@inheritdoc}
*/
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);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
AcquiadamClientFactoryTest:: |
protected | property | Media: Acquia DAM client factory. | |
AcquiadamClientFactoryTest:: |
protected | property | Container builder helper. | |
AcquiadamClientFactoryTest:: |
protected | function |
Overrides UnitTestCase:: |
|
AcquiadamClientFactoryTest:: |
public | function | Check to make sure that the 'background' option gives us a client. | |
AcquiadamClientFactoryTest:: |
public | function | Check to make sure that the 'current' option gives us a client. | |
AcquiadamClientFactoryTest:: |
public | function | Check to make sure that we can get a client directly. | |
AcquiadamConfigTrait:: |
public | function | ||
PhpunitCompatibilityTrait:: |
public | function | Returns a mock object for the specified class using the available method. | |
PhpunitCompatibilityTrait:: |
public | function | Compatibility layer for PHPUnit 6 to support PHPUnit 4 code. | |
UnitTestCase:: |
protected | property | The random generator. | |
UnitTestCase:: |
protected | property | The app root. | 1 |
UnitTestCase:: |
protected | function | Asserts if two arrays are equal by sorting them first. | |
UnitTestCase:: |
protected | function | Mocks a block with a block plugin. | 1 |
UnitTestCase:: |
protected | function | Returns a stub class resolver. | |
UnitTestCase:: |
public | function | Returns a stub config storage that returns the supplied configuration. | |
UnitTestCase:: |
protected | function | Sets up a container with a cache tags invalidator. | |
UnitTestCase:: |
protected | function | Gets the random generator for the utility methods. | |
UnitTestCase:: |
public | function | Returns a stub translation manager that just returns the passed string. | |
UnitTestCase:: |
public | function | Generates a unique random string containing letters and numbers. |