From bc5f69a333af204f8e6c6494d85c96b2da1e1c51 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Fri, 30 May 2008 07:27:14 +0000 Subject: [PATCH] - Patch #261836 by dropcube: tests for cron. --- modules/system/system.test | 39 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/modules/system/system.test b/modules/system/system.test index 859566a8881..fc144dc6e68 100644 --- a/modules/system/system.test +++ b/modules/system/system.test @@ -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