function HelpTest::verifyHelp

Same name in other branches
  1. 9 core/modules/help/tests/src/Functional/HelpTest.php \Drupal\Tests\help\Functional\HelpTest::verifyHelp()
  2. 10 core/modules/help/tests/src/Functional/HelpTest.php \Drupal\Tests\help\Functional\HelpTest::verifyHelp()
  3. 11.x core/modules/help/tests/src/Functional/HelpTest.php \Drupal\Tests\help\Functional\HelpTest::verifyHelp()

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

Parameters

int $response: (optional) An HTTP response code. Defaults to 200.

1 call to HelpTest::verifyHelp()
HelpTest::testHelp in core/modules/help/tests/src/Functional/HelpTest.php
Logs in users, tests help pages.

File

core/modules/help/tests/src/Functional/HelpTest.php, line 119

Class

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

Namespace

Drupal\Tests\help\Functional

Code

protected function verifyHelp($response = 200) {
    $this->drupalGet('admin/index');
    $this->assertSession()
        ->statusCodeEquals($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 page.
        $this->drupalGet('admin/help/' . $module);
        $this->assertSession()
            ->statusCodeEquals($response);
        if ($response == 200) {
            $this->assertTitle("{$name} | Drupal");
            $this->assertEquals($name, $this->cssSelect('h1.page-title')[0]
                ->getText(), "{$module} heading was displayed");
            $info = \Drupal::service('extension.list.module')->getExtensionInfo($module);
            $admin_tasks = system_get_module_admin_tasks($module, $info);
            if (!empty($admin_tasks)) {
                $this->assertText(t('@module administration pages', [
                    '@module' => $name,
                ]));
            }
            foreach ($admin_tasks as $task) {
                $this->assertSession()
                    ->linkExists($task['title']);
                // Ensure there are no double escaped '&' or '<' characters.
                $this->assertNoEscaped('&amp;');
                $this->assertNoEscaped('&lt;');
                // Ensure there are no escaped '<' characters.
                $this->assertNoEscaped('<');
            }
            // Ensure there are no double escaped '&' or '<' characters.
            $this->assertNoEscaped('&amp;');
            $this->assertNoEscaped('&lt;');
            // Ensure there are no escaped '<' characters.
            $this->assertNoEscaped('<');
        }
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.