protected function FieldUnitTestBase::_generateTestFieldValues in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/field/src/Tests/FieldUnitTestBase.php \Drupal\field\Tests\FieldUnitTestBase::_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.
12 calls to FieldUnitTestBase::_generateTestFieldValues()
- BulkDeleteTest::setUp in core/
modules/ field/ src/ Tests/ BulkDeleteTest.php - Set the default field storage backend for fields created during tests.
- DisplayApiTest::setUp in core/
modules/ field/ src/ Tests/ DisplayApiTest.php - Set the default field storage backend for fields created during tests.
- FieldAttachOtherTest::testEntityCache in core/
modules/ field/ src/ Tests/ FieldAttachOtherTest.php - Test entity cache.
- FieldAttachOtherTest::testEntityDisplayBuild in core/
modules/ field/ src/ Tests/ FieldAttachOtherTest.php - Test rendering fields with EntityDisplay build().
- FieldAttachOtherTest::testEntityDisplayViewMultiple in core/
modules/ field/ src/ Tests/ FieldAttachOtherTest.php - Tests rendering fields with EntityDisplay::buildMultiple().
File
- core/
modules/ field/ src/ Tests/ FieldUnitTestBase.php, line 166 - Contains \Drupal\field\Tests\FieldUnitTestBase.
Class
- FieldUnitTestBase
- Parent class for Field API unit tests.
Namespace
Drupal\field\TestsCode
protected 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;
}