You are here

protected function EntityconnectTestBase::updateEntityReferenceFieldTargets in Entity connect 8.2

Update the target bundles of the test entity reference field.

Parameters

array $target_bundles: The target bundles.

Throws

\Drupal\Core\Entity\EntityStorageException

1 call to EntityconnectTestBase::updateEntityReferenceFieldTargets()
EntityconnectAddTest::testAddWithMultipleTypes in tests/src/Functional/EntityconnectAddTest.php
Entityconnect add with multiple types test.

File

tests/src/Functional/EntityconnectTestBase.php, line 154

Class

EntityconnectTestBase
EntityConnect Test Base.

Namespace

Drupal\Tests\entityconnect\Functional

Code

protected function updateEntityReferenceFieldTargets(array $target_bundles = []) {
  if (!$this->testRefField) {
    $this->testRefField = $this
      ->addContentEntityReferenceField();
  }
  $handler_settings = $this->testRefField
    ->getSetting('handler_settings') ?? [];
  $handler_settings['target_bundles'] = array_merge($handler_settings['target_bundles'], $target_bundles);
  $this->testRefField
    ->setSetting('handler_settings', $handler_settings);
  $this->testRefField
    ->save();
}