1 | <?php |
---|
2 | module_load_include('test', 'feeds', 'tests/feeds_mapper'); |
---|
3 | |
---|
4 | /** |
---|
5 | * @file |
---|
6 | * Test case for locale (language) mapper mappers/locale.inc. |
---|
7 | */ |
---|
8 | |
---|
9 | /** |
---|
10 | * Class for testing Feeds <em>locale</em> mapper. |
---|
11 | */ |
---|
12 | class FeedsMapperLocaleTestCase extends FeedsMapperTestCase { |
---|
13 | public static function getInfo() { |
---|
14 | return array( |
---|
15 | 'name' => 'Mapper: Locale', |
---|
16 | 'description' => 'Test Feeds Mapper support for Locale (Language).', |
---|
17 | 'group' => 'Feeds', |
---|
18 | ); |
---|
19 | } |
---|
20 | |
---|
21 | function setUp() { |
---|
22 | parent::setUp(array('locale'), array('administer languages')); |
---|
23 | |
---|
24 | // Add an additional language and enable it for page and story. |
---|
25 | $edit = array( |
---|
26 | 'langcode' => 'zh-hans', |
---|
27 | ); |
---|
28 | $this->drupalPost('admin/settings/language/add', $edit, t('Add language')); |
---|
29 | $this->assertText('The language Chinese, Simplified has been created and can now be used.'); |
---|
30 | $edit = array( |
---|
31 | 'language_content_type' => TRUE, |
---|
32 | ); |
---|
33 | foreach (array('story', 'page') as $type) { |
---|
34 | $this->drupalPost("admin/content/node-type/$type", $edit, t('Save content type')); |
---|
35 | } |
---|
36 | |
---|
37 | // Create an importer configuration with basic mapping. |
---|
38 | $this->createImporterConfiguration('Syndication', 'syndication'); |
---|
39 | $this->addMappings('syndication', |
---|
40 | array( |
---|
41 | array( |
---|
42 | 'source' => 'title', |
---|
43 | 'target' => 'title', |
---|
44 | 'unique' => FALSE, |
---|
45 | ), |
---|
46 | array( |
---|
47 | 'source' => 'description', |
---|
48 | 'target' => 'body', |
---|
49 | 'unique' => FALSE, |
---|
50 | ), |
---|
51 | array( |
---|
52 | 'source' => 'timestamp', |
---|
53 | 'target' => 'created', |
---|
54 | 'unique' => FALSE, |
---|
55 | ), |
---|
56 | array( |
---|
57 | 'source' => 'url', |
---|
58 | 'target' => 'url', |
---|
59 | 'unique' => TRUE, |
---|
60 | ), |
---|
61 | array( |
---|
62 | 'source' => 'guid', |
---|
63 | 'target' => 'guid', |
---|
64 | 'unique' => TRUE, |
---|
65 | ), |
---|
66 | ) |
---|
67 | ); |
---|
68 | } |
---|
69 | |
---|
70 | /** |
---|
71 | * Test inheriting language from the feed node. |
---|
72 | */ |
---|
73 | function testInheritLanguage() { |
---|
74 | // Map feed node's language to feed item node's language. |
---|
75 | $this->addMappings('syndication', |
---|
76 | array( |
---|
77 | array( |
---|
78 | 'source' => 'parent:language', |
---|
79 | 'target' => 'language', |
---|
80 | ), |
---|
81 | ) |
---|
82 | ); |
---|
83 | // Turn off import on create, create feed node, add language, import. |
---|
84 | $edit = array( |
---|
85 | 'import_on_create' => FALSE, |
---|
86 | ); |
---|
87 | $this->drupalPost('admin/build/feeds/edit/syndication/settings', $edit, 'Save'); |
---|
88 | $this->assertText('Do not import on create'); |
---|
89 | $nid = $this->createFeedNode(); |
---|
90 | $edit = array( |
---|
91 | 'language' => 'zh-hans', |
---|
92 | ); |
---|
93 | $this->drupalPost("node/$nid/edit", $edit, t('Save')); |
---|
94 | $this->drupalPost('node/'. $nid .'/import', array(), 'Import'); |
---|
95 | $count = db_result(db_query("SELECT COUNT(*) FROM {node} WHERE language = 'zh-hans'")); |
---|
96 | $this->assertEqual(11, $count, 'Found correct number of nodes.'); |
---|
97 | } |
---|
98 | } |
---|