You are here

protected function FieldItemTest::assertSavedFieldItemValue in Drupal 9

Same name and namespace in other branches
  1. 8 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.

Parameters

\Drupal\entity_test\Entity\EntityTest $entity: The test entity.

$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 89

Class

FieldItemTest
Test field item methods.

Namespace

Drupal\KernelTests\Core\Field

Code

protected function assertSavedFieldItemValue(EntityTest $entity, $expected_value) {
  $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);
}