protected function FieldItemTest::assertSavedFieldItemValue in Drupal 10
Same name and namespace in other branches
- 8 core/tests/Drupal/KernelTests/Core/Field/FieldItemTest.php \Drupal\KernelTests\Core\Field\FieldItemTest::assertSavedFieldItemValue()
- 9 core/tests/Drupal/KernelTests/Core/Field/FieldItemTest.php \Drupal\KernelTests\Core\Field\FieldItemTest::assertSavedFieldItemValue()
Checks that the saved field item value matches the expected one.
@internal
Parameters
\Drupal\entity_test\Entity\EntityTest $entity: The test entity.
string $expected_value: The expected field item value.
1 call to FieldItemTest::assertSavedFieldItemValue()
- FieldItemTest::testSaveWorkflow in core/
tests/ Drupal/ KernelTests/ Core/ Field/ FieldItemTest.php - Tests the field item save workflow.
File
- core/
tests/ Drupal/ KernelTests/ Core/ Field/ FieldItemTest.php, line 91
Class
- FieldItemTest
- Test field item methods.
Namespace
Drupal\KernelTests\Core\FieldCode
protected function assertSavedFieldItemValue(EntityTest $entity, string $expected_value) : void {
$entity
->setNewRevision(TRUE);
$entity
->save();
$base_field_expected_value = str_replace($this->fieldName, 'field_test_item', $expected_value);
$this
->assertEquals($base_field_expected_value, $entity->field_test_item->value);
$this
->assertEquals($expected_value, $entity->{$this->fieldName}->value);
$entity = $this
->reloadEntity($entity);
$this
->assertEquals($base_field_expected_value, $entity->field_test_item->value);
$this
->assertEquals($expected_value, $entity->{$this->fieldName}->value);
}