function EntityReferenceItemTest::testGenerateSampleValueCircularReference

Same name in other branches
  1. 9 core/modules/field/tests/src/Kernel/EntityReference/EntityReferenceItemTest.php \Drupal\Tests\field\Kernel\EntityReference\EntityReferenceItemTest::testGenerateSampleValueCircularReference()
  2. 8.9.x core/modules/field/tests/src/Kernel/EntityReference/EntityReferenceItemTest.php \Drupal\Tests\field\Kernel\EntityReference\EntityReferenceItemTest::testGenerateSampleValueCircularReference()
  3. 11.x 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 239

Class

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

Namespace

Drupal\Tests\field\Kernel\EntityReference

Code

public function testGenerateSampleValueCircularReference() : void {
    // 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);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.