public function ContentHubEntityExportControllerTest::testExportEntities in Acquia Content Hub 8
Tests exportEntities method.
@covers ::exportEntities
Throws
\Drupal\Core\Entity\EntityStorageException
File
- tests/
src/ Unit/ Controller/ ContentHubEntityExportControllerTest.php, line 286
Class
- ContentHubEntityExportControllerTest
- Unit test for ContentHubEntityExportController class.
Namespace
Drupal\Tests\acquia_contenthub\Unit\ControllerCode
public function testExportEntities() {
$candidate_entities = $this
->getSampleCandidateEntities();
$this->contentHubInternalRequest
->method('getEntityCdfByInternalRequest')
->willReturn($this
->getEntities());
list(, , $node) = $this
->getBasicEntities();
$this->entityRepository
->method('loadEntityByUuid')
->willReturn($node);
$actual_result = $this->contentHubEntityExportController
->exportEntities($candidate_entities);
$this
->assertEquals(FALSE, $actual_result);
$this->config
->method('get')
->with('export_with_queue')
->willReturn(TRUE);
$this
->instantiateContentHubEntityController();
$this->entityRepository
->method('loadEntityByUuid')
->willReturnOnConsecutiveCalls(...array_values($this
->getSampleCandidateEntities()));
$entity = $this
->getSampleContentHubEntity();
$contentHubEntitiesTracking = $this
->getContentHubEntitiesTrackingService();
$contentHubEntitiesTracking
->setExportedEntity($entity->entity_type, $entity->entity_id, $entity->entity_uuid, $entity->modified, $entity->origin);
$this->contentHubEntitiesTracking
->method('setExportedEntity')
->willReturn($contentHubEntitiesTracking);
$this->contentHubExportQueueController
->expects($this
->once())
->method('enqueueExportEntities')
->willReturnCallback(function ($candidate_entities) {
return $candidate_entities;
});
$actual_result = $this->contentHubEntityExportController
->exportEntities($candidate_entities);
$this
->assertEquals(TRUE, $actual_result);
}