You are here

protected function HelpTopicTest::verifyHelpLinks in Drupal 8

Verifies links on the test help topic page and other pages.

Assumes an admin user is logged in.

1 call to HelpTopicTest::verifyHelpLinks()
HelpTopicTest::testHelp in core/modules/help_topics/tests/src/Functional/HelpTopicTest.php
Tests the main help page and individual pages for topics.

File

core/modules/help_topics/tests/src/Functional/HelpTopicTest.php, line 174

Class

HelpTopicTest
Verifies help topic display and user access to help based on permissions.

Namespace

Drupal\Tests\help_topics\Functional

Code

protected function verifyHelpLinks() {
  $session = $this
    ->assertSession();

  // Verify links on the test top-level page.
  $page = 'admin/help/topic/help_topics_test.test';
  $links = [
    'link to the additional topic' => 'Additional topic',
    'Linked topic' => 'This topic is not supposed to be top-level',
    'Additional topic' => 'This topic should get listed automatically',
  ];
  foreach ($links as $link_text => $page_text) {
    $this
      ->drupalGet($page);
    $this
      ->clickLink($link_text);
    $session
      ->pageTextContains($page_text);
  }

  // Verify theme provided help topics work and can be related.
  $this
    ->drupalGet('admin/help/topic/help_topics_test_theme.test');
  $session
    ->pageTextContains('This is a theme provided topic.');
  $this
    ->assertStringContainsString('This is a theme provided topic.', $session
    ->elementExists('css', 'article')
    ->getText());
  $this
    ->clickLink('Additional topic');
  $session
    ->linkExists('XYZ Help Test theme');

  // Verify that the non-top-level topics do not appear on the Help page.
  $this
    ->drupalGet('admin/help');
  $session
    ->linkNotExists('Linked topic');
  $session
    ->linkNotExists('Additional topic');
}