public function FeedsFileHTTPTestCase::testHTTPCacheOverride in Feeds 7.2
Tests if the data is cached on the file system even when a different cache class is used.
This can happen when using Memcache or Redis for all cache bins.
File
- tests/
feeds_fetcher_http.test, line 315 - Contains FeedsFileHTTPTestCase.
Class
- FeedsFileHTTPTestCase
- HTTP fetcher test class.
Code
public function testHTTPCacheOverride() {
// Revert back to the default cache class.
variable_set('cache_class_cache_feeds_http', 'DrupalDatabaseCache');
// Import. We cannot test with a simple feeds_http_request() call here,
// because there is no way to override a cache class on a single request.
// @see _cache_get_object().
$this
->setUpImporter();
$source_url = url('testing/feeds/nodes.csv', array(
'absolute' => TRUE,
));
$edit = array(
'feeds[FeedsHTTPFetcher][source]' => $source_url,
);
$this
->drupalPost('import/node', $edit, t('Import'));
$this
->assertText('Created 9 nodes');
// Assert that the raw data is not saved in the database.
$count = db_select('cache_feeds_http')
->condition('data', '%Title,Body,published,GUID%', 'LIKE')
->countQuery()
->execute()
->fetchField();
$this
->assertEqual(0, $count, 'Raw source was not saved in the database.');
// Assert that a file was created.
$file_url = 'private://feeds/cache/' . hash('sha256', $source_url);
$this
->assertTrue(file_exists($file_url), format_string('The file @file_url exists.', array(
'@file_url' => $file_url,
)));
}