You are here

protected function EntityGenerateTest::setUp in Migrate Plus 8.3

Same name and namespace in other branches
  1. 8.5 tests/src/Kernel/Plugin/migrate/process/EntityGenerateTest.php \Drupal\Tests\migrate_plus\Kernel\Plugin\migrate\process\EntityGenerateTest::setUp()
  2. 8.4 tests/src/Kernel/Plugin/migrate/process/EntityGenerateTest.php \Drupal\Tests\migrate_plus\Kernel\Plugin\migrate\process\EntityGenerateTest::setUp()

Overrides KernelTestBase::setUp

File

tests/src/Kernel/Plugin/migrate/process/EntityGenerateTest.php, line 71

Class

EntityGenerateTest
Tests the migration plugin.

Namespace

Drupal\Tests\migrate_plus\Kernel\Plugin\migrate\process

Code

protected function setUp() {
  parent::setUp();

  // Create article content type.
  $values = [
    'type' => $this->bundle,
    'name' => 'Page',
  ];
  $node_type = NodeType::create($values);
  $node_type
    ->save();
  $this
    ->installEntitySchema('node');
  $this
    ->installEntitySchema('taxonomy_term');
  $this
    ->installEntitySchema('taxonomy_vocabulary');
  $this
    ->installEntitySchema('user');
  $this
    ->installSchema('system', [
    'sequences',
  ]);
  $this
    ->installSchema('user', 'users_data');
  $this
    ->installConfig($this->modules);

  // Create a vocabulary.
  $vocabulary = Vocabulary::create([
    'name' => $this->vocabulary,
    'description' => $this->vocabulary,
    'vid' => $this->vocabulary,
    'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
  ]);
  $vocabulary
    ->save();

  // Create a field.
  $this
    ->createEntityReferenceField('node', $this->bundle, $this->fieldName, 'Term reference', 'taxonomy_term', 'default', [
    'target_bundles' => [
      $this->vocabulary,
    ],
  ], FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED);
  $this->migrationPluginManager = \Drupal::service('plugin.manager.migration');
}