function EntityTypedDataDefinitionTest::testEntityReferences
Same name in other branches
- 9 core/tests/Drupal/KernelTests/Core/Entity/EntityTypedDataDefinitionTest.php \Drupal\KernelTests\Core\Entity\EntityTypedDataDefinitionTest::testEntityReferences()
- 8.9.x core/tests/Drupal/KernelTests/Core/Entity/EntityTypedDataDefinitionTest.php \Drupal\KernelTests\Core\Entity\EntityTypedDataDefinitionTest::testEntityReferences()
- 10 core/tests/Drupal/KernelTests/Core/Entity/EntityTypedDataDefinitionTest.php \Drupal\KernelTests\Core\Entity\EntityTypedDataDefinitionTest::testEntityReferences()
Tests deriving metadata from entity references.
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Entity/ EntityTypedDataDefinitionTest.php, line 136
Class
- EntityTypedDataDefinitionTest
- Tests deriving metadata of entity and field data types.
Namespace
Drupal\KernelTests\Core\EntityCode
public function testEntityReferences() : void {
$reference_definition = DataReferenceDefinition::create('entity');
$this->assertInstanceOf(DataReferenceDefinitionInterface::class, $reference_definition);
// Test retrieving metadata about the referenced data.
$this->assertEquals('entity', $reference_definition->getTargetDefinition()
->getDataType());
$this->assertInstanceOf(EntityDataDefinitionInterface::class, $reference_definition->getTargetDefinition());
// Test that the definition factory creates the right definition object.
$reference_definition2 = $this->typedDataManager
->createDataDefinition('entity_reference');
$this->assertInstanceOf(DataReferenceDefinitionInterface::class, $reference_definition2);
$this->assertEquals(serialize($reference_definition), serialize($reference_definition2));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.