protected function MigrateTaxonomyTermTranslationTest::assertHierarchy in Drupal 10
Same name in this branch
- 10 core/modules/content_translation/tests/src/Kernel/Migrate/d6/MigrateTaxonomyTermTranslationTest.php \Drupal\Tests\content_translation\Kernel\Migrate\d6\MigrateTaxonomyTermTranslationTest::assertHierarchy()
- 10 core/modules/taxonomy/tests/src/Kernel/Migrate/d7/MigrateTaxonomyTermTranslationTest.php \Drupal\Tests\taxonomy\Kernel\Migrate\d7\MigrateTaxonomyTermTranslationTest::assertHierarchy()
Same name and namespace in other branches
- 8 core/modules/taxonomy/tests/src/Kernel/Migrate/d7/MigrateTaxonomyTermTranslationTest.php \Drupal\Tests\taxonomy\Kernel\Migrate\d7\MigrateTaxonomyTermTranslationTest::assertHierarchy()
- 9 core/modules/taxonomy/tests/src/Kernel/Migrate/d7/MigrateTaxonomyTermTranslationTest.php \Drupal\Tests\taxonomy\Kernel\Migrate\d7\MigrateTaxonomyTermTranslationTest::assertHierarchy()
Asserts that a term is present in the tree storage, with the right parents.
@internal
Parameters
string $vid: Vocabulary ID.
int $tid: ID of the term to check.
array $parent_ids: The expected parent term IDs.
1 call to MigrateTaxonomyTermTranslationTest::assertHierarchy()
- MigrateTaxonomyTermTranslationTest::assertEntity in core/
modules/ taxonomy/ tests/ src/ Kernel/ Migrate/ d7/ MigrateTaxonomyTermTranslationTest.php - Validates a migrated term contains the expected values.
File
- core/
modules/ taxonomy/ tests/ src/ Kernel/ Migrate/ d7/ MigrateTaxonomyTermTranslationTest.php, line 114
Class
- MigrateTaxonomyTermTranslationTest
- Test migration of translated taxonomy terms.
Namespace
Drupal\Tests\taxonomy\Kernel\Migrate\d7Code
protected function assertHierarchy(string $vid, int $tid, array $parent_ids) : void {
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");
}