protected function ParagraphsNodeMigrationAssertionsTrait::getReferencedEntities

Get the referred entities.

Parameters

\Drupal\Core\Entity\ContentEntityInterface $entity: The parent entity.

string $field_name: The name of the entity revision reference field.

int $expected_count: The expected number of the referenced entities.

Return value

\Drupal\Core\Entity\EntityInterface[] An array of entity objects keyed by field item deltas.

3 calls to ParagraphsNodeMigrationAssertionsTrait::getReferencedEntities()

File

paragraphs/tests/src/Traits/ParagraphsNodeMigrationAssertionsTrait.php, line 125

Class

ParagraphsNodeMigrationAssertionsTrait

Namespace

Drupal\Tests\paragraphs\Traits

Code

protected function getReferencedEntities(ContentEntityInterface $entity, $field_name, int $expected_count) {
  $entity_field = $entity
    ->hasField($field_name) ? $entity
    ->get($field_name) : NULL;
  assert($entity_field instanceof EntityReferenceRevisionsFieldItemList);
  $entity_field_entities = $entity_field
    ->referencedEntities();
  $this
    ->assertCount($expected_count, $entity_field_entities);
  return $entity_field_entities;
}