public function RelationAddTestCase::createRelationAddFieldWithInstance in Relation add 7
Create a demo text field and an instance of it.
1 call to RelationAddTestCase::createRelationAddFieldWithInstance()
- RelationAddTestCase::setUp in tests/
relation_add.test - Setup.
File
- tests/
relation_add.test, line 50 - Tests for Relation Add module.
Class
- RelationAddTestCase
- Tests Relation Add.
Code
public function createRelationAddFieldWithInstance($entity, $bundle, $field_name, $relation_types) {
// Setup a field and instance.
$this->field_name = $field_name;
$this->field = array(
'field_name' => $this->field_name,
'type' => 'relation_add',
);
field_create_field($this->field);
$this->instance = array(
'field_name' => $this->field_name,
'entity_type' => $entity,
'bundle' => $bundle,
'label' => $this
->randomName() . '_label',
'settings' => array(
'relation_type' => $relation_types,
),
'widget' => array(
'type' => 'relation_add',
'settings' => array(
'relation_endpoint_label' => 'endpoint',
'relation_endpoint_custom_label' => '',
'relation_endpoint_label_delta' => '',
'relation_endpoint_search_by_id' => '',
),
),
'display' => array(
'full' => array(
'type' => 'text_default',
),
),
);
field_create_instance($this->instance);
}