function MigrateFieldInstanceTest::assertEntityReferenceFields

Same name in other branches
  1. 8.9.x core/modules/field/tests/src/Kernel/Migrate/d7/MigrateFieldInstanceTest.php \Drupal\Tests\field\Kernel\Migrate\d7\MigrateFieldInstanceTest::assertEntityReferenceFields()
  2. 10 core/modules/field/tests/src/Kernel/Migrate/d7/MigrateFieldInstanceTest.php \Drupal\Tests\field\Kernel\Migrate\d7\MigrateFieldInstanceTest::assertEntityReferenceFields()
  3. 11.x core/modules/field/tests/src/Kernel/Migrate/d7/MigrateFieldInstanceTest.php \Drupal\Tests\field\Kernel\Migrate\d7\MigrateFieldInstanceTest::assertEntityReferenceFields()

Asserts the settings of an entity reference field config entity.

@internal

Parameters

string $id: The entity ID in the form ENTITY_TYPE.BUNDLE.FIELD_NAME.

string[] $target_bundles: An array of expected target bundles.

1 call to MigrateFieldInstanceTest::assertEntityReferenceFields()
MigrateFieldInstanceTest::testFieldInstances in core/modules/field/tests/src/Kernel/Migrate/d7/MigrateFieldInstanceTest.php
Tests migrating D7 field instances to field_config entities.

File

core/modules/field/tests/src/Kernel/Migrate/d7/MigrateFieldInstanceTest.php, line 97

Class

MigrateFieldInstanceTest
Migrates Drupal 7 field instances.

Namespace

Drupal\Tests\field\Kernel\Migrate\d7

Code

protected function assertEntityReferenceFields(string $id, array $target_bundles) : void {
    $field = FieldConfig::load($id);
    $handler_settings = $field->getSetting('handler_settings');
    $this->assertArrayHasKey('target_bundles', $handler_settings);
    foreach ($handler_settings['target_bundles'] as $target_bundle) {
        $this->assertContains($target_bundle, $target_bundles);
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.