public function EntityReferenceItemTest::testContentEntityReferenceItemWithStringId in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/field/src/Tests/EntityReference/EntityReferenceItemTest.php \Drupal\field\Tests\EntityReference\EntityReferenceItemTest::testContentEntityReferenceItemWithStringId()
Tests referencing content entities with string IDs.
File
- core/
modules/ field/ src/ Tests/ EntityReference/ EntityReferenceItemTest.php, line 192 - Contains \Drupal\field\Tests\EntityReference\EntityReferenceItemTest.
Class
- EntityReferenceItemTest
- Tests the new entity API for the entity reference field type.
Namespace
Drupal\field\Tests\EntityReferenceCode
public function testContentEntityReferenceItemWithStringId() {
$entity = EntityTest::create();
$entity->field_test_entity_test_string_id->target_id = $this->entityStringId
->id();
$entity
->save();
$storage = \Drupal::entityManager()
->getStorage('entity_test');
$storage
->resetCache();
$this
->assertEqual($this->entityStringId
->id(), $storage
->load($entity
->id())->field_test_entity_test_string_id->target_id);
// Verify that the label for the target ID property definition is correct.
$label = $entity->field_test_taxonomy_term
->getFieldDefinition()
->getFieldStorageDefinition()
->getPropertyDefinition('target_id')
->getLabel();
$this
->assertTrue($label instanceof TranslatableMarkup);
$this
->assertEqual($label
->render(), 'Taxonomy term ID');
}