You are here

function state_flow_add_test_integer_field in State Machine 7.3

Install a simple integer field on the state_flow_history_entity with a minimum of 1 and a maximum of 10.

1 call to state_flow_add_test_integer_field()
StateFlowWebTestCase::_addintegerfield in modules/state_flow/tests/state_flow.test
Add a text field to the state flow history entity.

File

modules/state_flow/tests/state_flow.test.inc, line 169
Helper functions for tests.

Code

function state_flow_add_test_integer_field() {

  /**
  *  $field_config = field_info_field('field_sfhe_integer');
    dsm(var_export($field_config, TRUE));
  */
  $field_config = array(
    'translatable' => '0',
    'entity_types' => array(),
    'settings' => array(),
    'storage' => array(
      'type' => 'field_sql_storage',
      'settings' => array(),
      'module' => 'field_sql_storage',
      'active' => '1',
      'details' => array(
        'sql' => array(
          'FIELD_LOAD_CURRENT' => array(
            'field_data_field_sfhe_integer' => array(
              'value' => 'field_sfhe_integer_value',
            ),
          ),
          'FIELD_LOAD_REVISION' => array(
            'field_revision_field_sfhe_integer' => array(
              'value' => 'field_sfhe_integer_value',
            ),
          ),
        ),
      ),
    ),
    'foreign keys' => array(),
    'indexes' => array(),
    'id' => '5',
    'field_name' => 'field_sfhe_integer',
    'type' => 'number_integer',
    'module' => 'number',
    'active' => '1',
    'locked' => '0',
    'cardinality' => '1',
    'deleted' => '0',
    'columns' => array(
      'value' => array(
        'type' => 'int',
        'not null' => false,
      ),
    ),
    'bundles' => array(
      'state_flow_history_entity' => array(
        0 => 'state_flow_history_entity',
      ),
    ),
  );
  field_create_field($field_config);

  /**
   * The field_instance array was generated with this debug code.
   *
   * $field_instance = field_info_instance('state_flow_history_entity', 'field_sfhe_text', 'state_flow_history_entity');
   * dsm(var_export($field_instance, TRUE));
   */
  $field_instance = array(
    'label' => 'Test integer',
    'widget' => array(
      'weight' => '1',
      'type' => 'number',
      'module' => 'number',
      'active' => 0,
      'settings' => array(),
    ),
    'settings' => array(
      'min' => '1',
      'max' => '10',
      'prefix' => '',
      'suffix' => '',
      'user_register_form' => false,
    ),
    'display' => array(
      'default' => array(
        'label' => 'above',
        'type' => 'number_integer',
        'settings' => array(
          'thousand_separator' => ' ',
          'decimal_separator' => '.',
          'scale' => 0,
          'prefix_suffix' => true,
        ),
        'module' => 'number',
        'weight' => 0,
      ),
    ),
    'required' => 0,
    'description' => '',
    'default_value' => NULL,
    'id' => '7',
    'field_id' => '5',
    'field_name' => 'field_sfhe_integer',
    'entity_type' => 'state_flow_history_entity',
    'bundle' => 'state_flow_history_entity',
    'deleted' => '0',
  );
  field_create_instance($field_instance);
}