// Check that hierarchy is flat.
$this->
assertEquals(0,
$taxonomy_storage->
getVocabularyHierarchyType($this->vocabulary->
id()), 'Vocabulary is flat.'
);
// Edit $term2, setting $term1 as parent.
$edit =
[];
$edit['parent[]'
] =
[$term1->
id()];
$this->
drupalGet('taxonomy/term/' .
$term2->
id() . '/edit'
);
$this->
submitForm($edit, 'Save'
);
// Check the hierarchy.
$children =
$taxonomy_storage->
loadChildren($term1->
id());
$parents =
$taxonomy_storage->
loadParents($term2->
id());
$this->
assertTrue(isset($children[$term2->
id()]), 'Child found correctly.'
);
$this->
assertTrue(isset($parents[$term1->
id()]), 'Parent found correctly.'
);
// Load and save a term, confirming that parents are still set.
$term = Term::
load($term2->
id());
$term->
save();
$parents =
$taxonomy_storage->
loadParents($term2->
id());
$this->
assertTrue(isset($parents[$term1->
id()]), 'Parent found correctly.'
);
// Create a third term and save this as a parent of term2.