function FormTest::assertFieldValues

{inheritdoc}

Overrides FieldTestBase::assertFieldValues

2 calls to FormTest::assertFieldValues()
FormTest::testFieldFormMultipleWidget in drupal/core/modules/field/lib/Drupal/field/Tests/FormTest.php
Tests widgets handling multiple values.
FormTest::testNestedFieldForm in drupal/core/modules/field/lib/Drupal/field/Tests/FormTest.php
Tests Field API form integration within a subform.

File

drupal/core/modules/field/lib/Drupal/field/Tests/FormTest.php, line 687
Definition of Drupal\field\Tests\FormTest.

Class

FormTest

Namespace

Drupal\field\Tests

Code

function assertFieldValues(EntityInterface $entity, $field_name, $langcode, $expected_values, $column = 'value') {

  // Override the base implementation with one that works with the old
  // entity API.
  // @todo: Remove this when replacing the remaining of test_entity with
  //   entity_test.
  $e = clone $entity;
  field_attach_load('test_entity', array(
    $e->ftid => $e,
  ));
  $values = isset($e->{$field_name}[$langcode]) ? $e->{$field_name}[$langcode] : array();
  $this
    ->assertEqual(count($values), count($expected_values), 'Expected number of values were saved.');
  foreach ($expected_values as $key => $value) {
    $this
      ->assertEqual($values[$key][$column], $value, format_string('Value @value was saved correctly.', array(
      '@value' => $value,
    )));
  }
}