You are here

protected function AcquiaConnectorSearchOverrideTest::setAvailableSearchCores in Acquia Connector 8

Sets available search cores into the subscription heartbeat data.

Parameters

bool $no_db_flag: Allows to set a limited number of search cores by excluding the one that contains the DB name.

1 call to AcquiaConnectorSearchOverrideTest::setAvailableSearchCores()
AcquiaConnectorSearchOverrideTest::setUp in acquia_search/tests/src/Functional/AcquiaConnectorSearchOverrideTest.php

File

acquia_search/tests/src/Functional/AcquiaConnectorSearchOverrideTest.php, line 309

Class

AcquiaConnectorSearchOverrideTest
Tests the automatic switching behavior of the Acquia Search module.

Namespace

Drupal\Tests\acquia_search\Functional

Code

protected function setAvailableSearchCores($no_db_flag = FALSE) {
  $acquia_identifier = $this->id;
  $solr_hostname = 'mock.acquia-search.com';
  $site_folder = $this
    ->getSiteFolderName();
  $ah_db_name = $this
    ->getDbName();
  $core_with_folder_name = [
    'balancer' => $solr_hostname,
    'core_id' => "{$acquia_identifier}.dev.{$site_folder}",
  ];
  $core_with_db_name = [
    'balancer' => $solr_hostname,
    'core_id' => "{$acquia_identifier}.dev.{$ah_db_name}",
  ];
  $core_with_acquia_identifier = [
    'balancer' => $solr_hostname,
    'core_id' => "{$acquia_identifier}",
  ];
  if ($no_db_flag) {
    $available_cores = [
      $core_with_folder_name,
      $core_with_acquia_identifier,
    ];
  }
  else {
    $available_cores = [
      $core_with_folder_name,
      $core_with_db_name,
      $core_with_acquia_identifier,
    ];
  }
  $storage = new Storage();
  $storage
    ->setIdentifier($acquia_identifier);
  $subscription = \Drupal::state()
    ->get('acquia_subscription_data');
  $subscription['heartbeat_data'] = [
    'search_cores' => $available_cores,
  ];
  \Drupal::state()
    ->set('acquia_subscription_data', $subscription);
}