You are here

public function EntityReferenceFieldTest::testEntityReferenceFieldDependencies in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Tests/Entity/EntityReferenceFieldTest.php \Drupal\system\Tests\Entity\EntityReferenceFieldTest::testEntityReferenceFieldDependencies()

Tests the dependencies entity reference fields are created with.

File

core/modules/system/src/Tests/Entity/EntityReferenceFieldTest.php, line 413
Contains \Drupal\system\Tests\Entity\EntityReferenceFieldTest.

Class

EntityReferenceFieldTest
Tests for the entity reference field.

Namespace

Drupal\system\Tests\Entity

Code

public function testEntityReferenceFieldDependencies() {
  $field_name = 'user_reference_field';
  $entity_type = 'entity_test';
  $field_storage = FieldStorageConfig::create([
    'field_name' => $field_name,
    'type' => 'entity_reference',
    'entity_type' => $entity_type,
    'settings' => [
      'target_type' => 'user',
    ],
  ]);
  $field_storage
    ->save();
  $this
    ->assertEqual([
    'module' => [
      'entity_test',
      'user',
    ],
  ], $field_storage
    ->getDependencies());
  $field = FieldConfig::create([
    'field_name' => $field_name,
    'entity_type' => $entity_type,
    'bundle' => 'entity_test',
    'label' => $field_name,
    'settings' => [
      'handler' => 'default',
    ],
  ]);
  $field
    ->save();
  $this
    ->assertEqual([
    'config' => [
      'field.storage.entity_test.user_reference_field',
    ],
    'module' => [
      'entity_test',
    ],
  ], $field
    ->getDependencies());
}