You are here

function TaxonomyTestTrait::createVocabulary in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/taxonomy/src/Tests/TaxonomyTestTrait.php \Drupal\taxonomy\Tests\TaxonomyTestTrait::createVocabulary()

Returns a new vocabulary with random properties.

26 calls to TaxonomyTestTrait::createVocabulary()
EfqTest::setUp in core/modules/taxonomy/src/Tests/EfqTest.php
Sets up a Drupal site for running functional and integration tests.
EfqTest::testTaxonomyEfq in core/modules/taxonomy/src/Tests/EfqTest.php
Tests that a basic taxonomy entity query works.
EntityReferenceFieldAttributesTest::setUp in core/modules/rdf/src/Tests/EntityReferenceFieldAttributesTest.php
Sets up a Drupal site for running functional and integration tests.
LoadMultipleTest::testTaxonomyTermMultipleLoad in core/modules/taxonomy/src/Tests/LoadMultipleTest.php
Create a vocabulary and some taxonomy terms, ensuring they're loaded correctly using entity_load_multiple().
RssTest::setUp in core/modules/taxonomy/src/Tests/RssTest.php
Sets up a Drupal site for running functional and integration tests.

... See full list

File

core/modules/taxonomy/src/Tests/TaxonomyTestTrait.php, line 22
Contains \Drupal\taxonomy\Tests\TaxonomyTestTrait.

Class

TaxonomyTestTrait
Provides common helper methods for Taxonomy module tests.

Namespace

Drupal\taxonomy\Tests

Code

function createVocabulary() {

  // Create a vocabulary.
  $vocabulary = entity_create('taxonomy_vocabulary', array(
    'name' => $this
      ->randomMachineName(),
    'description' => $this
      ->randomMachineName(),
    'vid' => Unicode::strtolower($this
      ->randomMachineName()),
    'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
    'weight' => mt_rand(0, 10),
  ));
  $vocabulary
    ->save();
  return $vocabulary;
}