You are here

protected function FieldItemTest::assertSavedFieldItemValue in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Tests/Field/FieldItemTest.php \Drupal\system\Tests\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.

Return value

bool TRUE if the item value matches expectations, FALSE otherwise.

1 call to FieldItemTest::assertSavedFieldItemValue()
FieldItemTest::testSaveWorkflow in core/modules/system/src/Tests/Field/FieldItemTest.php
Tests the field item save workflow.

File

core/modules/system/src/Tests/Field/FieldItemTest.php, line 98
Contains \Drupal\system\Tests\Field\FieldItemTest.

Class

FieldItemTest
Test field item methods.

Namespace

Drupal\system\Tests\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);
  $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;
}