X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Ftour%2Ftests%2Fsrc%2FFunctional%2FTourHelpPageTest.php;fp=web%2Fcore%2Fmodules%2Ftour%2Ftests%2Fsrc%2FFunctional%2FTourHelpPageTest.php;h=ad60df104f207b4034e8a83c56a13cef87c24413;hp=0000000000000000000000000000000000000000;hb=9917807b03b64faf00f6a1f29dcb6eafc454efa5;hpb=aea91e65e895364e460983b890e295aa5d5540a5 diff --git a/web/core/modules/tour/tests/src/Functional/TourHelpPageTest.php b/web/core/modules/tour/tests/src/Functional/TourHelpPageTest.php new file mode 100644 index 000000000..ad60df104 --- /dev/null +++ b/web/core/modules/tour/tests/src/Functional/TourHelpPageTest.php @@ -0,0 +1,141 @@ +tourUser = $this->drupalCreateUser(['access administration pages', 'access tour', 'administer languages']); + $this->noTourUser = $this->drupalCreateUser(['access administration pages']); + } + + /** + * Logs in users, tests help pages. + */ + public function testHelp() { + $this->drupalLogin($this->tourUser); + $this->verifyHelp(); + + $this->drupalLogin($this->noTourUser); + $this->verifyHelp(FALSE); + } + + /** + * Verifies the logged in user has access to the help properly. + * + * @param bool $tours_ok + * (optional) TRUE (default) if the user should see tours, FALSE if not. + */ + protected function verifyHelp($tours_ok = TRUE) { + $this->drupalGet('admin/help'); + + // All users should be able to see the module section. + $this->assertText('Module overviews are provided by modules'); + foreach ($this->getModuleList() as $name) { + $this->assertLink($name); + } + + // Some users should be able to see the tour section. + if ($tours_ok) { + $this->assertText('Tours guide you through workflows'); + } + else { + $this->assertNoText('Tours guide you through workflows'); + } + + $titles = $this->getTourList(); + + // Test the titles that should be links. + foreach ($titles[0] as $title) { + if ($tours_ok) { + $this->assertLink($title); + } + else { + $this->assertNoLink($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->assertText($title); + $this->assertSession()->linkNotExistsExact($title); + } + else { + $this->assertNoText($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; + } + } + } + + /** + * Gets a list of modules to test for hook_help() pages. + * + * @return array + * A list of module names to test. + */ + protected function getModuleList() { + return ['Help', 'Tour']; + } + + /** + * Gets a list of tours to test. + * + * @return array + * A list of tour titles to test. The first array element is a list of tours + * with links, and the second is a list of tours without links. Assumes + * that the user being tested has 'administer languages' permission but + * not 'translate interface'. + */ + protected function getTourList() { + return [['Adding languages', 'Language'], ['Editing languages', 'Translation']]; + } + +}