public function ContentHubTestBase::setContentHubConnection in Acquia Content Hub 8
Configures the Content Hub Connection.
1 call to ContentHubTestBase::setContentHubConnection()
- ContentHubTestBase::setUp in tests/
src/ Functional/ ContentHubTestBase.php
File
- tests/
src/ Functional/ ContentHubTestBase.php, line 137
Class
- ContentHubTestBase
- Provides the base class for web tests for Search API.
Namespace
Drupal\Tests\acquia_contenthub\FunctionalCode
public function setContentHubConnection() {
$config = [
'hostname' => \Drupal::request()
->getHost(),
'api' => '11111111-0000-0000-0000-000000000000',
'secret' => '22222222-0000-0000-0000-000000000000',
'origin' => '00000000-0000-0000-0000-000000000000',
'client_name' => 'mytestsite',
];
// Save configuration variables.
$this->config
->set('hostname', $config['hostname']);
$this->config
->set('api_key', $config['api']);
$this->config
->set('secret_key', $config['secret']);
$this->config
->set('origin', $config['origin']);
$this->config
->set('client_name', $config['client_name']);
$this->config
->save();
// Obtain configuration variables.
$hostname = $this->config
->get('hostname');
$api = $this->config
->get('api_key');
$secret = $this->config
->get('secret_key');
$origin = $this->config
->get('origin');
$client_name = $this->config
->get('client_name');
// Check config variables are correctly set.
$this
->assertEquals($hostname, $config['hostname']);
$this
->assertEquals($api, $config['api']);
$this
->assertEquals($secret, $config['secret']);
$this
->assertEquals($origin, $config['origin']);
$this
->assertEquals($client_name, $config['client_name']);
/** @var \Drupal\acquia_contenthub\Client\ClientManager $client_manager */
$client_manager = $this->container
->get('acquia_contenthub.client_manager');
$client_manager
->resetConnection($config);
$this
->assertTrue($client_manager
->isConnected(), 'Content Hub Client is connected successfully.');
}