You are here

function FieldTestBase::_generateTestFieldValues in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/field/src/Tests/FieldTestBase.php \Drupal\field\Tests\FieldTestBase::_generateTestFieldValues()

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.

File

core/modules/field/src/Tests/FieldTestBase.php, line 27
Contains \Drupal\field\Tests\FieldTestBase.

Class

FieldTestBase
Parent class for Field API tests.

Namespace

Drupal\field\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;
}