$this->
assertSame('foo computed 0',
$entity->computed_string_field
[0
]->value
);
$this->
assertSame('foo computed 1',
$entity->computed_string_field
[1
]->value
);
// Test \Drupal\Core\TypedData\ComputedItemListTrait::appendItem().
$entity = EntityTestComputedField::
create([]);
$entity->computed_string_field->
appendItem('foo computed 1'
);
$this->
assertSame('foo computed',
$entity->computed_string_field
[0
]->value
);
$this->
assertSame('foo computed 1',
$entity->computed_string_field
[1
]->value
);
// Test \Drupal\Core\TypedData\ComputedItemListTrait::removeItem().
$entity = EntityTestComputedField::
create([]);
$entity->computed_string_field->
removeItem(0
);
$this->
assertTrue($entity->computed_string_field->
isEmpty());
// Test \Drupal\Core\TypedData\ComputedItemListTrait::isEmpty().
\Drupal::
state()->
set('entity_test_computed_field_item_list_value',
[]);
$entity = EntityTestComputedField::
create([]);
$this->
assertTrue($entity->computed_string_field->
isEmpty());
\Drupal::
state()->
set('entity_test_computed_field_item_list_value',
['foo computed'
]);
$entity = EntityTestComputedField::
create([]);
$this->
assertFalse($entity->computed_string_field->
isEmpty());