public function ContentHubEntityExportControllerTest::testQueueExportedEntity in Acquia Content Hub 8
Tests queueExportedEntity method.
@covers ::queueExportedEntity
Throws
\Drupal\Core\Entity\EntityStorageException
File
- tests/
src/ Unit/ Controller/ ContentHubEntityExportControllerTest.php, line 337
Class
- ContentHubEntityExportControllerTest
- Unit test for ContentHubEntityExportController class.
Namespace
Drupal\Tests\acquia_contenthub\Unit\ControllerCode
public function testQueueExportedEntity() {
$entity = $this
->getSampleContentHubEntity();
$contentHubEntitiesTracking = $this
->getContentHubEntitiesTrackingService();
$contentHubEntitiesTracking
->setExportedEntity($entity->entity_type, $entity->entity_id, $entity->entity_uuid, $entity->modified, $entity->origin);
/** @var \Drupal\Core\Entity\ContentEntityInterface|\PHPUnit\Framework\MockObject\MockObject $node */
$node = $this
->getMockBuilder('\\Drupal\\node\\Entity\\Node')
->disableOriginalConstructor()
->getMock();
$node
->method('id')
->willReturn($entity->entity_id);
$node
->method('uuid')
->willReturn($entity->entity_uuid);
$node
->method('getEntityTypeId')
->willReturn($entity->entity_type);
$this->contentHubEntitiesTracking
->expects($this::exactly(2))
->method('save');
$this->entityRepository
->method('loadEntityByUuid')
->willReturn($node);
$this->contentHubEntitiesTracking
->method('getSiteOrigin')
->willReturn('00000000-0000-0000-0000-000000000000');
$this->contentHubEntitiesTracking
->method('setExportedEntity')
->willReturn($contentHubEntitiesTracking);
$this->contentHubEntityExportController
->queueExportedEntity($node);
$this
->assertEquals(TRUE, $contentHubEntitiesTracking
->isQueued());
$contentHubEntitiesTracking = $this
->getContentHubEntitiesTrackingService();
$contentHubEntitiesTracking
->setExportedEntity($entity->entity_type, $entity->entity_id, $entity->entity_uuid, $entity->modified, $entity->origin);
$this->contentHubEntitiesTracking
->method('loadExportedByUuid')
->willReturn($contentHubEntitiesTracking);
$this->contentHubEntityExportController
->queueExportedEntity($node);
$this
->assertEquals(TRUE, $contentHubEntitiesTracking
->isQueued());
}