You are here

public function ClientFactoryTest::testGetClientConfiguredByCoreConfig in Acquia Content Hub 8.2

Test case when content hub configured via core config or UI.

@dataProvider settingsDataProvider

Parameters

string $name: Client name.

string $uuid: Client UUID.

string $api_key: API Key.

string $secret_key: Secret Key.

string $url: Hostname.

string $shared_secret: Shared secret key.

See also

GetSettingsFromCoreConfig

File

tests/src/Kernel/ClientFactoryTest.php, line 72

Class

ClientFactoryTest
Tests the client factory.

Namespace

Drupal\Tests\acquia_contenthub\Kernel

Code

public function testGetClientConfiguredByCoreConfig(string $name, string $uuid, string $api_key, string $secret_key, string $url, string $shared_secret) {
  $ch_settings = [
    'client_name' => $name,
    'origin' => $uuid,
    'api_key' => $api_key,
    'secret_key' => $secret_key,
    'hostname' => $url,
    'shared_secret' => $shared_secret,
  ];
  $this
    ->createAcquiaContentHubAdminSettings($ch_settings);
  Cache::invalidateTags([
    'acquia_contenthub_settings',
  ]);

  /** @var \Drupal\acquia_contenthub\Client\ClientFactory $clientFactory */
  $clientFactory = \Drupal::service('acquia_contenthub.client.factory');
  $settings = $clientFactory
    ->getClient()
    ->getSettings();

  // Check that settings has loaded from correct storage (provider).
  $this
    ->assertEquals($clientFactory
    ->getProvider(), 'core_config');

  // Check all values.
  $this
    ->assertEquals($settings
    ->getName(), $name);
  $this
    ->assertEquals($settings
    ->getUuid(), $uuid);
  $this
    ->assertEquals($settings
    ->getApiKey(), $api_key);
  $this
    ->assertEquals($settings
    ->getSecretKey(), $secret_key);
  $this
    ->assertEquals($settings
    ->getUrl(), $url);
  $this
    ->assertEquals($settings
    ->getSharedSecret(), $shared_secret);
}