You are here

class AcquiadamClientFactoryTest in Media: Acquia DAM 8

Client factory test.

@group media_acquiadam

Hierarchy

Expanded class hierarchy of AcquiadamClientFactoryTest

File

tests/src/Unit/AcquiadamClientFactoryTest.php, line 19

Namespace

Drupal\Tests\media_acquiadam\Unit
View 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

Namesort descending Modifiers Type Description Overrides
AcquiadamClientFactoryTest::$clientFactory protected property Media: Acquia DAM client factory.
AcquiadamClientFactoryTest::$container protected property Container builder helper.
AcquiadamClientFactoryTest::setUp protected function Overrides UnitTestCase::setUp
AcquiadamClientFactoryTest::testFactoryGetBackground public function Check to make sure that the 'background' option gives us a client.
AcquiadamClientFactoryTest::testFactoryGetCurrent public function Check to make sure that the 'current' option gives us a client.
AcquiadamClientFactoryTest::testFactoryGetWithCredentials public function Check to make sure that we can get a client directly.
AcquiadamConfigTrait::getConfigFactoryStub public function
PhpunitCompatibilityTrait::getMock Deprecated public function Returns a mock object for the specified class using the available method.
PhpunitCompatibilityTrait::setExpectedException Deprecated public function Compatibility layer for PHPUnit 6 to support PHPUnit 4 code.
UnitTestCase::$randomGenerator protected property The random generator.
UnitTestCase::$root protected property The app root. 1
UnitTestCase::assertArrayEquals protected function Asserts if two arrays are equal by sorting them first.
UnitTestCase::getBlockMockWithMachineName Deprecated protected function Mocks a block with a block plugin. 1
UnitTestCase::getClassResolverStub protected function Returns a stub class resolver.
UnitTestCase::getConfigStorageStub public function Returns a stub config storage that returns the supplied configuration.
UnitTestCase::getContainerWithCacheTagsInvalidator protected function Sets up a container with a cache tags invalidator.
UnitTestCase::getRandomGenerator protected function Gets the random generator for the utility methods.
UnitTestCase::getStringTranslationStub public function Returns a stub translation manager that just returns the passed string.
UnitTestCase::randomMachineName public function Generates a unique random string containing letters and numbers.