public function EntityReferenceItemTest::testGenerateSampleValueCircularReference in Drupal 9
Same name and namespace in other branches
- 8 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\EntityReferenceCode
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);
}