Spike PHPCoverage Details: help.test

Line #FrequencySource Line
1 <?php
2 // $Id: help.test,v 1.1 2008/04/04 23:01:20 boombatower Exp $
3 
4 class HelpModuleTestCase extends DrupalTestCase {
5   protected $big_user;
6   protected $any_user;
7 
8   /**
9    * Implementation of getInfo().
10    */
11   function getInfo() {
12     return array(
131      'name' => t('Help functionality'),
14       'description' => t('Verify help display and user access to help based on persmissions.'),
15       'group' => t('Help Tests'),
16     );
17   }
18 
19   /**
20    * Enable modules and create users with specific permissions.
21    */
22   function setUp() {
231    parent::setUp();
24 
25     // Loading these (and other?) modules will result in failures?
26 //    $this->drupalModuleEnable('blog');
27 //    $this->drupalModuleEnable('poll');
281    $this->getModuleList();
29 
30     // Create users.
311    $this->big_user = $this->drupalCreateUser(array('access administration pages')); // 'administer blocks', 'administer site configuration',
321    $this->any_user = $this->drupalCreateUser(array());
33   }
34 
35   /**
36    * Login users, create dblog events, and test dblog functionality through the admin and user interfaces.
37    */
38   function testHelp() {
39     // Login the admin user.
401    $this->drupalLogin($this->big_user);
411    $this->verifyHelp();
42 
43     // Login the regular user.
441    $user = $this->drupalLogin($this->any_user);
451    $this->verifyHelp(403);
46   }
47 
48   /**
49    * Verify the logged in user has the desired access to the various help nodes and the nodes display help.
50    *
51    * @param integer $response HTTP response code.
52    */
53   private function verifyHelp($response = 200) {
541    $crumb = '›';
55 
561    foreach ($this->modules as $module => $name) {
57       // View module help node.
581      $this->drupalGet('admin/help/'. $module);
591      $this->assertResponse($response);
601      if ($response == 200) {
61         // NOTE: The asserts fail on blog and poll because the get returns the 'admin/help' node instead of the indicated node???
62 //        if ($module == 'blog' || $module == 'poll') {
63 //          continue;
64 //        }
651        $this->assertTitle($name. ' | Drupal', t('['. $module .'] Title was displayed'));
661        $this->assertRaw('<h2>'. t($name) .'</h2>', t('['. $module .'] Heading was displayed'));
671        $this->assertText(t('Home '. $crumb .' Administer '. $crumb .' Help'), t('['. $module .'] Breadcrumbs were displayed'));
68       }
69     }
70   }
71 
72   /**
73    * Get list of enabled modules.
74    * 
75    * @return array Enabled modules.
76    */
77   private function getModuleList() {
781    $this->modules = array();
791    $result = db_query("SELECT name, filename, info FROM {system} WHERE type = 'module' AND status = 1 ORDER BY weight ASC, filename ASC");
801    while ($module = db_fetch_object($result)) {
811      if (file_exists($module->filename)) {
821        $fullname = unserialize($module->info);
831        $this->modules[$module->name] = $fullname['name'];
84       }
85     }
86   }
87 }