You are here

public function PublishOnlyRenderedTest::testOnEnqueueCandidateEntity in Acquia Lift Connector 8.4

@covers ::onEnqueueCandidateEntity

Throws

\Exception

File

modules/acquia_lift_publisher/tests/src/Kernel/EventSubscriber/Publish/PublishOnlyRenderedTest.php, line 145

Class

PublishOnlyRenderedTest
Class PublishOnlyRenderedTest.

Namespace

Drupal\Tests\acquia_lift_publisher\Kernel\EventSubscriber\Publish

Code

public function testOnEnqueueCandidateEntity() {
  $entity = $this
    ->createNode([
    'title' => 'Test title',
    'type' => 'article',
  ]);

  // Set up entity view display for rendered entity creation.
  EntityViewDisplay::create([
    'id' => 'node.article',
    'targetEntityType' => 'node',
    'bundle' => 'article',
    'label' => 'Full',
    'mode' => 'full',
  ])
    ->save();
  $operation = 'insert';
  $event = new ContentHubEntityEligibilityEvent($entity, $operation);
  $this->eventDispatcher
    ->dispatch(ContentHubPublisherEvents::ENQUEUE_CANDIDATE_ENTITY, $event);
  $this
    ->assertFalse($event
    ->getEligibility(), 'Entity not eligible due to the default publishing configuration');

  // Enable entity view display for the article, check if the entity is
  // eligible.
  $this->publisherSettings
    ->set('view_modes', [
    'node' => [
      'article' => [
        'full' => 1,
      ],
    ],
  ]);
  $this
    ->savePublisherSettings();
  $event = new ContentHubEntityEligibilityEvent($entity, $operation);
  $this->eventDispatcher
    ->dispatch(ContentHubPublisherEvents::ENQUEUE_CANDIDATE_ENTITY, $event);
  $this
    ->assertTrue($event
    ->getEligibility(), 'Entity is renderable, therefore eligible.');
}