public function FeedsRSStoNodesTest::testClearInBackground in Feeds 7.2
Tests clearing items in background.
File
- tests/
feeds_processor_node.test, line 599 - Tests for plugins/FeedsNodeProcessor.inc.
Class
- FeedsRSStoNodesTest
- Test aggregating a feed as node items.
Code
public function testClearInBackground() {
// Just remove the mappings rather than creating a new importer.
$this
->removeMappings('syndication', $this
->getCurrentMappings('syndication'));
$this
->setSettings('syndication', NULL, array(
'content_type' => '',
));
$this
->setPlugin('syndication', 'FeedsFileFetcher');
$this
->setPlugin('syndication', 'FeedsCSVParser');
$this
->addMappings('syndication', array(
0 => array(
'source' => 'title',
'target' => 'title',
),
1 => array(
'source' => 'GUID',
'target' => 'guid',
'unique' => TRUE,
),
));
// Import 86 nodes.
$this
->importFile('syndication', $this
->absolutePath() . '/tests/feeds/many_nodes_ordered.csv');
$this
->assertEqual(86, db_query("SELECT COUNT(*) FROM {node}")
->fetchField());
// Turn on "Process in background option" and turn off periodic import.
$this
->setSettings('syndication', NULL, array(
'process_in_background' => TRUE,
'import_period' => FEEDS_SCHEDULE_NEVER,
));
// Now schedule clearing in background.
$this
->drupalPost('import/syndication/delete-items', array(), t('Schedule delete'));
$this
->assertEqual(86, db_query("SELECT COUNT(*) FROM {node}")
->fetchField());
// Assert that the delete button is disabled.
$this
->drupalGet('import/syndication/delete-items');
$this
->assertFieldDisabled('op');
// Assert that there is one clear task in the queue.
$this
->assertEqual(1, db_query("SELECT COUNT(*) FROM {queue} WHERE name = 'feeds_source_clear'")
->fetchField());
// And run cron.
$this
->cronRun();
$this
->assertEqual(0, db_query("SELECT COUNT(*) FROM {node}")
->fetchField());
// Assert that the delete button is no longer disabled.
$this
->drupalGet('import/syndication/delete-items');
$this
->assertFieldEnabled('op');
// Assert that there are no more clear tasks in the queue.
$this
->assertEqual(0, db_query("SELECT COUNT(*) FROM {queue} WHERE name = 'feeds_source_clear'")
->fetchField());
}