public function FeedsFileFetcherTestCase::testPublicFiles in Feeds 7.2
Test scheduling on cron.
File
- tests/
feeds_fetcher_file.test, line 47 - File fetcher tests.
Class
- FeedsFileFetcherTestCase
- File fetcher test class.
Code
public function testPublicFiles() {
// Straight up upload is covered in other tests, focus on direct mode and
// file batching here.
$settings = array(
'direct' => TRUE,
'directory' => 'public://feeds',
);
$this
->setSettings('node', 'FeedsFileFetcher', $settings);
// Verify that invalid paths are not accepted.
foreach (array(
'/tmp/',
) as $path) {
$edit = array(
'feeds[FeedsFileFetcher][source]' => $path,
);
$this
->drupalPost('import/node', $edit, t('Import'));
$this
->assertText("The file needs to reside within the site's files directory, its path needs to start with scheme://. Available schemes:");
$count = db_query("SELECT COUNT(*) FROM {feeds_source} WHERE feed_nid = 0")
->fetchField();
$this
->assertEqual($count, 0);
}
// Verify batching through directories.
// Copy directory of files.
$dir = 'public://batchtest';
$this
->copyDir($this
->absolutePath() . '/tests/feeds/batch', $dir);
// Ingest directory of files. Set limit to 5 to force processor to batch,
// too.
variable_set('feeds_process_limit', 5);
$edit = array(
'feeds[FeedsFileFetcher][source]' => $dir,
);
$this
->drupalPost('import/node', $edit, t('Import'));
$this
->assertText('Created 18 nodes');
}