- Added a test framework to Drupal along with a first batch of tests for
Drupal core! This is an important milestone for the project so enable
the module and check it out ... :)
Thanks to Rok Žlender, Károly Négyesi, Jimmy Berry, Kevin Bridges, Charlie
Gordon, Douglas Hubler, Miglius Alaburda, Andy Kirkham, Dimitri13, Kieran
Lal, Moshe Weitzman, and the many other people that helped with testing
over the past years and that drove this home.
It all works but it is still rough around the edges (i.e. documentation
is still being written, the coding style is not 100% yet, a number of
tests still fail) but we spent the entire weekend working on it in Paris
and made a ton of progress. The best way to help and to get up to speed,
is to start writing and contributing some tests ... as well as fixing
some of the failures.
For those willing to help with improving the test framework, here are
some next steps and issues to resolve:
- How to best approach unit tests and mock functions?
- How to test drupal_mail() and drupal_http_request()?
- How to improve the admin UI so we have a nice progress bar?
- How best to do code coverage?
- See http://g.d.o/node/10099 for more ...
2008-04-20 18:24:07 +00:00
|
|
|
|
<?php
|
|
|
|
|
// $Id$
|
|
|
|
|
|
|
|
|
|
class HelpTestCase extends DrupalWebTestCase {
|
|
|
|
|
protected $big_user;
|
|
|
|
|
protected $any_user;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Implementation of getInfo().
|
|
|
|
|
*/
|
|
|
|
|
function getInfo() {
|
|
|
|
|
return array(
|
|
|
|
|
'name' => t('Help functionality'),
|
|
|
|
|
'description' => t('Verify help display and user access to help based on persmissions.'),
|
|
|
|
|
'group' => t('Help'),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Enable modules and create users with specific permissions.
|
|
|
|
|
*/
|
|
|
|
|
function setUp() {
|
|
|
|
|
parent::setUp();
|
|
|
|
|
|
|
|
|
|
// 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->any_user = $this->drupalCreateUser(array());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Login users, create dblog events, and test dblog functionality through the admin and user interfaces.
|
|
|
|
|
*/
|
|
|
|
|
function testHelp() {
|
|
|
|
|
// Login the admin user.
|
|
|
|
|
$this->drupalLogin($this->big_user);
|
|
|
|
|
$this->verifyHelp();
|
|
|
|
|
|
|
|
|
|
// Login the regular user.
|
|
|
|
|
$user = $this->drupalLogin($this->any_user);
|
|
|
|
|
$this->verifyHelp(403);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Verify the logged in user has the desired access to the various help nodes and the nodes display help.
|
|
|
|
|
*
|
|
|
|
|
* @param integer $response HTTP response code.
|
|
|
|
|
*/
|
|
|
|
|
private function verifyHelp($response = 200) {
|
|
|
|
|
$crumb = '›';
|
|
|
|
|
|
|
|
|
|
foreach ($this->modules as $module => $name) {
|
|
|
|
|
// View module help node.
|
2008-05-30 07:30:53 +00:00
|
|
|
|
$this->drupalGet('admin/help/' . $module);
|
- Added a test framework to Drupal along with a first batch of tests for
Drupal core! This is an important milestone for the project so enable
the module and check it out ... :)
Thanks to Rok Žlender, Károly Négyesi, Jimmy Berry, Kevin Bridges, Charlie
Gordon, Douglas Hubler, Miglius Alaburda, Andy Kirkham, Dimitri13, Kieran
Lal, Moshe Weitzman, and the many other people that helped with testing
over the past years and that drove this home.
It all works but it is still rough around the edges (i.e. documentation
is still being written, the coding style is not 100% yet, a number of
tests still fail) but we spent the entire weekend working on it in Paris
and made a ton of progress. The best way to help and to get up to speed,
is to start writing and contributing some tests ... as well as fixing
some of the failures.
For those willing to help with improving the test framework, here are
some next steps and issues to resolve:
- How to best approach unit tests and mock functions?
- How to test drupal_mail() and drupal_http_request()?
- How to improve the admin UI so we have a nice progress bar?
- How best to do code coverage?
- See http://g.d.o/node/10099 for more ...
2008-04-20 18:24:07 +00:00
|
|
|
|
$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;
|
|
|
|
|
// }
|
2008-05-30 07:30:53 +00:00
|
|
|
|
$this->assertTitle($name . ' | Drupal', t('[' . $module . '] Title was displayed'));
|
|
|
|
|
$this->assertRaw('<h2>' . t($name) . '</h2>', t('[' . $module . '] Heading was displayed'));
|
|
|
|
|
$this->assertText(t('Home ' . $crumb . ' Administer ' . $crumb . ' Help'), t('[' . $module . '] Breadcrumbs were displayed'));
|
- Added a test framework to Drupal along with a first batch of tests for
Drupal core! This is an important milestone for the project so enable
the module and check it out ... :)
Thanks to Rok Žlender, Károly Négyesi, Jimmy Berry, Kevin Bridges, Charlie
Gordon, Douglas Hubler, Miglius Alaburda, Andy Kirkham, Dimitri13, Kieran
Lal, Moshe Weitzman, and the many other people that helped with testing
over the past years and that drove this home.
It all works but it is still rough around the edges (i.e. documentation
is still being written, the coding style is not 100% yet, a number of
tests still fail) but we spent the entire weekend working on it in Paris
and made a ton of progress. The best way to help and to get up to speed,
is to start writing and contributing some tests ... as well as fixing
some of the failures.
For those willing to help with improving the test framework, here are
some next steps and issues to resolve:
- How to best approach unit tests and mock functions?
- How to test drupal_mail() and drupal_http_request()?
- How to improve the admin UI so we have a nice progress bar?
- How best to do code coverage?
- See http://g.d.o/node/10099 for more ...
2008-04-20 18:24:07 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get list of enabled modules.
|
|
|
|
|
*
|
|
|
|
|
* @return array Enabled modules.
|
|
|
|
|
*/
|
|
|
|
|
private 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");
|
|
|
|
|
while ($module = db_fetch_object($result)) {
|
|
|
|
|
if (file_exists($module->filename)) {
|
|
|
|
|
$fullname = unserialize($module->info);
|
|
|
|
|
$this->modules[$module->name] = $fullname['name'];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|