public function FeedsAccountSwitcherTest::testRunImportAsFeedNodeAuthorOnCron in Feeds 7.2
Tests if the import is ran as the feed node author when using cron.
File
- tests/
FeedsAccountSwitcherTest.test, line 105 - Contains FeedsAccountSwitcherTest.
Class
- FeedsAccountSwitcherTest
- Test case for account switching.
Code
public function testRunImportAsFeedNodeAuthorOnCron() {
// Use the CSV parser.
$this
->setPlugin('syndication', 'FeedsCSVParser');
// Run import in background.
$this
->setSettings('syndication', NULL, array(
'process_in_background' => TRUE,
));
// Make the feeds_tests module set the uid source to the current user.
variable_set('feeds_tests_set_uid_current_user', TRUE);
// And map to 'uid'.
$this
->addMappings('syndication', array(
1 => array(
'source' => 'uid',
'target' => 'uid',
),
));
// Create a feed node and change author of node.
$nid = $this
->createFeedNode('syndication', $GLOBALS['base_url'] . '/' . drupal_get_path('module', 'feeds') . '/tests/feeds/content.csv', 'Node 1');
$account = $this
->drupalCreateUser(array(
'access content',
'create article content',
));
$this
->changeNodeAuthor($nid, $account);
// Schedule import and run cron.
$this
->drupalPost('node/' . $nid . '/import', NULL, 'Schedule import');
$this
->cronRun();
// Assert that the author of the created nodes is from the created account.
$node = node_load(2);
$this
->assertEqual($account->uid, $node->uid, format_string('The author of the imported node is set to @expected (actual: @actual).', array(
'@expected' => $account->uid,
'@actual' => $node->uid,
)));
}