function TermHierarchyTest::testTaxonomyTermHierarchyBreadcrumbs
Tests that there is a link to the parent term on the child term page.
File
-
core/
modules/ taxonomy/ tests/ src/ Kernel/ TermHierarchyTest.php, line 67
Class
- TermHierarchyTest
- Tests term hierarchy.
Namespace
Drupal\Tests\taxonomy\KernelCode
public function testTaxonomyTermHierarchyBreadcrumbs() : void {
$vocabulary = $this->createVocabulary();
// Create two taxonomy terms and set term2 as the parent of term1.
$term1 = $this->createTerm($vocabulary);
$term2 = $this->createTerm($vocabulary);
$term1->parent = [
$term2->id(),
];
$term1->save();
// Verify that the page breadcrumbs include a link to the parent term.
$this->drupalGet('taxonomy/term/' . $term1->id());
// Breadcrumbs are not rendered with a language, prevent the term
// language from being added to the options.
// Check that parent term link is displayed when viewing the node.
$this->assertSession()
->responseContains(Link::fromTextAndUrl($term2->getName(), $term2->toUrl('canonical', [
'language' => NULL,
]))
->toString());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.