protected function RequiredByRoleCommonWebTestCase::createOptionsField in Required by role 7
1 call to RequiredByRoleCommonWebTestCase::createOptionsField()
- RequiredByRoleCommonWebTestCase::setUp in tests/
required_by_role_test/ RequiredByRoleCommonWebTestCase.test - Setup method.
File
- tests/
required_by_role_test/ RequiredByRoleCommonWebTestCase.test, line 125 - Tests for the common cases.
Class
- RequiredByRoleCommonWebTestCase
- @file Tests for the common cases.
Code
protected function createOptionsField($bundle = NULL) {
$node_type = $bundle ? $bundle : $this->entity_bundle;
// Field with cardinality 0.
$this->options_field = array(
'field_name' => 'options_field',
'type' => 'list_integer',
'cardinality' => $this->optionsFieldCardinality,
'settings' => array(
'allowed_values' => array(
1 => 'One',
2 => 'Two',
),
),
);
$this->options_field = field_create_field($this->options_field);
$rid = (int) $this->required_fields_rid;
// Create an instance of the 'single value' field.
$instance = array(
'field_name' => $this->options_field['field_name'],
'entity_type' => $this->entity_type,
'bundle' => $node_type,
'settings' => array(
'required_by_role' => array(
$rid => $rid,
),
),
'widget' => array(
'type' => 'options_select',
),
);
$instance = field_create_instance($instance);
}