You are here

function ABTWebTestCase::createFields in Access By Term 7

1 call to ABTWebTestCase::createFields()
ABTWebTestCase::setUpContentStructure in ./abt.test

File

./abt.test, line 73

Class

ABTWebTestCase

Code

function createFields($number_of_fields = 3) {
  $fields = array();
  $vocs = isset($this->vocabularies) ? $this->vocabularies : array(
    (object) array(
      'machine_name' => 'no_voc',
    ),
  );
  $voc_index = 0;
  for ($i = 0; $i < $number_of_fields; $i++) {
    if ($i >= count($vocs)) {
      $voc_index = 0;
    }
    $field = array(
      'field_name' => drupal_strtolower($this
        ->randomName() . '_field_name'),
      'type' => 'taxonomy_term_reference',
      'cardinality' => FIELD_CARDINALITY_UNLIMITED,
      'settings' => array(
        'allowed_values' => array(
          array(
            'vocabulary' => $vocs[$voc_index]->machine_name,
            'parent' => 0,
          ),
        ),
      ),
    );
    field_create_field($field);
    $fields[$i] = $field;
  }
  return $fields;
}