#295982 by kscheirer, jhedstrom, Senpai, et al: Added tests for the main help page.
parent
75c8c24c69
commit
ff477cd6ea
|
@ -17,15 +17,12 @@ class HelpTestCase extends DrupalWebTestCase {
|
|||
* Enable modules and create users with specific permissions.
|
||||
*/
|
||||
function setUp() {
|
||||
parent::setUp();
|
||||
parent::setUp('blog', 'poll');
|
||||
|
||||
// Loading these (and other?) modules will result in failures?
|
||||
// $this->drupalModuleEnable('blog');
|
||||
// $this->drupalModuleEnable('poll');
|
||||
$this->getModuleList();
|
||||
|
||||
// Create users.
|
||||
$this->big_user = $this->drupalCreateUser(array('access administration pages')); // 'administer blocks', 'administer site configuration',
|
||||
$this->big_user = $this->drupalCreateUser(array('access administration pages'));
|
||||
$this->any_user = $this->drupalCreateUser(array());
|
||||
}
|
||||
|
||||
|
@ -40,6 +37,22 @@ class HelpTestCase extends DrupalWebTestCase {
|
|||
// Login the regular user.
|
||||
$this->drupalLogin($this->any_user);
|
||||
$this->verifyHelp(403);
|
||||
|
||||
// Check for css on admin/help.
|
||||
$this->drupalLogin($this->big_user);
|
||||
$this->drupalGet('admin/help');
|
||||
$this->assertRaw(drupal_get_path('module', 'help') . '/help.css', t('The help.css file is present in the HTML.'));
|
||||
|
||||
// Verify that introductory help text exists, goes for 100% module coverage.
|
||||
$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.');
|
||||
|
||||
// Verify that help topics text appears.
|
||||
$this->assertRaw('<h2>' . t('Help topics') . '</h2><p>' . t('Help is available on the following items:') . '</p>', t('Help topics text correctly appears.'));
|
||||
|
||||
// Make sure links are properly added for modules implementing hook_help().
|
||||
foreach ($this->modules as $module => $name) {
|
||||
$this->assertLink($name, 0, t('Link properly added to @name (admin/help/@module)', array('@module' => $module, '@name' => $name)));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -48,29 +61,19 @@ class HelpTestCase extends DrupalWebTestCase {
|
|||
* @param integer $response HTTP response code.
|
||||
*/
|
||||
private function verifyHelp($response = 200) {
|
||||
$crumb = '›';
|
||||
|
||||
foreach ($this->modules as $module => $name) {
|
||||
// View module help node.
|
||||
$this->drupalGet('admin/help/' . $module);
|
||||
$this->assertResponse($response);
|
||||
if (drupal_function_exists($module . '_help')) {
|
||||
// View module help node.
|
||||
$this->drupalGet('admin/help/' . $module);
|
||||
$this->assertResponse($response);
|
||||
if ($response == 200) {
|
||||
// NOTE: The asserts fail on blog and poll because the get returns the 'admin/help' node instead of the indicated node???
|
||||
// if ($module == 'blog' || $module == 'poll') {
|
||||
// continue;
|
||||
// }
|
||||
$this->assertTitle($name . ' | Drupal', t('[' . $module . '] Title was displayed'));
|
||||
}
|
||||
}
|
||||
if ($response == 200) {
|
||||
$this->assertTitle($name . ' | Drupal', t('[' . $module . '] Title was displayed'));
|
||||
$this->assertRaw('<h1 class="page-title">' . t($name) . '</h1>', t('[' . $module . '] Heading was displayed'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get list of enabled modules.
|
||||
* Get list of enabled modules that implement hook_help().
|
||||
*
|
||||
* @return array Enabled modules.
|
||||
*/
|
||||
|
@ -78,12 +81,12 @@ class HelpTestCase extends DrupalWebTestCase {
|
|||
$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)) {
|
||||
if (file_exists($module->filename) && drupal_function_exists($module->name . '_help')) {
|
||||
$fullname = unserialize($module->info);
|
||||
$this->modules[$module->name] = $fullname['name'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue