function TaxonomyTestBase::createTerm

Same name in this branch
  1. 9.x drupal/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TaxonomyTestBase.php \Drupal\taxonomy\Tests\TaxonomyTestBase::createTerm()
  2. 9.x drupal/core/modules/views/lib/Drupal/views/Tests/Taxonomy/TaxonomyTestBase.php \Drupal\views\Tests\Taxonomy\TaxonomyTestBase::createTerm()

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

21 calls to TaxonomyTestBase::createTerm()
EfqTest::testTaxonomyEfq in drupal/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/EfqTest.php
Tests that a basic taxonomy entity query works.
LoadMultipleTest::testTaxonomyTermMultipleLoad in drupal/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/LoadMultipleTest.php
Create a vocabulary and some taxonomy terms, ensuring they're loaded correctly using taxonomy_term_load_multiple().
MappingDefinitionTest::testTaxonomyTermRdfaAttributes in drupal/core/modules/rdf/lib/Drupal/rdf/Tests/MappingDefinitionTest.php
Creates a random term and ensures the right RDFa markup is used.
RssTest::testTaxonomyRss in drupal/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/RssTest.php
Tests that terms added to nodes are displayed in core RSS feed.
TermFieldMultipleVocabularyTest::testTaxonomyTermFieldMultipleVocabularies in drupal/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermFieldMultipleVocabularyTest.php
Tests term reference field and widget with multiple vocabularies.

... See full list

File

drupal/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TaxonomyTestBase.php, line 54
Definition of Drupal\taxonomy\Tests\TaxonomyTestBase.

Class

TaxonomyTestBase
Provides common helper methods for Taxonomy module tests.

Namespace

Drupal\taxonomy\Tests

Code

function createTerm($vocabulary) {
  $term = entity_create('taxonomy_term', array(
    'name' => $this
      ->randomName(),
    'description' => $this
      ->randomName(),
    // Use the first available text format.
    'format' => db_query_range('SELECT format FROM {filter_format}', 0, 1)
      ->fetchField(),
    'vid' => $vocabulary->vid,
    'langcode' => LANGUAGE_NOT_SPECIFIED,
  ));
  taxonomy_term_save($term);
  return $term;
}