You are here

public function ClusterManagerTest::testLoadAllClusters in Elasticsearch Connector 8.6

Same name and namespace in other branches
  1. 8.7 tests/src/Unit/ClusterManagerTest.php \Drupal\Tests\elasticsearch_connector\Unit\ClusterManagerTest::testLoadAllClusters()
  2. 8.5 tests/src/Unit/ClusterManagerTest.php \Drupal\Tests\elasticsearch_connector\Unit\ClusterManagerTest::testLoadAllClusters()

@covers ::loadAllClusters

File

tests/src/Unit/ClusterManagerTest.php, line 68

Class

ClusterManagerTest
@coversDefaultClass \Drupal\elasticsearch_connector\ClusterManager

Namespace

Drupal\Tests\elasticsearch_connector\Unit

Code

public function testLoadAllClusters() {
  $state = $this
    ->prophesize(StateInterface::class);
  $cluster1 = new \stdClass();
  $cluster1->cluster_id = 'foo';
  $cluster1->status = FALSE;
  $cluster2 = new \stdClass();
  $cluster2->cluster_id = 'bar';
  $cluster2->status = TRUE;
  $entity_storage_interface = $this
    ->prophesize(EntityStorageInterface::class);
  $entity_storage_interface
    ->loadMultiple()
    ->willReturn([
    $cluster1->cluster_id => $cluster1,
    $cluster2->cluster_id => $cluster2,
  ]);
  $entity_type_manager = $this
    ->prophesize(EntityTypeManagerInterface::class);
  $entity_type_manager
    ->getStorage('elasticsearch_cluster')
    ->willReturn($entity_storage_interface
    ->reveal());
  $this->clusterManager = new ClusterManager($state
    ->reveal(), $entity_type_manager
    ->reveal());
  $expected_clusters = [
    $cluster2->cluster_id => $cluster2,
  ];
  $this
    ->assertEquals($expected_clusters, $this->clusterManager
    ->loadAllClusters(FALSE));
}