public function CatalogBreadcrumbTest::testCatalogBreadcrumb in Ubercart 8.4
Tests the catalog view breadcrumb.
File
- uc_catalog/
tests/ src/ Functional/ CatalogBreadcrumbTest.php, line 52
Class
- CatalogBreadcrumbTest
- Tests for the Ubercart catalog breadcrumbs.
Namespace
Drupal\Tests\uc_catalog\FunctionalCode
public function testCatalogBreadcrumb() {
$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('catalog');
$this
->clickLink($grandparent
->label());
$this
->clickLink($parent
->label());
$this
->clickLink($term
->label());
// 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(4, $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]);
}