function MigrateBundleTest::testDestinationBundle
Same name in other branches
- 9 core/modules/migrate/tests/src/Kernel/MigrateBundleTest.php \Drupal\Tests\migrate\Kernel\MigrateBundleTest::testDestinationBundle()
- 10 core/modules/migrate/tests/src/Kernel/MigrateBundleTest.php \Drupal\Tests\migrate\Kernel\MigrateBundleTest::testDestinationBundle()
- 11.x core/modules/migrate/tests/src/Kernel/MigrateBundleTest.php \Drupal\Tests\migrate\Kernel\MigrateBundleTest::testDestinationBundle()
Tests setting the bundle in the destination.
File
-
core/
modules/ migrate/ tests/ src/ Kernel/ MigrateBundleTest.php, line 40
Class
- MigrateBundleTest
- Tests setting of bundles on content entity migrations.
Namespace
Drupal\Tests\migrate\KernelCode
public function testDestinationBundle() {
$term_data_rows = [
[
'id' => 1,
'name' => 'Category 1',
],
];
$ids = [
'id' => [
'type' => 'integer',
],
];
$definition = [
'id' => 'terms',
'migration_tags' => [
'Bundle test',
],
'source' => [
'plugin' => 'embedded_data',
'data_rows' => $term_data_rows,
'ids' => $ids,
],
'process' => [
'tid' => 'id',
'name' => 'name',
],
'destination' => [
'plugin' => 'entity:taxonomy_term',
'default_bundle' => 'categories',
],
'migration_dependencies' => [],
];
$term_migration = \Drupal::service('plugin.manager.migration')->createStubMigration($definition);
// Import and validate the term entity was created with the correct bundle.
$term_executable = new MigrateExecutable($term_migration, $this);
$term_executable->import();
/** @var \Drupal\taxonomy\Entity\Term $term */
$term = Term::load(1);
$this->assertEquals($term->bundle(), 'categories');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.