ClientFactoryMock.php in Acquia Content Hub 8.2
File
tests/modules/acquia_contenthub_server_test/src/Client/ClientFactoryMock.php
View source
<?php
namespace Drupal\acquia_contenthub_server_test\Client;
use Acquia\ContentHubClient\Settings;
use Drupal\acquia_contenthub\Client\ClientFactory;
use Drupal\Component\Uuid\Uuid;
class ClientFactoryMock extends ClientFactory {
public function registerClient(string $name, string $url, string $api_key, string $secret, string $api_version = 'v2') {
return ContentHubClientMock::register($this->loggerFactory
->get('acquia_contenthub'), $this->dispatcher, $name, $url, $api_key, $secret);
}
public function getClient(Settings $settings = NULL) {
if (isset($this->client)) {
return $this->client;
}
if (!$this->settings || !Uuid::isValid($this->settings
->getUuid()) || empty($this->settings
->getName()) || empty($this->settings
->getUrl()) || empty($this->settings
->getApiKey()) || empty($this->settings
->getSecretKey())) {
return FALSE;
}
$config = [
'base_url' => $this->settings
->getUrl(),
'client-user-agent' => $this
->getClientUserAgent(),
];
$this->client = new ContentHubClientMock($config, $this->loggerFactory
->get('acquia_contenthub'), $this->settings, $this->settings
->getMiddleware(), $this->dispatcher);
return $this->client;
}
public function isConfigurationSet(Settings $settings = NULL) : bool {
return TRUE;
}
}