You are here

protected function HelpTest::verifyHelp 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::verifyHelp()

Verifies the logged in user has access to the various help nodes.

Parameters

integer $response: An HTTP response code.

1 call to HelpTest::verifyHelp()
HelpTest::testHelp in core/modules/help/src/Tests/HelpTest.php
Logs in users, creates dblog events, and tests dblog functionality.

File

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

Class

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

Namespace

Drupal\help\Tests

Code

protected function verifyHelp($response = 200) {
  $this
    ->drupalGet('admin/index');
  $this
    ->assertResponse($response);
  if ($response == 200) {
    $this
      ->assertText('This page shows you all available administration tasks for each module.');
  }
  else {
    $this
      ->assertNoText('This page shows you all available administration tasks for each module.');
  }
  foreach ($this
    ->getModuleList() as $module => $name) {

    // View module help node.
    $this
      ->drupalGet('admin/help/' . $module);
    $this
      ->assertResponse($response);
    if ($response == 200) {
      $this
        ->assertTitle($name . ' | Drupal', format_string('%module title was displayed', array(
        '%module' => $module,
      )));
      $this
        ->assertEqual($this
        ->cssSelect('h1.page-title')[0], t($name), format_string('%module heading was displayed', array(
        '%module' => $module,
      )));
      $admin_tasks = system_get_module_admin_tasks($module, system_get_info('module', $module));
      if (!empty($admin_tasks)) {
        $this
          ->assertText(t('@module administration pages', array(
          '@module' => $name,
        )));
      }
      foreach ($admin_tasks as $task) {
        $this
          ->assertLink($task['title']);

        // Ensure there are no double escaped '&' or '<' characters.
        $this
          ->assertNoEscaped('&amp;', 'The help text does not have double escaped &amp;.');
        $this
          ->assertNoEscaped('&lt;', 'The help text does not have double escaped &lt;.');

        // Ensure there are no escaped '<' characters.
        $this
          ->assertNoEscaped('<', 'The help text does not have single escaped &lt;.');
      }

      // Ensure there are no double escaped '&' or '<' characters.
      $this
        ->assertNoEscaped('&amp;');
      $this
        ->assertNoEscaped('&lt;');

      // Ensure there are no escaped '<' characters.
      $this
        ->assertNoEscaped('<');
    }
  }
}