public function CatalogBreadcrumbTest::testProductBreadcrumb in Ubercart 8.4
Tests the product node breadcrumb.
File
- uc_catalog/
tests/ src/ Functional/ CatalogBreadcrumbTest.php, line 23
Class
- CatalogBreadcrumbTest
- Tests for the Ubercart catalog breadcrumbs.
Namespace
Drupal\Tests\uc_catalog\FunctionalCode
public function testProductBreadcrumb() {
$this
->drupalLogin($this->adminUser);
$grandparent = $this
->createCatalogTerm();
$parent = $this
->createCatalogTerm([
'parent' => $grandparent
->id(),
]);
$term = $this
->createCatalogTerm([
'parent' => $parent
->id(),
]);
$product = $this
->createProduct([
'taxonomy_catalog' => [
$term
->id(),
],
]);
$this
->drupalGet($product
->toUrl());
// Fetch each node title in the current breadcrumb.
$links = $this
->xpath('//nav[@class="breadcrumb"]/ol/li/a');
$func = function ($element) {
return $element
->getText();
};
$links = array_map($func, $links);
$this
->assertCount(5, $links, 'The correct number of links were found.');
$this
->assertEquals('Home', $links[0]);
$this
->assertEquals('Catalog', $links[1]);
$this
->assertEquals($grandparent
->label(), $links[2]);
$this
->assertEquals($parent
->label(), $links[3]);
$this
->assertEquals($term
->label(), $links[4]);
}