You are here

public function HtmlTitleViewsTest::testViewsIntegration in HTML Title 8

Tests the HTML Title views integration.

File

tests/src/Functional/HtmlTitleViewsTest.php, line 101

Class

HtmlTitleViewsTest
Tests the HTML Title integration with Views.

Namespace

Drupal\Tests\html_title\Functional

Code

public function testViewsIntegration() {
  $this
    ->drupalGet(Url::fromRoute('system.admin_content'));
  $assert_session = $this
    ->assertSession();
  $assert_session
    ->responseContains('Test <sup>sup</sup>-tag');
  $assert_session
    ->responseContains('Test <sup>sup</sup>-tag, <sub>sub</sub>-tag and <br>br-tag');
  $assert_session
    ->responseContains('Test <sup>sup</sup>-tag, <sub>sub</sub>-tag, <br>br-tag and p-tag');
  $assert_session
    ->responseNotContains('Test <p>p</p>-tag');
  $assert_session
    ->responseContains('Test p-tag');

  // Check that the node title is a link.
  $assert_session
    ->linkExists('Test p-tag');

  // Check that disabling the node title as a link still works.
  $this
    ->drupalGet(Url::fromRoute('entity.view.edit_form', [
    'view' => 'content',
  ]));
  $this
    ->clickLink('Content: Title (Title)');
  $this
    ->submitForm([
    'options[settings][link_to_entity]' => FALSE,
  ], 'Apply');
  $this
    ->submitForm([], 'Save');
  $this
    ->drupalGet(Url::fromRoute('system.admin_content'));
  $assert_session
    ->responseContains('Test <sup>sup</sup>-tag');
  $assert_session
    ->responseContains('Test <sup>sup</sup>-tag, <sub>sub</sub>-tag and <br>br-tag');
  $assert_session
    ->responseContains('Test <sup>sup</sup>-tag, <sub>sub</sub>-tag, <br>br-tag and p-tag');
  $assert_session
    ->responseNotContains('Test <p>p</p>-tag');
  $assert_session
    ->linkNotExists('Test p-tag');
}