public function AcquiaSearchV3ApiClientTest::setUp in Acquia Connector 8
Overrides UnitTestCase::setUp
File
- acquia_search/
tests/ src/ Unit/ AcquiaSearchV3ApiClientTest.php, line 49
Class
- AcquiaSearchV3ApiClientTest
- Search v3 Client test.
Namespace
Drupal\Tests\acquia_search\UnitCode
public function setUp() {
parent::setUp();
$this->searchV3Host = 'https://api.sr-dev.acquia.com';
$this->searchV3ApiKey = 'XXXXXXXXXXyyyyyyyyyyXXXXXXXXXXyyyyyyyyyy';
$path = '/index/network_id/get_all?network_id=WXYZ-12345';
$data = [
'host' => $this->searchV3Host,
'headers' => [
'x-api-key' => $this->searchV3ApiKey,
],
];
$uri = $data['host'] . $path;
$options = [
'headers' => $data['headers'],
'body' => Json::encode($data),
];
$json = '[{"name":"WXYZ-12345.dev.drupal8","host":"test.sr-dev.acquia.com"}]';
$stream = $this
->prophesize('Psr\\Http\\Message\\StreamInterface');
$stream
->getSize()
->willReturn(1000);
$stream
->read(1000)
->willReturn($json);
$response = $this
->prophesize('Psr\\Http\\Message\\ResponseInterface');
$response
->getStatusCode()
->willReturn(200);
$response
->getBody()
->willReturn($stream);
$this->guzzleClient = $this
->prophesize('\\GuzzleHttp\\Client');
$this->guzzleClient
->get($uri, $options)
->willReturn($response);
$this->cacheBackend = $this
->prophesize('\\Drupal\\Core\\Cache\\CacheBackendInterface');
}