protected function HelpTest::verifyHelp in Drupal 10
Same name and namespace in other branches
- 8 core/modules/help/tests/src/Functional/HelpTest.php \Drupal\Tests\help\Functional\HelpTest::verifyHelp()
- 9 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.
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\FunctionalCode
protected function verifyHelp($response = 200) {
$this
->drupalGet('admin/index');
$this
->assertSession()
->statusCodeEquals($response);
if ($response == 200) {
$this
->assertSession()
->pageTextContains('This page shows you all available administration tasks for each module.');
}
else {
$this
->assertSession()
->pageTextNotContains('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
->assertSession()
->titleEquals("{$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
->assertSession()
->pageTextContains($name . ' administration pages');
}
foreach ($admin_tasks as $task) {
$this
->assertSession()
->linkExists($task['title']);
// Ensure there are no double escaped '&' or '<' characters.
$this
->assertSession()
->assertNoEscaped('&');
$this
->assertSession()
->assertNoEscaped('<');
// Ensure there are no escaped '<' characters.
$this
->assertSession()
->assertNoEscaped('<');
}
// Ensure there are no double escaped '&' or '<' characters.
$this
->assertSession()
->assertNoEscaped('&');
$this
->assertSession()
->assertNoEscaped('<');
// Ensure there are no escaped '<' characters.
$this
->assertSession()
->assertNoEscaped('<');
}
}
}