protected function MediaMigrationAssertionsBaseTrait::getReferencedEntities in Media Migration 8
Get the referred entities.
Parameters
\Drupal\Core\Entity\ContentEntityInterface $entity: The parent entity.
string $field_name: The name of the entity 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.
23 calls to MediaMigrationAssertionsBaseTrait::getReferencedEntities()
- MediaMigrationAssertionsForMediaSourceTrait::assertMedia10FieldValues in tests/
src/ Traits/ MediaMigrationAssertionsForMediaSourceTrait.php - Assertions of media 10 ("yellow.webp").
- MediaMigrationAssertionsForMediaSourceTrait::assertMedia11FieldValues in tests/
src/ Traits/ MediaMigrationAssertionsForMediaSourceTrait.php - Assertions of media 11 ("audio.m4a").
- MediaMigrationAssertionsForMediaSourceTrait::assertMedia12FieldValues in tests/
src/ Traits/ MediaMigrationAssertionsForMediaSourceTrait.php - Assertions of media 12 ("document.odt").
- MediaMigrationAssertionsForMediaSourceTrait::assertMedia1FieldValues in tests/
src/ Traits/ MediaMigrationAssertionsForMediaSourceTrait.php - Assertions of media 1.
- MediaMigrationAssertionsForMediaSourceTrait::assertMedia2FieldValues in tests/
src/ Traits/ MediaMigrationAssertionsForMediaSourceTrait.php - Assertions of media 2.
File
- tests/
src/ Traits/ MediaMigrationAssertionsBaseTrait.php, line 767
Class
- MediaMigrationAssertionsBaseTrait
- Trait for media migration tests.
Namespace
Drupal\Tests\media_migration\TraitsCode
protected function getReferencedEntities(ContentEntityInterface $entity, $field_name, int $expected_count) {
$entity_field = $entity
->hasField($field_name) ? $entity
->get($field_name) : NULL;
$this
->assertInstanceOf(EntityReferenceFieldItemList::class, $entity_field);
$entity_field_entities = $entity_field
->referencedEntities();
$this
->assertCount($expected_count, $entity_field_entities);
return $entity_field_entities;
}