You are here

protected function ParagraphsNodeMigrationAssertionsTrait::getReferencedEntities in Paragraphs 8

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()
ParagraphsNodeMigrationAssertionsTrait::assertIcelandicNode9Paragraphs in tests/src/Traits/ParagraphsNodeMigrationAssertionsTrait.php
Assertions of the Icelandic translation of node 9.
ParagraphsNodeMigrationAssertionsTrait::assertNode8Paragraphs in tests/src/Traits/ParagraphsNodeMigrationAssertionsTrait.php
Assertions on node 8.
ParagraphsNodeMigrationAssertionsTrait::assertNode9Paragraphs in tests/src/Traits/ParagraphsNodeMigrationAssertionsTrait.php
Assertions of node 9.

File

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;
}