You are here

public function EntityReferenceItemTest::testGenerateSampleValueCircularReference in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/field/tests/src/Kernel/EntityReference/EntityReferenceItemTest.php \Drupal\Tests\field\Kernel\EntityReference\EntityReferenceItemTest::testGenerateSampleValueCircularReference()
  2. 9 core/modules/field/tests/src/Kernel/EntityReference/EntityReferenceItemTest.php \Drupal\Tests\field\Kernel\EntityReference\EntityReferenceItemTest::testGenerateSampleValueCircularReference()

Tests the ::generateSampleValue() method when it has a circular reference.

File

core/modules/field/tests/src/Kernel/EntityReference/EntityReferenceItemTest.php, line 237

Class

EntityReferenceItemTest
Tests the new entity API for the entity reference field type.

Namespace

Drupal\Tests\field\Kernel\EntityReference

Code

public function testGenerateSampleValueCircularReference() {

  // Delete the existing entity.
  $this->entityStringId
    ->delete();
  $entity_storage = \Drupal::entityTypeManager()
    ->getStorage('entity_test');
  $entity = $entity_storage
    ->createWithSampleValues('entity_test');
  $this
    ->assertInstanceOf(EntityTestStringId::class, $entity->field_test_entity_test_string_id->entity);
  $this
    ->assertInstanceOf(EntityTest::class, $entity->field_test_entity_test_string_id->entity->field_test_entity_test->entity);
}