View source
<?php
require_once drupal_get_path('module', 'feeds') . '/tests/feeds_mapper_test.inc';
class FeedsMapperOGTestCase extends FeedsMapperTestCase {
public static function getInfo() {
return array(
'name' => t('Mapper: Organic Groups'),
'description' => t('Test Feeds Mapper support for Organic Groups (Language). <strong>Requires Organic Groups module</strong>.'),
'group' => t('Feeds'),
);
}
function setUp() {
parent::setUp('feeds', 'feeds_ui', 'ctools', 'job_scheduler', 'og');
$this
->drupalLogin($this
->drupalCreateUser(array(
'administer content types',
'administer feeds',
'administer nodes',
'administer site configuration',
'administer organic groups',
)));
$edit = array(
'name' => 'Group',
'type' => 'group',
'og_content_type_usage' => 'group',
);
$this
->drupalPost('admin/content/types/add', $edit, t('Save content type'));
$edit = array(
'og_content_type_usage' => 'group_post_standard',
);
foreach (array(
'article',
'page',
) as $type) {
$this
->drupalPost("admin/content/node-type/{$type}", $edit, t('Save content type'));
}
$this
->createImporterConfiguration('Syndication', 'syndication');
$this
->addMappings('syndication', array(
array(
'source' => 'title',
'target' => 'title',
'unique' => FALSE,
),
array(
'source' => 'description',
'target' => 'body',
'unique' => FALSE,
),
array(
'source' => 'timestamp',
'target' => 'created',
'unique' => FALSE,
),
array(
'source' => 'url',
'target' => 'url',
'unique' => TRUE,
),
array(
'source' => 'guid',
'target' => 'guid',
'unique' => TRUE,
),
));
}
function testInheritOG() {
$this
->addMappings('syndication', array(
array(
'source' => 'parent:og_groups',
'target' => 'og_groups',
),
));
$edit = array(
'title' => 'Group A',
'og_description' => 'Test group.',
);
$this
->drupalPost('node/add/group', $edit, 'Save');
$group_nid = $this
->getNid($this
->getUrl());
$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 = db_query("SELECT COUNT(*) FROM {og_ancestry} WHERE group_nid = :nid", array(
':nid' => $group_nid,
))
->fetchField();
$this
->assertEqual(11, $count, 'Found correct number of nodes in group.');
$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 = db_query("SELECT COUNT(*) FROM {og_ancestry} WHERE group_nid = :nid", array(
':nid' => $group_nid,
))
->fetchField();
$this
->assertEqual(10, $count, 'Found correct number of nodes in group.');
}
}