You are here

function FieldTestCase::_generateTestFieldValues in Drupal 7

Generate random values for a field_test field.

Parameters

$cardinality: Number of values to generate.

Return value

An array of random values, in the format expected for field values.

14 calls to FieldTestCase::_generateTestFieldValues()
FieldAttachOtherTestCase::testFieldAttachCache in modules/field/tests/field.test
Test field cache.
FieldAttachOtherTestCase::testFieldAttachPrepareViewMultiple in modules/field/tests/field.test
Tests the 'multiple entity' behavior of field_attach_prepare_view().
FieldAttachOtherTestCase::testFieldAttachValidate in modules/field/tests/field.test
Test field_attach_validate().
FieldAttachOtherTestCase::testFieldAttachView in modules/field/tests/field.test
Test field_attach_view() and field_attach_prepare_view().
FieldAttachStorageTestCase::testFieldAttachCreateRenameBundle in modules/field/tests/field.test
Test field_attach_create_bundle() and field_attach_rename_bundle().

... See full list

File

modules/field/tests/field.test, line 38
Tests for field.module.

Class

FieldTestCase
Parent class for Field API tests.

Code

function _generateTestFieldValues($cardinality) {
  $values = array();
  for ($i = 0; $i < $cardinality; $i++) {

    // field_test fields treat 0 as 'empty value'.
    $values[$i]['value'] = mt_rand(1, 127);
  }
  return $values;
}