You are here

public function ContentHubReindexTest::testGetExportedEntitiesNotOwnedByThisSite in Acquia Content Hub 8

Test the getExportedEntitiesNotOwnedByThisSite function.

@covers ::getExportedEntitiesNotOwnedByThisSite

File

tests/src/Unit/Controller/ContentHubReindexTest.php, line 390

Class

ContentHubReindexTest
@coversDefaultClass \Drupal\acquia_contenthub\Controller\ContentHubReindex

Namespace

Drupal\Tests\acquia_contenthub\Unit\Controller

Code

public function testGetExportedEntitiesNotOwnedByThisSite() {
  $origin = '00000000-0000-0000-0000-000000000000';
  $entity_type_id = 'media';
  $this->contentHubEntitiesTracking
    ->expects($this
    ->once())
    ->method('getSiteOrigin')
    ->willReturn($origin);

  // Some entities do not belong to this origin.
  $entities = [
    'success' => TRUE,
    'data' => [
      // Entities owned by this site origin.
      [
        'uuid' => '00000000-0000-0000-1111-000000000000',
        'origin' => $origin,
        'modified' => '2017-09-07T22:45:41+00:00',
        'type' => $entity_type_id,
      ],
      [
        'uuid' => '00000000-0000-0000-2222-000000000000',
        'origin' => $origin,
        'modified' => '2017-09-07T22:45:41+00:00',
        'type' => $entity_type_id,
      ],
      [
        'uuid' => '00000000-0000-0000-3333-000000000000',
        'origin' => $origin,
        'modified' => '2017-09-07T22:45:41+00:00',
        'type' => $entity_type_id,
      ],
      // Entities that do not belong to this site origin.
      [
        'uuid' => '00000000-0000-0000-4444-000000000000',
        'origin' => '11111111-0000-0000-0000-000000000000',
        'modified' => '2017-09-07T22:45:41+00:00',
        'type' => $entity_type_id,
      ],
      [
        'uuid' => '00000000-0000-0000-5555-000000000000',
        'origin' => '22222222-0000-0000-0000-000000000000',
        'modified' => '2017-09-07T22:45:41+00:00',
        'type' => $entity_type_id,
      ],
      [
        'uuid' => '00000000-0000-0000-6666-000000000000',
        'origin' => '33333333-0000-0000-0000-000000000000',
        'modified' => '2017-09-07T22:45:41+00:00',
        'type' => $entity_type_id,
      ],
    ],
  ];
  $options = [
    'type' => $entity_type_id,
  ];
  $this->clientManager
    ->expects($this
    ->once())
    ->method('createRequest')
    ->with('listEntities', [
    $options,
  ])
    ->willReturn($entities);
  $external_ownership = $this->contentHubReindex
    ->getExportedEntitiesNotOwnedByThisSite($entity_type_id);
  $expected_output = array_slice($entities['data'], 3, 3);
  $this
    ->assertEquals($expected_output, $external_ownership);
}