You are here

public function HelpTest::testHelp in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/help/src/Tests/HelpTest.php \Drupal\help\Tests\HelpTest::testHelp()

Logs in users, creates dblog events, and tests dblog functionality.

File

core/modules/help/src/Tests/HelpTest.php, line 57
Contains \Drupal\help\Tests\HelpTest.

Class

HelpTest
Verify help display and user access to help based on permissions.

Namespace

Drupal\help\Tests

Code

public function testHelp() {

  // Login the root user to ensure as many admin links appear as possible on
  // the module overview pages.
  $this
    ->drupalLogin($this->rootUser);
  $this
    ->verifyHelp();

  // Login the regular user.
  $this
    ->drupalLogin($this->anyUser);
  $this
    ->verifyHelp(403);

  // Verify that introductory help text exists, goes for 100% module coverage.
  $this
    ->drupalLogin($this->adminUser);
  $this
    ->drupalGet('admin/help');
  $this
    ->assertRaw(t('For more information, refer to the subjects listed in the Help Topics section or to the <a href=":docs">online documentation</a> and <a href=":support">support</a> pages at <a href=":drupal">drupal.org</a>.', array(
    ':docs' => 'https://www.drupal.org/documentation',
    ':support' => 'https://www.drupal.org/support',
    ':drupal' => 'https://www.drupal.org',
  )), 'Help intro text correctly appears.');

  // Verify that help topics text appears.
  $this
    ->assertRaw('<h2>' . t('Help topics') . '</h2><p>' . t('Help is available on the following items:') . '</p>', 'Help topics text correctly appears.');

  // Make sure links are properly added for modules implementing hook_help().
  foreach ($this
    ->getModuleList() as $module => $name) {
    $this
      ->assertLink($name, 0, format_string('Link properly added to @name (admin/help/@module)', array(
      '@module' => $module,
      '@name' => $name,
    )));
  }

  // Ensure that module which does not provide an module overview page is
  // handled correctly.
  $this
    ->clickLink(\Drupal::moduleHandler()
    ->getName('help_test'));
  $this
    ->assertRaw(t('No help is available for module %module.', array(
    '%module' => \Drupal::moduleHandler()
      ->getName('help_test'),
  )));
}