protected function FieldCollectionRulesIntegrationTestCase::createFields in Field collection 7
2 calls to FieldCollectionRulesIntegrationTestCase::createFields()
- FieldCollectionRulesIntegrationTestCase::testCreation in ./
field_collection.test - Test creation field collection items.
- FieldCollectionRulesIntegrationTestCase::testUsageDuringCreation in ./
field_collection.test - Test using field collection items via the host while they are being created.
File
- ./
field_collection.test, line 465 - Tests for field_collections.
Class
- FieldCollectionRulesIntegrationTestCase
- Test using field collection with Rules.
Code
protected function createFields($cardinality = 4) {
// Create a field_collection field to use for the tests.
$this->field_name = 'field_test_collection';
$this->field = array(
'field_name' => $this->field_name,
'type' => 'field_collection',
'cardinality' => $cardinality,
);
$this->field = field_create_field($this->field);
$this->field_id = $this->field['id'];
$this->instance = array(
'field_name' => $this->field_name,
'entity_type' => 'node',
'bundle' => 'article',
'label' => self::randomName() . '_label',
'description' => self::randomName() . '_description',
'weight' => random_int(0, 127),
'settings' => array(),
'widget' => array(
'type' => 'hidden',
'label' => 'Test',
'settings' => array(),
),
);
$this->instance = field_create_instance($this->instance);
// Add a field to the collection.
$field = array(
'field_name' => 'field_text',
'type' => 'text',
'cardinality' => 1,
'translatable' => FALSE,
);
field_create_field($field);
$instance = array(
'entity_type' => 'field_collection_item',
'field_name' => 'field_text',
'bundle' => $this->field_name,
'label' => 'Test text field',
'widget' => array(
'type' => 'text_textfield',
),
);
field_create_instance($instance);
}