function EntityReferenceItemTest::testGenerateSampleValue
Same name in other branches
- 9 core/modules/field/tests/src/Kernel/EntityReference/EntityReferenceItemTest.php \Drupal\Tests\field\Kernel\EntityReference\EntityReferenceItemTest::testGenerateSampleValue()
- 8.9.x core/modules/field/tests/src/Kernel/EntityReference/EntityReferenceItemTest.php \Drupal\Tests\field\Kernel\EntityReference\EntityReferenceItemTest::testGenerateSampleValue()
- 11.x core/modules/field/tests/src/Kernel/EntityReference/EntityReferenceItemTest.php \Drupal\Tests\field\Kernel\EntityReference\EntityReferenceItemTest::testGenerateSampleValue()
Tests the ::generateSampleValue() method.
File
-
core/
modules/ field/ tests/ src/ Kernel/ EntityReference/ EntityReferenceItemTest.php, line 221
Class
- EntityReferenceItemTest
- Tests the new entity API for the entity reference field type.
Namespace
Drupal\Tests\field\Kernel\EntityReferenceCode
public function testGenerateSampleValue() : void {
$entity = EntityTest::create();
// Test while a term exists.
$entity->field_test_taxonomy_term
->generateSampleItems();
$this->assertInstanceOf(TermInterface::class, $entity->field_test_taxonomy_term->entity);
$this->entityValidateAndSave($entity);
// Delete the term and test again.
$this->term
->delete();
$entity->field_test_taxonomy_term
->generateSampleItems();
$this->assertInstanceOf(TermInterface::class, $entity->field_test_taxonomy_term->entity);
$this->entityValidateAndSave($entity);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.