'value' => 'foo computed 1'
],
['value' => 'foo computed 2'
],
]);
$this->
assertSame([['value' => 'foo computed 1'
],
['value' => 'foo computed 2'
]],
$entity->computed_string_field->
getValue());
// Check that the values have not been computed when they were explicitly
// set.
$this->
assertSame(0, \Drupal::
state()->
get('computed_test_field_execution', 0
));
// Test \Drupal\Core\TypedData\ComputedItemListTrait::getString().
$entity = EntityTestComputedField::
create([]);
$this->
assertSame('foo computed',
$entity->computed_string_field->
getString());
// Test \Drupal\Core\TypedData\ComputedItemListTrait::get().
$entity = EntityTestComputedField::
create([]);
$this->
assertSame('foo computed',
$entity->computed_string_field->
get(0
)->value
);
$this->
assertEmpty($entity->computed_string_field->
get(1
));
// Test \Drupal\Core\TypedData\ComputedItemListTrait::set().
$entity = EntityTestComputedField::
create([]);
$entity->computed_string_field->
set(1, 'foo computed 1'
);
$this->
assertSame('foo computed',
$entity->computed_string_field
[0
]->value
);
$this->
assertSame('foo computed 1',
$entity->computed_string_field
[1
]->value
);