function TaxonomyTestBase::createTerm

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

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

22 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().
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.
TaxonomyAttributesTest::testTaxonomyTermRdfaAttributes in drupal/core/modules/rdf/lib/Drupal/rdf/Tests/TaxonomyAttributesTest.php
Creates a random term and ensures the RDF output is correct.
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 53
Definition of Drupal\taxonomy\Tests\TaxonomyTestBase.

Class

TaxonomyTestBase
Provides common helper methods for Taxonomy module tests.

Namespace

Drupal\taxonomy\Tests

Code

function createTerm($vocabulary) {
  $filter_formats = filter_formats();
  $format = array_pop($filter_formats);
  $term = entity_create('taxonomy_term', array(
    'name' => $this
      ->randomName(),
    'description' => $this
      ->randomName(),
    // Use the first available text format.
    'format' => $format->format,
    'vid' => $vocabulary
      ->id(),
    'langcode' => Language::LANGCODE_NOT_SPECIFIED,
  ));
  $term
    ->save();
  return $term;
}