$userref_properties =
$entity->user_id->
getFieldDefinition()->
getPropertyDefinitions();
$this->
assertEquals('integer',
$userref_properties['target_id'
]->
getDataType(),
$entity_type . ': Entity id property of the user found.'
);
$this->
assertEquals('entity_reference',
$userref_properties['entity'
]->
getDataType(),
$entity_type . ': Entity reference property of the user found.'
);
$textfield_properties =
$entity->field_test_text->
getFieldDefinition()->
getFieldStorageDefinition()->
getPropertyDefinitions();
$this->
assertEquals('string',
$textfield_properties['value'
]->
getDataType(),
$entity_type . ': String value property of the test-text field found.'
);
$this->
assertEquals('filter_format',
$textfield_properties['format'
]->
getDataType(),
$entity_type . ': String format field of the test-text field found.'
);
$this->
assertEquals('string',
$textfield_properties['processed'
]->
getDataType(),
$entity_type . ': String processed property of the test-text field found.'
);
// Make sure provided contextual information is right.
$entity_adapter =
$entity->
getTypedData();
$this->
assertSame($entity_adapter->
getRoot(),
$entity_adapter, 'Entity is root object.'
);
$this->
assertEquals('',
$entity_adapter->
getPropertyPath());
$this->
assertEquals('',
$entity_adapter->
getName());
$this->
assertNull($entity_adapter->
getParent());
$field =
$entity->user_id;
$this->
assertSame($field->
getRoot()->
getValue(),
$entity, 'Entity is root object.'
);
$this->
assertSame($field->
getEntity(),
$entity, 'getEntity() returns the entity.'
);
$this->
assertEquals('user_id',
$field->
getPropertyPath());
$this->
assertEquals('user_id',
$field->
getName());
$this->
assertSame($field->
getParent()->
getValue(),
$entity, 'Parent object matches.'
);