You are here

public function FeedsAccountSwitcherTest::testRunImportAsFeedNodeAuthorInUI in Feeds 7.2

Tests if the import is ran as the feed node author when using the UI.

File

tests/FeedsAccountSwitcherTest.test, line 56
Contains FeedsAccountSwitcherTest.

Class

FeedsAccountSwitcherTest
Test case for account switching.

Code

public function testRunImportAsFeedNodeAuthorInUI() {

  // Assert that the admin user is logged in.
  $this
    ->drupalGet('user');
  $this
    ->clickLink('Edit');
  $this
    ->assertUrl('user/' . $this->admin_user->uid . '/edit');

  // Use the CSV parser.
  $this
    ->setPlugin('syndication', 'FeedsCSVParser');

  // 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);

  // And perform import.
  $this
    ->drupalPost('node/' . $nid . '/import', NULL, 'Import');
  $this
    ->assertText('Created 2 nodes');

  // 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,
  )));

  // Assert that the admin user is still logged in.
  $this
    ->drupalGet('user');
  $this
    ->clickLink('Edit');
  $this
    ->assertUrl('user/' . $this->admin_user->uid . '/edit');
}