You are here

protected function MigrateEckFieldInstanceTest::assertEntityReferenceFields in Entity Construction Kit (ECK) 8

Asserts the settings of an entity reference field config entity.

Parameters

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

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

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

File

tests/src/Kernel/Migrate/d7/MigrateEckFieldInstanceTest.php, line 49

Class

MigrateEckFieldInstanceTest
Migrates Drupal 7 field instances.

Namespace

Drupal\Tests\eck\Kernel\Migrate\d7

Code

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