/[drupal]/drupal/modules/help/help.test
ViewVC logotype

Contents of /drupal/modules/help/help.test

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.15 - (show annotations) (download) (as text)
Mon Aug 24 00:14:20 2009 UTC (3 months ago) by webchick
Branch: MAIN
CVS Tags: DRUPAL-7-0-UNSTABLE-10, DRUPAL-7-0-UNSTABLE-9, HEAD
Changes since 1.14: +2 -2 lines
File MIME type: text/x-php
#497118 by chx, catch, pwolanin, JoshuaRogers, and Jacob Singh: Remove the function registry. While the hope was that this would result in improved performance for low-end hosts, it comes at the expense of critical development experience problems and less benefit than something like APC. Class registry remains intact to facilitate autoloading.
1 <?php
2 // $Id: help.test,v 1.14 2009/08/24 00:10:43 webchick Exp $
3
4 class HelpTestCase extends DrupalWebTestCase {
5 protected $big_user;
6 protected $any_user;
7
8 public static function getInfo() {
9 return array(
10 'name' => 'Help functionality',
11 'description' => 'Verify help display and user access to help based on permissions.',
12 'group' => 'Help',
13 );
14 }
15
16 /**
17 * Enable modules and create users with specific permissions.
18 */
19 function setUp() {
20 parent::setUp('blog', 'poll');
21
22 $this->getModuleList();
23
24 // Create users.
25 $this->big_user = $this->drupalCreateUser(array('access administration pages'));
26 $this->any_user = $this->drupalCreateUser(array());
27 }
28
29 /**
30 * Login users, create dblog events, and test dblog functionality through the admin and user interfaces.
31 */
32 function testHelp() {
33 // Login the admin user.
34 $this->drupalLogin($this->big_user);
35 $this->verifyHelp();
36
37 // Login the regular user.
38 $this->drupalLogin($this->any_user);
39 $this->verifyHelp(403);
40
41 // Check for css on admin/help.
42 $this->drupalLogin($this->big_user);
43 $this->drupalGet('admin/help');
44 $this->assertRaw(drupal_get_path('module', 'help') . '/help.css', t('The help.css file is present in the HTML.'));
45
46 // Verify that introductory help text exists, goes for 100% module coverage.
47 $this->assertRaw(t('For more information, please refer to the specific topics listed in the next section, or the <a href="@drupal">online Drupal handbooks</a>.', array('@drupal' => 'http://drupal.org/handbooks')), 'Help intro text correctly appears.');
48
49 // Verify that help topics text appears.
50 $this->assertRaw('<h2>' . t('Help topics') . '</h2><p>' . t('Help is available on the following items:') . '</p>', t('Help topics text correctly appears.'));
51
52 // Make sure links are properly added for modules implementing hook_help().
53 foreach ($this->modules as $module => $name) {
54 $this->assertLink($name, 0, t('Link properly added to @name (admin/help/@module)', array('@module' => $module, '@name' => $name)));
55 }
56 }
57
58 /**
59 * Verify the logged in user has the desired access to the various help nodes and the nodes display help.
60 *
61 * @param integer $response HTTP response code.
62 */
63 private function verifyHelp($response = 200) {
64 foreach ($this->modules as $module => $name) {
65 // View module help node.
66 $this->drupalGet('admin/help/' . $module);
67 $this->assertResponse($response);
68 if ($response == 200) {
69 $this->assertTitle($name . ' | Drupal', t('[' . $module . '] Title was displayed'));
70 $this->assertRaw('<h1 class="page-title">' . t($name) . '</h1>', t('[' . $module . '] Heading was displayed'));
71 }
72 }
73 }
74
75 /**
76 * Get list of enabled modules that implement hook_help().
77 *
78 * @return array Enabled modules.
79 */
80 private function getModuleList() {
81 $this->modules = array();
82 $result = db_query("SELECT name, filename, info FROM {system} WHERE type = 'module' AND status = 1 ORDER BY weight ASC, filename ASC");
83 foreach ($result as $module) {
84 if (file_exists($module->filename) && function_exists($module->name . '_help')) {
85 $fullname = unserialize($module->info);
86 $this->modules[$module->name] = $fullname['name'];
87 }
88 }
89 }
90 }
91
92 /**
93 * Tests module without help to verify it is not listed in help page.
94 */
95 class NoHelpTestCase extends DrupalWebTestCase {
96 protected $big_user;
97
98 public static function getInfo() {
99 return array(
100 'name' => 'No help',
101 'description' => 'Verify no help is displayed for modules not providing any help.',
102 'group' => 'Help',
103 );
104 }
105
106 function setUp() {
107 // Use one of the test modules that do not implement hook_help().
108 parent::setUp('menu_test');
109 $this->big_user = $this->drupalCreateUser(array('access administration pages'));
110 }
111
112 /**
113 * Ensure modules not implementing help do not appear on admin/help.
114 */
115 function testMainPageNoHelp() {
116 $this->drupalLogin($this->big_user);
117
118 $this->drupalGet('admin/help');
119 $this->assertNoText('Hook menu tests', t('Making sure the test module menu_test does not display a help link in admin/help'));
120 }
121 }

  ViewVC Help
Powered by ViewVC 1.1.2