source: sipes/modules_contrib/feeds/tests/feeds_mapper_og.test @ 92213c1

stableversion-3.0
Last change on this file since 92213c1 was 177a560, checked in by José Gregorio Puentes <jpuentes@…>, 8 años ago

se agrego el directorio de modulos contribuidos de drupal

  • Propiedad mode establecida a 100755
File size: 3.7 KB
Línea 
1<?php
2module_load_include('test', 'feeds', 'tests/feeds_mapper');
3
4/**
5 * @file
6 * Test case for OG mapper mappers/og.inc.
7 */
8
9/**
10 * Class for testing Feeds <em>locale</em> mapper.
11 */
12class FeedsMapperOGTestCase extends FeedsMapperTestCase {
13  public static function getInfo() {
14    return array(
15      'name' => 'Mapper: Organic Groups',
16      'description' => 'Test Feeds Mapper support for Organic Groups (Language).',
17      'group' => 'Feeds',
18      'dependencies' => array('og'),
19    );
20  }
21
22  function setUp() {
23    parent::setUp(array('og'), array('administer organic groups'));
24
25    // Add and configure a group content type, configure story, page type.
26    $edit = array(
27      'name' => 'Group',
28      'type' => 'group',
29      'og_content_type_usage' => 'group',
30    );
31    $this->drupalPost('admin/content/types/add', $edit, t('Save content type'));
32    $edit = array(
33      'og_content_type_usage' => 'group_post_standard',
34    );
35    foreach (array('story', 'page') as $type) {
36      $this->drupalPost("admin/content/node-type/$type", $edit, t('Save content type'));
37    }
38
39    // Create an importer configuration with basic mapping.
40    $this->createImporterConfiguration('Syndication', 'syndication');
41    $this->addMappings('syndication',
42      array(
43        array(
44          'source' => 'title',
45          'target' => 'title',
46          'unique' => FALSE,
47        ),
48        array(
49          'source' => 'description',
50          'target' => 'body',
51          'unique' => FALSE,
52        ),
53        array(
54          'source' => 'timestamp',
55          'target' => 'created',
56          'unique' => FALSE,
57        ),
58        array(
59          'source' => 'url',
60          'target' => 'url',
61          'unique' => TRUE,
62        ),
63        array(
64          'source' => 'guid',
65          'target' => 'guid',
66          'unique' => TRUE,
67        ),
68      )
69    );
70  }
71
72  /**
73   * Test inheriting groups from the feed node.
74   */
75  function testInheritOG() {
76    // Map feed node's group to feed item node's language.
77    $this->addMappings('syndication',
78      array(
79        array(
80          'source' => 'parent:og_groups',
81          'target' => 'og_groups',
82        ),
83      )
84    );
85
86    // Create a group node.
87    $edit = array(
88      'title' => 'Group A',
89      'og_description' => 'Test group.',
90    );
91    $this->drupalPost('node/add/group', $edit, 'Save');
92    $group_nid = $this->getNid($this->getUrl());
93
94    // Create a feed node, add to group created above.
95    $edit = array(
96      'feeds[FeedsHTTPFetcher][source]' => $GLOBALS['base_url'] .'/'. drupal_get_path('module', 'feeds') .'/tests/feeds/developmentseed.rss2',
97      'og_groups[1]' => TRUE,
98    );
99    $this->drupalPost('node/add/page', $edit, 'Save');
100
101    // Count number of items for this group, should be 11.
102    $count = db_result(db_query("SELECT COUNT(*) FROM {og_ancestry} WHERE group_nid = %d", $group_nid));
103    $this->assertEqual(11, $count, 'Found correct number of nodes in group.');
104
105    // Make page (= feed content type) itself a group content type, test again.
106    $edit = array(
107      'og_content_type_usage' => 'group',
108    );
109    $this->drupalPost('admin/content/node-type/page', $edit, 'Save content type');
110    $edit = array(
111      'feeds[FeedsHTTPFetcher][source]' => $GLOBALS['base_url'] .'/'. drupal_get_path('module', 'feeds') .'/tests/feeds/developmentseed.rss2',
112      'og_description' => 'This is a feed node that is an organic group at the same time.',
113    );
114    $this->drupalPost('node/add/page', $edit, 'Save');
115    $group_nid = $this->getNid($this->getUrl());
116
117    // Count number of items for this group, should be 10.
118    $count = db_result(db_query("SELECT COUNT(*) FROM {og_ancestry} WHERE group_nid = %d", $group_nid));
119    $this->assertEqual(10, $count, 'Found correct number of nodes in group.');
120  }
121}
Nota: Vea TracBrowser para ayuda de uso del navegador del repositorio.