function FieldTestCase::assertFieldValues

Assert that a field has the expected values in an entity.

This function only checks a single column in the field values.

Parameters

$entity: The entity to test.

$field_name: The name of the field to test

$langcode: The language code for the values.

$expected_values: The array of expected values.

$column: (Optional) the name of the column to check.

14 calls to FieldTestCase::assertFieldValues()
FieldFormTestCase::testFieldFormMultipleWidget in drupal-7.x/modules/field/tests/field.test
Tests widgets handling multiple values.
FieldFormTestCase::testFieldFormMultipleWidget in drupal-7.x/modules/field/tests/field.test
Tests widgets handling multiple values.
FieldFormTestCase::testNestedFieldForm in drupal-7.x/modules/field/tests/field.test
Tests Field API form integration within a subform.
FieldFormTestCase::testNestedFieldForm in drupal-7.x/modules/field/tests/field.test
Tests Field API form integration within a subform.
OptionsWidgetsTestCase::testCheckBoxes in drupal-7.x/modules/field/modules/options/options.test
Tests the 'options_buttons' widget (multiple select).

... See full list

Archivo

drupal-7.x/modules/field/tests/field.test, line 63
Tests for field.module.

Class

FieldTestCase
Parent class for Field API tests.

Código

function assertFieldValues($entity, $field_name, $langcode, $expected_values, $column = 'value') {
  $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)));
  }
}