You are here

public function Pathautoi18nTaxonomyTest::createTaxonomyTerm in Pathauto i18n 8

Helper to create taxonomy term.

File

src/Tests/Pathautoi18nTaxonomyTest.php, line 98
Tests for the pathauto_i18n taxonomy module.

Class

Pathautoi18nTaxonomyTest
Pathauto i18n test functionality for taxonomy.

Namespace

Drupal\pathauto_i18n\Tests

Code

public function createTaxonomyTerm($pathauto_i18n_status, $pathauto, $alias = FALSE) {
  $vocabulary = taxonomy_vocabulary_machine_name_load(PATHAUTO_I18N_TAG_VOCABULARU_MACHINE_NAME);
  $term = new stdClass();
  $term->name = $this->title;
  $term->description = $this->title;

  // Use the first available text format.
  $term->format = db_query_range('SELECT format FROM {filter_format}', 0, 1)
    ->fetchField();
  $term->vid = $vocabulary->vid;
  $term->path = array(
    'pathauto_i18n_status' => $pathauto_i18n_status,
    'pathauto' => $pathauto,
  );
  if (!empty($alias)) {
    $term->path['alias'] = $alias;
  }
  taxonomy_term_save($term);
}