You are here

public function EntityManagerTest::testSupportedContentHubEntity in Acquia Content Hub 8

Test for isSupportedContentHubEntity() method.

@covers ::isSupportedContentHubEntity

File

tests/src/Unit/EntityManagerTest.php, line 300

Class

EntityManagerTest
PHPUnit for the EntityManager class.

Namespace

Drupal\Tests\acquia_contenthub\Unit

Code

public function testSupportedContentHubEntity() {
  $entity_manager = new EntityManager($this->loggerFactory, $this->configFactory, $this->clientManager, $this->contentHubEntitiesTracking, $this->entityTypeManager, $this->entityTypeBundleInfoManager, $this->kernel);

  // Defining a Content Entity.
  $enabled_methods = [
    'getEntityTypeId',
  ];
  $content_entity = $this
    ->getMockBuilder('Drupal\\Core\\Entity\\ContentEntityBase')
    ->disableOriginalConstructor()
    ->setMethods($enabled_methods)
    ->getMockForAbstractClass();

  // Testing node is a supported Content Hub entity.
  $content_entity
    ->expects($this
    ->at(0))
    ->method('getEntityTypeId')
    ->willReturn('node');

  // Testing taxonomy_term is a supported Content Hub entity.
  $content_entity
    ->expects($this
    ->at(1))
    ->method('getEntityTypeId')
    ->willReturn('taxonomy_term');

  // Testing user is not a supported Content Hub entity.
  $content_entity
    ->expects($this
    ->at(2))
    ->method('getEntityTypeId')
    ->willReturn('user');
  $this
    ->assertTrue($entity_manager
    ->isSupportedContentHubEntity($content_entity));
  $this
    ->assertTrue($entity_manager
    ->isSupportedContentHubEntity($content_entity));
  $this
    ->assertFalse($entity_manager
    ->isSupportedContentHubEntity($content_entity));
}