/** * Checks that the saved field item value matches the expected one. * * @param \Drupal\entity_test\Entity\EntityTest $entity * The test entity. * @param $expected_value * The expected field item value. * * @return bool * TRUE if the item value matches expectations, FALSE otherwise. */ 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); $result = $this->assertEqual($entity->field_test_item->value, $base_field_expected_value); $result = $result && $this->assertEqual($entity->{$this->fieldName}->value, $expected_value); $entity = $this->reloadEntity($entity); $result = $result && $this->assertEqual($entity->field_test_item->value, $base_field_expected_value); $result = $result && $this->assertEqual($entity->{$this->fieldName}->value, $expected_value); return $result; }