123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- <?php
- class HelpTestCase extends DrupalWebTestCase {
-
- protected $big_user;
-
- protected $any_user;
- public static function getInfo() {
- return array(
- 'name' => 'Help functionality',
- 'description' => 'Verify help display and user access to help based on permissions.',
- 'group' => 'Help',
- );
- }
- function setUp() {
- parent::setUp('blog', 'poll');
- $this->getModuleList();
-
- $this->big_user = $this->drupalCreateUser(array('access administration pages', 'view the administration theme', 'administer permissions'));
- $this->any_user = $this->drupalCreateUser(array());
- }
-
- function testHelp() {
-
- $this->drupalLogin($this->big_user);
- $this->verifyHelp();
-
- $this->drupalLogin($this->any_user);
- $this->verifyHelp(403);
-
- $this->drupalLogin($this->big_user);
- $this->drupalGet('admin/help');
- $this->assertRaw(drupal_get_path('module', 'help') . '/help.css', 'The help.css file is present in the HTML.');
-
- $this->assertRaw(t('For more information, refer to the specific topics listed in the next section or to the <a href="@drupal">online Drupal handbooks</a>.', array('@drupal' => 'http://drupal.org/documentation')), 'Help intro text correctly appears.');
-
- $this->assertRaw('<h2>' . t('Help topics') . '</h2><p>' . t('Help is available on the following items:') . '</p>', 'Help topics text correctly appears.');
-
- foreach ($this->modules as $module => $name) {
- $this->assertLink($name, 0, format_string('Link properly added to @name (admin/help/@module)', array('@module' => $module, '@name' => $name)));
- }
- }
-
- protected function verifyHelp($response = 200) {
- foreach ($this->modules as $module => $name) {
-
- $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->assertRaw('<h1 class="page-title">' . t($name) . '</h1>', format_string('%module heading was displayed', array('%module' => $module)));
- }
- }
- }
-
- protected function getModuleList() {
- $this->modules = array();
- $result = db_query("SELECT name, filename, info FROM {system} WHERE type = 'module' AND status = 1 ORDER BY weight ASC, filename ASC");
- foreach ($result as $module) {
- if (file_exists($module->filename) && function_exists($module->name . '_help')) {
- $fullname = unserialize($module->info);
- $this->modules[$module->name] = $fullname['name'];
- }
- }
- }
- }
- class NoHelpTestCase extends DrupalWebTestCase {
-
- protected $big_user;
- public static function getInfo() {
- return array(
- 'name' => 'No help',
- 'description' => 'Verify no help is displayed for modules not providing any help.',
- 'group' => 'Help',
- );
- }
- function setUp() {
-
- parent::setUp('menu_test');
- $this->big_user = $this->drupalCreateUser(array('access administration pages'));
- }
-
- function testMainPageNoHelp() {
- $this->drupalLogin($this->big_user);
- $this->drupalGet('admin/help');
- $this->assertNoText('Hook menu tests', 'Making sure the test module menu_test does not display a help link in admin/help');
- }
- }
|