You are here

function FeedsMapperOGTestCase::testInheritOG in Feeds 6

Same name and namespace in other branches
  1. 7 tests/feeds_mapper_og.test \FeedsMapperOGTestCase::testInheritOG()

Test inheriting groups from the feed node.

File

tests/feeds_mapper_og.test, line 75
Test case for OG mapper mappers/og.inc.

Class

FeedsMapperOGTestCase
Class for testing Feeds <em>locale</em> mapper.

Code

function testInheritOG() {

  // Map feed node's group to feed item node's language.
  $this
    ->addMappings('syndication', array(
    array(
      'source' => 'parent:og_groups',
      'target' => 'og_groups',
    ),
  ));

  // Create a group node.
  $edit = array(
    'title' => 'Group A',
    'og_description' => 'Test group.',
  );
  $this
    ->drupalPost('node/add/group', $edit, 'Save');
  $group_nid = $this
    ->getNid($this
    ->getUrl());

  // Create a feed node, add to group created above.
  $edit = array(
    'feeds[FeedsHTTPFetcher][source]' => $GLOBALS['base_url'] . '/' . drupal_get_path('module', 'feeds') . '/tests/feeds/developmentseed.rss2',
    'og_groups[1]' => TRUE,
  );
  $this
    ->drupalPost('node/add/page', $edit, 'Save');

  // Count number of items for this group, should be 11.
  $count = db_result(db_query("SELECT COUNT(*) FROM {og_ancestry} WHERE group_nid = %d", $group_nid));
  $this
    ->assertEqual(11, $count, 'Found correct number of nodes in group.');

  // Make page (= feed content type) itself a group content type, test again.
  $edit = array(
    'og_content_type_usage' => 'group',
  );
  $this
    ->drupalPost('admin/content/node-type/page', $edit, 'Save content type');
  $edit = array(
    'feeds[FeedsHTTPFetcher][source]' => $GLOBALS['base_url'] . '/' . drupal_get_path('module', 'feeds') . '/tests/feeds/developmentseed.rss2',
    'og_description' => 'This is a feed node that is an organic group at the same time.',
  );
  $this
    ->drupalPost('node/add/page', $edit, 'Save');
  $group_nid = $this
    ->getNid($this
    ->getUrl());

  // Count number of items for this group, should be 10.
  $count = db_result(db_query("SELECT COUNT(*) FROM {og_ancestry} WHERE group_nid = %d", $group_nid));
  $this
    ->assertEqual(10, $count, 'Found correct number of nodes in group.');
}