You are here

protected function CsvTestBase::createVocabularies in Commerce Migrate 3.1.x

Same name and namespace in other branches
  1. 8.2 tests/src/Kernel/CsvTestBase.php \Drupal\Tests\commerce_migrate\Kernel\CsvTestBase::createVocabularies()
  2. 3.0.x tests/src/Kernel/CsvTestBase.php \Drupal\Tests\commerce_migrate\Kernel\CsvTestBase::createVocabularies()

Creates vocabularies.

Parameters

array $vids: An array of vocabulary ids.

2 calls to CsvTestBase::createVocabularies()
ProductTest::setUp in modules/csv_example/tests/src/Kernel/Migrate/ProductTest.php
TaxonomyTermTest::setUp in modules/csv_example/tests/src/Kernel/Migrate/TaxonomyTermTest.php

File

tests/src/Kernel/CsvTestBase.php, line 157

Class

CsvTestBase
Test base for migrations tests with CSV source file.

Namespace

Drupal\Tests\commerce_migrate\Kernel

Code

protected function createVocabularies(array $vids) {
  if (is_array($vids)) {
    foreach ($vids as $vid) {
      $vocabulary = Vocabulary::create([
        'name' => $vid,
        'description' => $this
          ->randomMachineName(),
        'vid' => mb_strtolower($vid),
        'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
        'weight' => mt_rand(0, 10),
      ]);
      $vocabulary
        ->save();
    }
  }
}