$entity = EntityTestComputedField::
create([]);
$this->
assertCount(0,
$entity->computed_string_field
);
// Test \Drupal\Core\Field\FieldItemList::equals() for a computed field.
\Drupal::
state()->
set('entity_test_computed_field_item_list_value',
['foo computed'
]);
$entity = EntityTestComputedField::
create([]);
$computed_item_list1 =
$entity->computed_string_field;
$entity = EntityTestComputedField::
create([]);
$computed_item_list2 =
$entity->computed_string_field;
$this->
assertTrue($computed_item_list1->
equals($computed_item_list2));
$computed_item_list2->value = 'foo computed 2';
$this->
assertFalse($computed_item_list1->
equals($computed_item_list2));
} /**
* Tests an entity reference computed field.
*/
public function testEntityReferenceComputedField() { $this->
installEntitySchema('entity_test_computed_field'
);