diff -u b/core/modules/taxonomy/migration_templates/d6_i18n_taxonomy_term.yml b/core/modules/taxonomy/migration_templates/d6_i18n_taxonomy_term.yml --- b/core/modules/taxonomy/migration_templates/d6_i18n_taxonomy_term.yml +++ b/core/modules/taxonomy/migration_templates/d6_i18n_taxonomy_term.yml @@ -1,4 +1,4 @@ -id: d6_taxonomy_term +id: d6_i18n_taxonomy_term label: Taxonomy terms migration_tags: - Drupal 6 @@ -37,0 +38 @@ + - d6_taxonomy_term reverted: --- b/core/modules/taxonomy/migration_templates/d6_taxonomy_term.yml +++ a/core/modules/taxonomy/migration_templates/d6_taxonomy_term.yml @@ -1,4 +1,4 @@ +id: d6_taxonomy_term -id: d6_i18n_taxonomy_term label: Taxonomy terms migration_tags: - Drupal 6 diff -u b/core/modules/taxonomy/src/Plugin/migrate/source/d6/I18nTerm.php b/core/modules/taxonomy/src/Plugin/migrate/source/d6/I18nTerm.php --- b/core/modules/taxonomy/src/Plugin/migrate/source/d6/I18nTerm.php +++ b/core/modules/taxonomy/src/Plugin/migrate/source/d6/I18nTerm.php @@ -27,7 +27,7 @@ ->orderBy('td.tid'); if (isset($this->configuration['bundle'])) { - $query->condition('td.vid', (array) $this->configuration['bundle'], 'IN'); + $query->condition('td.vid', [$this->configuration['bundle']], 'IN'); } return $query; } diff -u b/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateI18nTaxonomyTermTest.php b/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateI18nTaxonomyTermTest.php --- b/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateI18nTaxonomyTermTest.php +++ b/core/modules/taxonomy/tests/src/Kernel/Migrate/d6/MigrateI18nTaxonomyTermTest.php @@ -86,19 +86,44 @@ $this->assertEquals($expected_description, $entity->getDescription()); $this->assertEquals($expected_format, $entity->getFormat()); $this->assertEquals($expected_weight, $entity->getWeight()); + $this->assertHierarchy($expected_vid, $id, $expected_parents); + } + + /** + * Assert that a term is present in the tree storage, with the right parents. + * + * @param string $vid + * Vocabulary ID. + * @param int $tid + * ID of the term to check. + * @param array $parent_ids + * The expected parent term IDs. + */ + protected function assertHierarchy($vid, $tid, array $parent_ids) { + if (!isset($this->treeData[$vid])) { + $tree = \Drupal::entityTypeManager()->getStorage('taxonomy_term')->loadTree($vid); + $this->treeData[$vid] = []; + foreach ($tree as $item) { + $this->treeData[$vid][$item->tid] = $item; + } + } + + $this->assertArrayHasKey($tid, $this->treeData[$vid], "Term $tid exists in taxonomy tree"); + $term = $this->treeData[$vid][$tid]; + $this->assertEquals($parent_ids, array_filter($term->parents), "Term $tid has correct parents in taxonomy tree"); } /** * Tests the Drupal 6 i18n taxonomy term to Drupal 8 migration. */ public function testI18nTaxonomyTerms() { - $this->assertEntity(1, 'zu', 'zu - term 1 of vocabulary 1', 'vocabulary_1_i_0_', 'zu - description of term 1 of vocabulary 1', NULL, 0); - $this->assertEntity(2, 'fr', 'fr - term 2 of vocabulary 2', 'vocabulary_2_i_1_', 'fr - description of term 2 of vocabulary 2', NULL, 3); - $this->assertEntity(3, 'fr', 'fr - term 3 of vocabulary 2', 'vocabulary_2_i_1_', 'fr - description of term 3 of vocabulary 2', NULL, 4); - $this->assertEntity(4, 'en', 'term 4 of vocabulary 3', 'vocabulary_3_i_2_', 'description of term 4 of vocabulary 3', NULL, 6); - $this->assertEntity(5, 'en', 'term 5 of vocabulary 3', 'vocabulary_3_i_2_', 'description of term 5 of vocabulary 3', NULL, 7); - $this->assertEntity(6, 'en', 'term 6 of vocabulary 3', 'vocabulary_3_i_2_', 'description of term 6 of vocabulary 3', NULL, 8); - $this->assertEntity(7, 'fr', 'fr - term 2 of vocabulary 1', 'vocabulary_1_i_0_', 'fr - desc of term 2 vocab 1', NULL, 0); + $this->assertEntity(1, 'zu', 'zu - term 1 of vocabulary 1', 'vocabulary_1_i_0_', 'zu - description of term 1 of vocabulary 1', NULL, 0, []); + $this->assertEntity(2, 'fr', 'fr - term 2 of vocabulary 2', 'vocabulary_2_i_1_', 'fr - description of term 2 of vocabulary 2', NULL, 3, []); + $this->assertEntity(3, 'fr', 'fr - term 3 of vocabulary 2', 'vocabulary_2_i_1_', 'fr - description of term 3 of vocabulary 2', NULL, 4, ['2']); + $this->assertEntity(4, 'en', 'term 4 of vocabulary 3', 'vocabulary_3_i_2_', 'description of term 4 of vocabulary 3', NULL, 6, []); + $this->assertEntity(5, 'en', 'term 5 of vocabulary 3', 'vocabulary_3_i_2_', 'description of term 5 of vocabulary 3', NULL, 7, ['4']); + $this->assertEntity(6, 'en', 'term 6 of vocabulary 3', 'vocabulary_3_i_2_', 'description of term 6 of vocabulary 3', NULL, 8, ['4', '5']); + $this->assertEntity(7, 'fr', 'fr - term 2 of vocabulary 1', 'vocabulary_1_i_0_', 'fr - desc of term 2 vocab 1', NULL, 0, []); } }