public function FeedsRSStoNodesTest::testImportInBackground in Feeds 7.2
Tests process in background option.
File
- tests/
feeds_processor_node.test, line 549 - Tests for plugins/FeedsNodeProcessor.inc.
Class
- FeedsRSStoNodesTest
- Test aggregating a feed as node items.
Code
public function testImportInBackground() {
// Just remove the mappings rather than creating a new importer.
$this
->removeMappings('syndication', $this
->getCurrentMappings('syndication'));
$this
->setPlugin('syndication', 'FeedsFileFetcher');
$this
->setPlugin('syndication', 'FeedsCSVParser');
$this
->setSettings('syndication', NULL, array(
'content_type' => '',
'process_in_background' => TRUE,
'import_period' => FEEDS_SCHEDULE_NEVER,
));
$this
->addMappings('syndication', array(
0 => array(
'source' => 'title',
'target' => 'title',
),
1 => array(
'source' => 'GUID',
'target' => 'guid',
'unique' => TRUE,
),
));
$this
->importFile('syndication', $this
->absolutePath() . '/tests/feeds/many_nodes_ordered.csv', 'Schedule import');
$this
->assertEqual(0, db_query("SELECT COUNT(*) FROM {node}")
->fetchField());
// Assert that the import button is disabled.
$this
->assertFieldDisabled('op');
// Assert that there is one import task in the queue.
$this
->assertEqual(1, db_query("SELECT COUNT(*) FROM {queue} WHERE name = 'feeds_source_import'")
->fetchField());
// The feed should still be scheduled because it is being processed.
// @see https://drupal.org/node/2275893
$this
->cronRun();
$this
->assertEqual(86, db_query("SELECT COUNT(*) FROM {node}")
->fetchField());
// Assert that the import button is no longer disabled.
$this
->drupalGet('import/syndication');
$this
->assertFieldEnabled('op');
// Assert that there are no more import tasks in the queue.
$this
->assertEqual(0, db_query("SELECT COUNT(*) FROM {queue} WHERE name = 'feeds_source_import'")
->fetchField());
}