protected function TourHelpPageTest::verifyHelp in Drupal 9
Same name and namespace in other branches
- 8 core/modules/tour/tests/src/Functional/TourHelpPageTest.php \Drupal\Tests\tour\Functional\TourHelpPageTest::verifyHelp()
Verifies the logged in user has access to the help properly.
Parameters
bool $tours_ok: (optional) TRUE (default) if the user should see tours, FALSE if not.
1 call to TourHelpPageTest::verifyHelp()
- TourHelpPageTest::testHelp in core/
modules/ tour/ tests/ src/ Functional/ TourHelpPageTest.php - Logs in users, tests help pages.
File
- core/
modules/ tour/ tests/ src/ Functional/ TourHelpPageTest.php, line 76
Class
- TourHelpPageTest
- Verifies help page display of tours.
Namespace
Drupal\Tests\tour\FunctionalCode
protected function verifyHelp($tours_ok = TRUE) {
$this
->drupalGet('admin/help');
// All users should be able to see the module section.
$this
->assertSession()
->pageTextContains('Module overviews are provided by modules');
foreach ($this
->getModuleList() as $name) {
$this
->assertSession()
->linkExists($name);
}
// Some users should be able to see the tour section.
if ($tours_ok) {
$this
->assertSession()
->pageTextContains('Tours guide you through workflows');
}
else {
$this
->assertSession()
->pageTextNotContains('Tours guide you through workflows');
}
$titles = $this
->getTourList();
// Test the titles that should be links.
foreach ($titles[0] as $title) {
if ($tours_ok) {
$this
->assertSession()
->linkExists($title);
}
else {
$this
->assertSession()
->linkNotExists($title);
// Just test the first item in the list of links that should not
// be there, because the second matches the name of a module that is
// in the Module overviews section, so the link will be there and
// this test will fail. Testing one should be sufficient to verify
// the page is working correctly.
break;
}
}
// Test the titles that should not be links.
foreach ($titles[1] as $title) {
if ($tours_ok) {
$this
->assertSession()
->pageTextContains($title);
$this
->assertSession()
->linkNotExistsExact($title);
}
else {
$this
->assertSession()
->pageTextNotContains($title);
// Just test the first item in the list of text that should not
// be there, because the second matches part of the name of a module
// that is in the Module overviews section, so the text will be there
// and this test will fail. Testing one should be sufficient to verify
// the page is working correctly.
break;
}
}
}