You are here

public function HtmlTitleTest::testBreadcrumbBlock in HTML Title 8

Tests the breadcrumb block in combination with HTML Title.

File

tests/src/Functional/HtmlTitleTest.php, line 189

Class

HtmlTitleTest
Tests the HTML Title module.

Namespace

Drupal\Tests\html_title\Functional

Code

public function testBreadcrumbBlock() {
  $assert_session = $this
    ->assertSession();
  $this
    ->drupalGet($this->node1
    ->toUrl());
  $element = $assert_session
    ->elementExists('css', 'nav[role="navigation"] ol li:last-child');
  $this
    ->assertEquals('Test <sup>sup</sup>-tag', trim($element
    ->getHtml()));
  $this
    ->drupalGet($this->node2
    ->toUrl());
  $element = $assert_session
    ->elementExists('css', 'nav[role="navigation"] ol li:nth-child(2) a');
  $this
    ->assertEquals('Test <sup>sup</sup>-tag', trim($element
    ->getHtml()));
  $element = $assert_session
    ->elementExists('css', 'nav[role="navigation"] ol li:last-child');
  $this
    ->assertEquals('Test <sup>sup</sup>-tag, <sub>sub</sub>-tag and <br>br-tag', trim($element
    ->getHtml()));
  $this
    ->drupalGet($this->node3
    ->toUrl());
  $element = $assert_session
    ->elementExists('css', 'nav[role="navigation"] ol li:last-child');
  $this
    ->assertEquals('Test <sup>sup</sup>-tag, <sub>sub</sub>-tag, <br>br-tag and p-tag', trim($element
    ->getHtml()));

  // Check that translations still work.
  $this
    ->drupalGet('fr/node/' . $this->node3
    ->id());
  $element = $assert_session
    ->elementExists('css', 'nav[role="navigation"] ol li:last-child');
  $this
    ->assertEquals('Test <sup>sup</sup>-tag, <sub>sub</sub>-tag, <br>br-tag and p-tag FR', trim($element
    ->getHtml()));
  $this
    ->drupalGet($this->node4
    ->toUrl());
  $element = $assert_session
    ->elementExists('css', 'nav[role="navigation"] ol li:last-child');
  $this
    ->assertEquals('Test p-tag', trim($element
    ->getHtml()));
}