summaryrefslogtreecommitdiff
path: root/modules/system/system.test
diff options
context:
space:
mode:
Diffstat (limited to 'modules/system/system.test')
-rw-r--r--modules/system/system.test53
1 files changed, 49 insertions, 4 deletions
diff --git a/modules/system/system.test b/modules/system/system.test
index 2c642adff..92d0e32dc 100644
--- a/modules/system/system.test
+++ b/modules/system/system.test
@@ -372,6 +372,7 @@ class CronRunTestCase extends DrupalWebTestCase {
*/
function testCronRun() {
global $base_url;
+
// Run cron anonymously without any cron key.
$this->drupalGet($base_url . '/cron.php', array('external' => TRUE));
$this->assertResponse(403);
@@ -391,13 +392,57 @@ class CronRunTestCase extends DrupalWebTestCase {
}
/**
+ * Follow every image paths in the previously retrieved content.
+ */
+ function drupalGetAllImages() {
+ foreach ($this->xpath('//img') as $image) {
+ $this->drupalGet($this->getAbsoluteUrl($image['src']));
+ }
+ }
+
+ /**
+ * Ensure that the cron image callback to run it automatically is working.
+ *
+ * In these tests we do not use REQUEST_TIME to track start time, because we
+ * need the exact time when cron is triggered.
+ */
+ function testCronThreshold() {
+ // Ensure cron does not run when the cron threshold is enabled and was
+ // not passed.
+ $start_cron_last = time();
+ variable_set('cron_last', $start_cron_last);
+ variable_set('cron_safe_threshold', 10);
+ $this->drupalGet('');
+ // Follow every image path on the page.
+ $this->drupalGetAllImages();
+ $this->assertTrue($start_cron_last == variable_get('cron_last', NULL), t('Cron does not run when the cron threshold is not passed.'));
+
+ // Test if cron runs when the cron threshold was passed.
+ $start_cron_last = time() - 15;
+ variable_set('cron_last', $start_cron_last);
+ $this->drupalGet('');
+ // Follow every image path on the page.
+ $this->drupalGetAllImages();
+ $this->assertTrue(variable_get('cron_last', NULL) > $start_cron_last, t('Cron runs when the cron threshold is passed.'));
+
+ // Test if cron does not run when the cron threshold was is disabled.
+ $start_cron_last = time() - 15;
+ variable_set('cron_safe_threshold', 0);
+ variable_set('cron_last', $start_cron_last);
+ $this->drupalGet('');
+ // Follow every image path on the page.
+ $this->drupalGetAllImages();
+ $this->assertTrue($start_cron_last == variable_get('cron_last', NULL), t('Cron does not run when the cron threshold is disabled.'));
+ }
+
+ /**
* Ensure that temporary files are removed.
+ *
+ * Create files for all the possible combinations of age and status. We are
+ * using UPDATE statments rather than file_save() because it would set the
+ * timestamp.
*/
function testTempFileCleanup() {
- // Create files for all the possible combinations of age and status. We're
- // using UPDATE statments rather than file_save() because it would set the
- // timestamp.
-
// Temporary file that is older than DRUPAL_MAXIMUM_TEMP_FILE_AGE.
$temp_old = file_save_data('');
db_update('file')