- 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 EnableDisableCoreTestCase extends DrupalWebTestCase {
|
2008-05-19 19:28:39 +00:00
|
|
|
protected $admin_user;
|
|
|
|
|
- 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
|
|
|
/**
|
|
|
|
* Implementation of getInfo().
|
|
|
|
*/
|
|
|
|
function getInfo() {
|
|
|
|
return array(
|
|
|
|
'name' => t('Module list functionality'),
|
2008-07-23 07:37:06 +00:00
|
|
|
'description' => t('Enable/disable core module and confirm table creation/deletion. Enable module without dependency enabled.'),
|
- 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
|
|
|
'group' => t('System')
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implementation of setUp().
|
|
|
|
*/
|
|
|
|
function setUp() {
|
|
|
|
parent::setUp();
|
|
|
|
|
2008-05-19 19:28:39 +00:00
|
|
|
$this->admin_user = $this->drupalCreateUser(array('access administration pages', 'administer site configuration'));
|
|
|
|
$this->drupalLogin($this->admin_user);
|
- 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
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Enable a module, check the database for related tables, disable module,
|
|
|
|
* check for related tables, unistall module, check for related tables.
|
|
|
|
*/
|
|
|
|
function testEnableDisable() {
|
|
|
|
// Enable aggregator, and check tables.
|
|
|
|
$this->assertModules(array('aggregator'), FALSE);
|
|
|
|
$this->assertTableCount('aggregator', FALSE);
|
|
|
|
|
|
|
|
$edit = array();
|
2008-10-11 02:33:14 +00:00
|
|
|
$edit['modules[Core][aggregator][enable]'] = 'aggregator';
|
- 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->drupalPost('admin/build/modules', $edit, t('Save configuration'));
|
|
|
|
$this->assertText(t('The configuration options have been saved.'), t('Modules status has been updated.'));
|
|
|
|
|
|
|
|
$this->assertModules(array('aggregator'), TRUE);
|
|
|
|
$this->assertTableCount('aggregator', TRUE);
|
|
|
|
|
|
|
|
// Disable aggregator, check tables, uninstall aggregator, check tables.
|
|
|
|
$edit = array();
|
2008-10-11 02:33:14 +00:00
|
|
|
$edit['modules[Core][aggregator][enable]'] = FALSE;
|
- 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->drupalPost('admin/build/modules', $edit, t('Save configuration'));
|
|
|
|
$this->assertText(t('The configuration options have been saved.'), t('Modules status has been updated.'));
|
|
|
|
|
|
|
|
$this->assertModules(array('aggregator'), FALSE);
|
|
|
|
$this->assertTableCount('aggregator', TRUE);
|
|
|
|
|
|
|
|
$edit = array();
|
|
|
|
$edit['uninstall[aggregator]'] = 'aggregator';
|
|
|
|
$this->drupalPost('admin/build/modules/uninstall', $edit, t('Uninstall'));
|
|
|
|
|
|
|
|
$this->drupalPost(NULL, NULL, t('Uninstall'));
|
|
|
|
$this->assertText(t('The selected modules have been uninstalled.'), t('Modules status has been updated.'));
|
|
|
|
|
|
|
|
$this->assertModules(array('aggregator'), FALSE);
|
|
|
|
$this->assertTableCount('aggregator', FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Attempt to enable translation module without locale enabled.
|
|
|
|
*/
|
|
|
|
function testEnableWithoutDependency () {
|
|
|
|
// Attempt to enable content translation without locale enabled.
|
|
|
|
$edit = array();
|
2008-10-11 02:33:14 +00:00
|
|
|
$edit['modules[Core][translation][enable]'] = 'translation';
|
- 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->drupalPost('admin/build/modules', $edit, t('Save configuration'));
|
|
|
|
$this->assertText(t('Some required modules must be enabled'), t('Dependecy required.'));
|
|
|
|
|
|
|
|
$this->assertModules(array('translation', 'locale'), FALSE);
|
|
|
|
|
|
|
|
// Assert that the locale tables weren't enabled.
|
|
|
|
$this->assertTableCount('languages', FALSE);
|
|
|
|
$this->assertTableCount('locale', FALSE);
|
|
|
|
|
|
|
|
$this->drupalPost(NULL, NULL, t('Continue'));
|
|
|
|
$this->assertText(t('The configuration options have been saved.'), t('Modules status has been updated.'));
|
|
|
|
|
|
|
|
$this->assertModules(array('translation', 'locale'), TRUE);
|
|
|
|
|
|
|
|
// Assert that the locale tables were enabled.
|
|
|
|
$this->assertTableCount('languages', TRUE);
|
|
|
|
$this->assertTableCount('locale', TRUE);
|
|
|
|
}
|
|
|
|
|
2008-10-11 03:25:36 +00:00
|
|
|
/**
|
|
|
|
* Assert that core required modules cannot be disabled.
|
|
|
|
*/
|
|
|
|
function testDisableRequired() {
|
|
|
|
$required_modules = drupal_required_modules();
|
|
|
|
foreach($required_modules as $module) {
|
|
|
|
// Check to make sure the checkbox for required module is not found.
|
|
|
|
$this->drupalGet('admin/build/modules');
|
|
|
|
$this->assertNoFieldByName('modules[Core][' . $module . '][enable]');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
- 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
|
|
|
/**
|
|
|
|
* Assert tables that begin with the specified base table name.
|
|
|
|
*
|
|
|
|
* @param string $base_table Begginning of table name to look for.
|
|
|
|
* @param boolean $count Assert tables that match specified base table.
|
|
|
|
* @return boolean Tables with specified base table.
|
|
|
|
*/
|
|
|
|
function assertTableCount($base_table, $count) {
|
|
|
|
$match_count = simpletest_get_like_tables($base_table, TRUE);
|
|
|
|
|
|
|
|
if ($count) {
|
|
|
|
return $this->assertTrue($match_count, t('Tables matching "@base_table" found.', array('@base_table' => $base_table)));
|
|
|
|
}
|
|
|
|
return $this->assertFalse($match_count, t('Tables matching "@base_table" not found.', array('@base_table' => $base_table)));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Assert the list of modules are enabled or disabled.
|
|
|
|
*
|
|
|
|
* @param array $modules Modules to check.
|
|
|
|
* @param boolean $enabled Module state.
|
|
|
|
*/
|
2008-07-23 07:37:06 +00:00
|
|
|
function assertModules(Array $modules, $enabled) {
|
- 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
|
|
|
module_list(TRUE, FALSE);
|
|
|
|
foreach ($modules as $module) {
|
|
|
|
if ($enabled) {
|
2008-07-23 07:37:06 +00:00
|
|
|
$message = 'Module "@module" is enabled.';
|
- 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
|
|
|
}
|
|
|
|
else {
|
2008-07-23 07:37:06 +00:00
|
|
|
$message = 'Module "@module" is not enabled.';
|
- 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
|
|
|
}
|
2008-07-23 07:37:06 +00:00
|
|
|
$this->assertEqual(module_exists($module), $enabled, t($message, array('@module' => $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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-05-10 07:32:02 +00:00
|
|
|
|
2008-06-02 17:32:19 +00:00
|
|
|
class IPAddressBlockingTestCase extends DrupalWebTestCase {
|
2008-05-19 19:28:39 +00:00
|
|
|
protected $blocking_user;
|
|
|
|
|
2008-05-10 07:32:02 +00:00
|
|
|
/**
|
|
|
|
* Implementation of getInfo().
|
|
|
|
*/
|
|
|
|
function getInfo() {
|
|
|
|
return array(
|
|
|
|
'name' => t('IP address blocking'),
|
2008-05-30 07:27:14 +00:00
|
|
|
'description' => t('Test IP address blocking.'),
|
2008-05-10 07:32:02 +00:00
|
|
|
'group' => t('System')
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implementation of setUp().
|
|
|
|
*/
|
|
|
|
function setUp() {
|
|
|
|
parent::setUp();
|
|
|
|
|
|
|
|
// Create user.
|
2008-06-09 16:33:20 +00:00
|
|
|
$this->blocking_user = $this->drupalCreateUser(array('block IP addresses'));
|
2008-05-19 19:28:39 +00:00
|
|
|
$this->drupalLogin($this->blocking_user);
|
2008-05-10 07:32:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2008-05-30 07:27:14 +00:00
|
|
|
* Test a variety of user input to confirm correct validation and saving of data.
|
2008-05-10 07:32:02 +00:00
|
|
|
*/
|
|
|
|
function testIPAddressValidation() {
|
|
|
|
$this->drupalGet('admin/settings/ip-blocking');
|
|
|
|
|
|
|
|
// Block a valid IP address.
|
|
|
|
$edit = array();
|
|
|
|
$edit['ip'] = '192.168.1.1';
|
|
|
|
$this->drupalPost('admin/settings/ip-blocking', $edit, t('Save'));
|
|
|
|
$ip = db_result(db_query("SELECT iid from {blocked_ips} WHERE ip = '%s'", $edit['ip']));
|
|
|
|
$this->assertNotNull($ip, t('IP address found in database'));
|
|
|
|
$this->assertRaw(t('The IP address %ip has been blocked.', array('%ip' => $edit['ip'])), t('IP address was blocked.'));
|
|
|
|
|
|
|
|
// Try to block an IP address that's already blocked.
|
|
|
|
$edit = array();
|
|
|
|
$edit['ip'] = '192.168.1.1';
|
|
|
|
$this->drupalPost('admin/settings/ip-blocking', $edit, t('Save'));
|
|
|
|
$this->assertText(t('This IP address is already blocked.'));
|
|
|
|
|
|
|
|
// Try to block a reserved IP address.
|
|
|
|
$edit = array();
|
|
|
|
$edit['ip'] = '255.255.255.255';
|
|
|
|
$this->drupalPost('admin/settings/ip-blocking', $edit, t('Save'));
|
|
|
|
$this->assertText(t('Please enter a valid IP address.'));
|
|
|
|
|
|
|
|
// Try to block a reserved IP address.
|
|
|
|
$edit = array();
|
|
|
|
$edit['ip'] = 'test.example.com';
|
|
|
|
$this->drupalPost('admin/settings/ip-blocking', $edit, t('Save'));
|
|
|
|
$this->assertText(t('Please enter a valid IP address.'));
|
|
|
|
|
|
|
|
// Submit an empty form.
|
|
|
|
$edit = array();
|
|
|
|
$edit['ip'] = '';
|
|
|
|
$this->drupalPost('admin/settings/ip-blocking', $edit, t('Save'));
|
|
|
|
$this->assertText(t('Please enter a valid IP address.'));
|
|
|
|
|
|
|
|
// Submit your own IP address. This fails, although it works when testing manually.
|
2008-06-29 11:39:38 +00:00
|
|
|
// TODO: on some systems this test fails due to a bug or inconsistency in cURL.
|
|
|
|
// $edit = array();
|
|
|
|
// $edit['ip'] = ip_address();
|
|
|
|
// $this->drupalPost('admin/settings/ip-blocking', $edit, t('Save'));
|
|
|
|
// $this->assertText(t('You may not block your own IP address.'));
|
2008-05-10 07:32:02 +00:00
|
|
|
}
|
|
|
|
}
|
2008-05-30 07:27:14 +00:00
|
|
|
|
2008-06-02 17:32:19 +00:00
|
|
|
class CronRunTestCase extends DrupalWebTestCase {
|
2008-05-30 07:27:14 +00:00
|
|
|
/**
|
|
|
|
* Implementation of getInfo().
|
|
|
|
*/
|
|
|
|
function getInfo() {
|
|
|
|
return array(
|
|
|
|
'name' => t('Cron run'),
|
|
|
|
'description' => t('Test cron run.'),
|
|
|
|
'group' => t('System')
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test cron runs.
|
|
|
|
*/
|
|
|
|
function testCronRun() {
|
|
|
|
// Run cron anonymously without any cron key.
|
|
|
|
$this->drupalGet('cron.php');
|
|
|
|
$this->assertResponse(403);
|
|
|
|
|
|
|
|
// Run cron anonymously with a random cron key.
|
|
|
|
$key = $this->randomName(16);
|
|
|
|
$this->drupalGet('cron.php', array('query' => 'cron_key=' . $key));
|
|
|
|
$this->assertResponse(403);
|
|
|
|
|
|
|
|
// Run cron anonymously with the valid cron key.
|
|
|
|
$key = variable_get('cron_key', 'drupal');
|
|
|
|
$this->drupalGet('cron.php', array('query' => 'cron_key=' . $key));
|
|
|
|
$this->assertResponse(200);
|
|
|
|
|
|
|
|
// Execute cron directly.
|
|
|
|
$this->assertTrue(drupal_cron_run(), t('Cron ran successfully.'));
|
|
|
|
}
|
2008-06-02 17:32:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
class AdminOverviewTestCase extends DrupalWebTestCase {
|
|
|
|
/**
|
|
|
|
* Implementation of getInfo().
|
|
|
|
*/
|
|
|
|
function getInfo() {
|
|
|
|
return array(
|
|
|
|
'name' => t('Admin overview'),
|
|
|
|
'description' => t('Confirm that the admin overview page appears as expected.'),
|
|
|
|
'group' => t('System')
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test the overview page by task.
|
|
|
|
*/
|
|
|
|
function testAdminOverview() {
|
|
|
|
$admin_user1 = $this->drupalCreateUser(array('access administration pages'));
|
|
|
|
$this->drupalLogin($admin_user1);
|
|
|
|
|
|
|
|
$this->drupalGet('admin');
|
|
|
|
$this->checkOverview();
|
|
|
|
|
|
|
|
$this->drupalGet('admin/by-module');
|
|
|
|
$this->checkOverview();
|
|
|
|
|
|
|
|
// Comments on permissions follow the format: [task], [module] that the permission relates to.
|
|
|
|
$permissions = array();
|
|
|
|
$permissions[] = 'access administration pages';
|
|
|
|
$permissions[] = 'administer comments'; // Content management, Comment.
|
|
|
|
$permissions[] = 'administer blocks'; // Site building, Block.
|
|
|
|
$permissions[] = 'administer filters'; // Site configuration, Filter.
|
|
|
|
$permissions[] = 'administer users'; // User management, User.
|
|
|
|
$permissions[] = 'access site reports'; // Reports, Database logging.
|
|
|
|
$admin_user2 = $this->drupalCreateUser($permissions);
|
|
|
|
$this->drupalLogin($admin_user2);
|
|
|
|
|
|
|
|
$this->drupalGet('admin');
|
|
|
|
$this->checkOverview(array(t('Content management'), t('User management'), t('Reports'), t('Site building'), t('Site configuration')));
|
|
|
|
|
|
|
|
$this->drupalGet('admin/by-module');
|
|
|
|
$this->checkOverview(array(t('Comment'), t('Block'), t('Filter'), t('User'), t('Database logging')));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check the overview page panels.
|
|
|
|
*
|
|
|
|
* @param array $panels List of panels to be found.
|
|
|
|
*/
|
|
|
|
function checkOverview(array $panels = array()) {
|
|
|
|
if ($this->parse()) {
|
|
|
|
$found = 0;
|
|
|
|
$extra = 0;
|
2008-08-22 12:35:55 +00:00
|
|
|
$divs = $this->xpath("//div[@class='admin-panel']");
|
2008-06-02 17:32:19 +00:00
|
|
|
foreach ($divs as $panel) {
|
|
|
|
if (in_array(trim($panel->h3), $panels)) {
|
|
|
|
$found++;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$extra++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$this->assertTrue(count($panels) == $found, t('Required panels found.'));
|
|
|
|
$this->assertFalse($extra, t('No extra panels found.'));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-06-28 19:19:08 +00:00
|
|
|
|
|
|
|
class AdminMetaTagTestCase extends DrupalWebTestCase {
|
|
|
|
/**
|
|
|
|
* Implementation of getInfo().
|
|
|
|
*/
|
|
|
|
function getInfo() {
|
|
|
|
return array(
|
|
|
|
'name' => t('Fingerprinting meta tag'),
|
|
|
|
'description' => t('Confirm that the fingerprinting meta tag appears as expected.'),
|
|
|
|
'group' => t('System')
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Verify that the meta tag HTML is generated correctly.
|
|
|
|
*/
|
|
|
|
public function testMetaTag() {
|
|
|
|
list($version,) = explode('.', VERSION);
|
|
|
|
$string = '<meta name="Generator" content="Drupal ' . $version. ' (http://drupal.org)" />';
|
|
|
|
$this->drupalGet('node');
|
|
|
|
$this->assertRaw($string, t('Fingerprinting meta tag generated correctly.'), t('System'));
|
|
|
|
}
|
|
|
|
}
|
2008-08-28 08:37:46 +00:00
|
|
|
|
|
|
|
class PageNotFoundTestCase extends DrupalWebTestCase {
|
|
|
|
protected $admin_user;
|
2008-09-15 20:48:10 +00:00
|
|
|
|
2008-08-28 08:37:46 +00:00
|
|
|
/**
|
|
|
|
* Implementation of getInfo().
|
|
|
|
*/
|
|
|
|
function getInfo() {
|
|
|
|
return array(
|
|
|
|
'name' => t('404 functionality'),
|
|
|
|
'description' => t("Tests page not found functionality, including custom 404 pages."),
|
|
|
|
'group' => t('System')
|
|
|
|
);
|
|
|
|
}
|
2008-09-15 20:48:10 +00:00
|
|
|
|
2008-08-28 08:37:46 +00:00
|
|
|
/**
|
|
|
|
* Implementation of setUp().
|
|
|
|
*/
|
|
|
|
function setUp() {
|
|
|
|
parent::setUp();
|
|
|
|
|
|
|
|
// Create an administrative user.
|
|
|
|
$this->admin_user = $this->drupalCreateUser(array('administer site configuration'));
|
|
|
|
$this->drupalLogin($this->admin_user);
|
|
|
|
}
|
|
|
|
|
|
|
|
function testPageNotFound() {
|
|
|
|
$this->drupalGet($this->randomName(10));
|
|
|
|
$this->assertText(t('Page not found'), t('Found the default 404 page'));
|
2008-09-15 20:48:10 +00:00
|
|
|
|
2008-08-28 08:37:46 +00:00
|
|
|
$edit = array(
|
|
|
|
'title' => $this->randomName(10),
|
|
|
|
'body' => $this->randomName(100)
|
|
|
|
);
|
|
|
|
$node = $this->drupalCreateNode($edit);
|
|
|
|
|
|
|
|
// Use a custom 404 page.
|
|
|
|
$this->drupalPost('admin/settings/error-reporting', array('site_404' => 'node/' . $node->nid), t('Save configuration'));
|
2008-09-15 20:48:10 +00:00
|
|
|
|
2008-08-28 08:37:46 +00:00
|
|
|
$this->drupalGet($this->randomName(10));
|
|
|
|
$this->assertText($node->title, t('Found the custom 404 page'));
|
2008-09-15 20:48:10 +00:00
|
|
|
|
2008-08-28 08:37:46 +00:00
|
|
|
// Logout and check that the user login block is not shown on custom 404 pages.
|
|
|
|
$this->drupalLogout();
|
2008-09-15 20:48:10 +00:00
|
|
|
|
2008-08-28 08:37:46 +00:00
|
|
|
$this->drupalGet($this->randomName(10));
|
|
|
|
$this->assertText($node->title, t('Found the custom 404 page'));
|
|
|
|
$this->assertNoText(t('User login'), t('Blocks are not shown on the custom 404 page'));
|
2008-09-15 20:48:10 +00:00
|
|
|
|
2008-08-28 08:37:46 +00:00
|
|
|
// Log back in and remove the custom 404 page.
|
|
|
|
$this->drupalLogin($this->admin_user);
|
|
|
|
$this->drupalPost('admin/settings/error-reporting', array(), t('Reset to defaults'));
|
|
|
|
|
|
|
|
// Logout and check that the user login block is not shown on default 404 pages.
|
|
|
|
$this->drupalLogout();
|
2008-09-15 20:48:10 +00:00
|
|
|
|
2008-08-28 08:37:46 +00:00
|
|
|
$this->drupalGet($this->randomName(10));
|
|
|
|
$this->assertText(t('Page not found'), t('Found the default 404 page'));
|
|
|
|
$this->assertNoText(t('User login'), t('Blocks are not shown on the default 404 page'));
|
|
|
|
}
|
|
|
|
}
|