1 field.test FieldTestCase::_generateTestFieldValues($cardinality)

Generate random values for a field_test field.

Parameters

$cardinality: Number of values to generate.

Return value

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

File

core/modules/field/tests/field.test, line 19
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;
}