class ClientFactoryMock in Acquia Content Hub 8.2
Mocks the client factory service.
Hierarchy
- class \Drupal\acquia_contenthub\Client\ClientFactory
- class \Drupal\acquia_contenthub_server_test\Client\ClientFactoryMock
Expanded class hierarchy of ClientFactoryMock
File
- tests/
modules/ acquia_contenthub_server_test/ src/ Client/ ClientFactoryMock.php, line 12
Namespace
Drupal\acquia_contenthub_server_test\ClientView source
class ClientFactoryMock extends ClientFactory {
/**
* Override original, and replace Conent Hub client with mock.
*/
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);
}
/**
* {@inheritdoc}
*/
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;
}
// Override configuration.
$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;
}
/**
* {@inheritDoc}
*/
public function isConfigurationSet(Settings $settings = NULL) : bool {
return TRUE;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ClientFactory:: |
protected | property | The contenthub client object. | |
ClientFactory:: |
protected | property | Client CDF object. | |
ClientFactory:: |
protected | property | Acquia ContentHub Admin Settings Config. | |
ClientFactory:: |
protected | property | The event dispatcher. | |
ClientFactory:: |
protected | property | Logger Factory. | |
ClientFactory:: |
protected | property | The module extension list. | |
ClientFactory:: |
protected | property | Settings object. | |
ClientFactory:: |
protected | property | Settings Provider. | |
ClientFactory:: |
public | function | Makes a call to get a client response based on the client name. | |
ClientFactory:: |
protected | function | Returns Client's user agent. | |
ClientFactory:: |
public | function | Gets the settings provider from the settings event for contenthub settings. | |
ClientFactory:: |
public | function | Returns a settings object containing CH credentials and other related info. | |
ClientFactory:: |
protected | function | Call the event to populate contenthub settings. | |
ClientFactory:: |
public | function | Update Client CDF. | |
ClientFactory:: |
public | function | ClientManagerFactory constructor. | |
ClientFactoryMock:: |
public | function |
Instantiates the content hub client. Overrides ClientFactory:: |
|
ClientFactoryMock:: |
public | function |
Verifies whether Content Hub has been configured or not. Overrides ClientFactory:: |
|
ClientFactoryMock:: |
public | function |
Override original, and replace Conent Hub client with mock. Overrides ClientFactory:: |