public function FeedsFileHTTPTestCase::testCachedFilesCleanupQueue in Feeds 7.2
Tests if the cron task for cleaning up cached files are run one at a time.
File
- tests/
feeds_fetcher_http.test, line 386 - Contains FeedsFileHTTPTestCase.
Class
- FeedsFileHTTPTestCase
- HTTP fetcher test class.
Code
public function testCachedFilesCleanupQueue() {
$queue = DrupalQueue::get('feeds_sync_cache_feeds_http');
// First, make sure that a queue task is only ran every six hours.
variable_set('feeds_sync_cache_feeds_http_last_check', REQUEST_TIME);
// Run cron without executing the queue tasks.
feeds_cron();
// Assert that no task was created for cleaning up the files.
$this
->assertEqual(0, $queue
->numberOfItems(), 'No task was created for the feeds_sync_cache_feeds_http queue.');
// Unset last check and run cron.
variable_del('feeds_sync_cache_feeds_http_last_check');
feeds_cron();
// Assert that one task was created for cleaning up the files and that the
// variable for the last check was updated.
$this
->assertEqual(1, $queue
->numberOfItems(), 'One task was created for the feeds_sync_cache_feeds_http queue.');
$this
->assertEqual(REQUEST_TIME, variable_get('feeds_sync_cache_feeds_http_last_check'));
// Unset last check and run cron again.
variable_del('feeds_sync_cache_feeds_http_last_check');
feeds_cron();
// Assert that there still is one task.
$this
->assertEqual(1, $queue
->numberOfItems(), 'One task exists for the feeds_sync_cache_feeds_http queue.');
$this
->assertEqual(REQUEST_TIME, variable_get('feeds_sync_cache_feeds_http_last_check'));
}