Commit bc5f69a3 authored by Dries's avatar Dries

- Patch #261836 by dropcube: tests for cron.

parent 01223c9f
......@@ -132,7 +132,7 @@ class IPAddressBlocking extends DrupalWebTestCase {
function getInfo() {
return array(
'name' => t('IP address blocking'),
'description' => t('Tests IP address blocking.'),
'description' => t('Test IP address blocking.'),
'group' => t('System')
);
}
......@@ -149,7 +149,7 @@ class IPAddressBlocking extends DrupalWebTestCase {
}
/**
* Tests a variety of user input to confirm correct validation and saving of data.
* Test a variety of user input to confirm correct validation and saving of data.
*/
function testIPAddressValidation() {
$this->drupalGet('admin/settings/ip-blocking');
......@@ -193,3 +193,38 @@ class IPAddressBlocking extends DrupalWebTestCase {
$this->assertText(t('You may not block your own IP address.'));
}
}
class CronRun extends DrupalWebTestCase {
/**
* 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.'));
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment