You are here

public function EntityAutocompleteWebTestCase::createTerm in Entity Autocomplete 7

Returns a new term with random properties in vocabulary $vid.

1 call to EntityAutocompleteWebTestCase::createTerm()
EntityAutocompleteWebTestCase::testEntityAutocompleteCallback in tests/entity_autocomplete.test
Tests autocomplete callback.

File

tests/entity_autocomplete.test, line 69
Tests suite for Entity Autocomplete module.

Class

EntityAutocompleteWebTestCase
Performs functional tests on advanced functionalities, such as administrative UI, etc.

Code

public function createTerm($vocabulary, $settings = array()) {
  static $format;
  if (!isset($format)) {

    // Use the first available text format.
    $format = db_query_range('SELECT format FROM {filter_format}', 0, 1)
      ->fetchField();
  }
  $settings += array(
    'name' => $this
      ->randomName(),
    'description' => $this
      ->randomName(),
    'format' => $format,
    'vid' => $vocabulary->vid,
    'weight' => mt_rand(0, 10),
  );
  $settings = (object) $settings;
  taxonomy_term_save($settings);
  return $settings;
}