public function TermTest::testTermBreadcrumbs in Drupal 8
Same name and namespace in other branches
- 9 core/modules/taxonomy/tests/src/Functional/TermTest.php \Drupal\Tests\taxonomy\Functional\TermTest::testTermBreadcrumbs()
Check the breadcrumb on edit and delete a term page.
File
- core/
modules/ taxonomy/ tests/ src/ Functional/ TermTest.php, line 587
Class
- TermTest
- Tests load, save and delete for taxonomy terms.
Namespace
Drupal\Tests\taxonomy\FunctionalCode
public function testTermBreadcrumbs() {
$edit = [
'name[0][value]' => $this
->randomMachineName(14),
'description[0][value]' => $this
->randomMachineName(100),
'parent[]' => [
0,
],
];
// Create the term.
$this
->drupalPostForm('admin/structure/taxonomy/manage/' . $this->vocabulary
->id() . '/add', $edit, 'Save');
$terms = taxonomy_term_load_multiple_by_name($edit['name[0][value]']);
$term = reset($terms);
$this
->assertNotNull($term, 'Term found in database.');
// Check the breadcrumb on the term edit page.
$this
->drupalGet('taxonomy/term/' . $term
->id() . '/edit');
$breadcrumbs = $this
->getSession()
->getPage()
->findAll('css', 'nav.breadcrumb ol li a');
$this
->assertCount(2, $breadcrumbs, 'The breadcrumbs are present on the page.');
$this
->assertIdentical($breadcrumbs[0]
->getText(), 'Home', 'First breadcrumb text is Home');
$this
->assertIdentical($breadcrumbs[1]
->getText(), $term
->label(), 'Second breadcrumb text is term name on term edit page.');
$this
->assertEscaped($breadcrumbs[1]
->getText());
// Check the breadcrumb on the term delete page.
$this
->drupalGet('taxonomy/term/' . $term
->id() . '/delete');
$breadcrumbs = $this
->getSession()
->getPage()
->findAll('css', 'nav.breadcrumb ol li a');
$this
->assertCount(2, $breadcrumbs, 'The breadcrumbs are present on the page.');
$this
->assertIdentical($breadcrumbs[0]
->getText(), 'Home', 'First breadcrumb text is Home');
$this
->assertIdentical($breadcrumbs[1]
->getText(), $term
->label(), 'Second breadcrumb text is term name on term delete page.');
$this
->assertEscaped($breadcrumbs[1]
->getText());
}