You are here

public function ContentHubEntitiesTrackingTest::testServiceLevelCaching in Acquia Content Hub 8

Test for service-level caching.

@covers ::setImportedEntity

File

tests/src/Unit/ContentHubEntitiesTrackingTest.php, line 277

Class

ContentHubEntitiesTrackingTest
PHPUnit tests for the ContentHubEntitiesTracking class.

Namespace

Drupal\Tests\acquia_contenthub\Unit

Code

public function testServiceLevelCaching() {
  $entity1 = (object) [
    'entity_type' => 'node',
    'entity_id' => 1,
    'entity_uuid' => '00000000-0000-0000-0000-000000000000',
    'modified' => '2016-12-09T20:51:45+00:00',
    'origin' => '22222222-2222-2222-2222-222222222222',
  ];
  $entity2 = (object) [
    'entity_type' => 'node',
    'entity_id' => 2,
    'entity_uuid' => '11111111-1111-1111-1111-111111111111',
    'modified' => '2016-12-10T20:51:45+00:00',
    'origin' => '22222222-2222-2222-2222-222222222222',
  ];
  $this->contentHubEntitiesTracking = $this
    ->getContentHubEntitiesTrackingService();
  $this->contentHubEntitiesTracking
    ->setImportedEntity($entity1->entity_type, $entity1->entity_id, $entity1->entity_uuid, $entity1->modified, $entity1->origin);
  $this->contentHubEntitiesTracking
    ->setImportedEntity($entity2->entity_type, $entity2->entity_id, $entity2->entity_uuid, $entity2->modified, $entity2->origin);
  $this->contentHubEntitiesTracking
    ->loadExportedByDrupalEntity($entity1->entity_type, $entity1->entity_id);
  $this
    ->assertEquals($entity1->entity_type, $this->contentHubEntitiesTracking
    ->getEntityType());
  $this
    ->assertEquals($entity1->entity_id, $this->contentHubEntitiesTracking
    ->getEntityId());
  $this
    ->assertEquals($entity1->entity_uuid, $this->contentHubEntitiesTracking
    ->getUuid());
  $this
    ->assertEquals($entity1->modified, $this->contentHubEntitiesTracking
    ->getModified());
  $this
    ->assertEquals($entity1->origin, $this->contentHubEntitiesTracking
    ->getOrigin());
  $this
    ->assertTrue($this->contentHubEntitiesTracking
    ->isAutoUpdate());
  $this
    ->assertFalse($this->contentHubEntitiesTracking
    ->hasLocalChange());
  $this
    ->assertFalse($this->contentHubEntitiesTracking
    ->isPendingSync());
}