1 |
85ad3d82
|
Assos Assos
|
<?php
|
2 |
|
|
|
3 |
|
|
/**
|
4 |
|
|
* @file
|
5 |
|
|
* Test cases for Feeds mapping configuration form.
|
6 |
|
|
*/
|
7 |
|
|
|
8 |
|
|
/**
|
9 |
|
|
* Class for testing basic Feeds ajax mapping configurtaion form behavior.
|
10 |
|
|
*/
|
11 |
|
|
class FeedsMapperConfigTestCase extends FeedsMapperTestCase {
|
12 |
|
|
public static function getInfo() {
|
13 |
|
|
return array(
|
14 |
|
|
'name' => 'Mapper: Config',
|
15 |
|
|
'description' => 'Test the mapper configuration UI.',
|
16 |
|
|
'group' => 'Feeds',
|
17 |
|
|
);
|
18 |
|
|
}
|
19 |
|
|
|
20 |
|
|
public function setUp() {
|
21 |
|
|
parent::setUp(array('feeds_tests'));
|
22 |
|
|
}
|
23 |
|
|
|
24 |
|
|
/**
|
25 |
|
|
* Basic test of mapping configuration.
|
26 |
|
|
*/
|
27 |
|
|
public function test() {
|
28 |
|
|
// Create importer configuration.
|
29 |
|
|
$this->createImporterConfiguration();
|
30 |
|
|
$this->addMappings('syndication', array(
|
31 |
|
|
array(
|
32 |
|
|
'source' => 'url',
|
33 |
|
|
'target' => 'test_target',
|
34 |
|
|
),
|
35 |
|
|
));
|
36 |
|
|
|
37 |
|
|
// Click gear to get form.
|
38 |
|
|
$this->drupalPostAJAX(NULL, array(), 'mapping_settings_edit_0');
|
39 |
|
|
|
40 |
|
|
// Set some settings.
|
41 |
|
|
$edit = array(
|
42 |
|
|
'config[0][settings][checkbox]' => 1,
|
43 |
|
|
'config[0][settings][textfield]' => 'Some text',
|
44 |
|
|
'config[0][settings][textarea]' => 'Textarea value: Didery dofffffffffffffffffffffffffffffffffffff',
|
45 |
|
|
'config[0][settings][radios]' => 'option1',
|
46 |
|
|
'config[0][settings][select]' => 'option4',
|
47 |
|
|
);
|
48 |
|
|
$this->drupalPostAJAX(NULL, $edit, 'mapping_settings_update_0');
|
49 |
|
|
|
50 |
|
|
// Click Save.
|
51 |
|
|
$this->drupalPost(NULL, array(), t('Save'));
|
52 |
|
|
|
53 |
|
|
// Reload.
|
54 |
|
|
$this->drupalGet('admin/structure/feeds/syndication/mapping');
|
55 |
|
|
|
56 |
|
|
// See if our settings were saved.
|
57 |
|
|
$this->assertText('Checkbox active.');
|
58 |
|
|
$this->assertText('Textfield value: Some text');
|
59 |
|
|
$this->assertText('Textarea value: Didery dofffffffffffffffffffffffffffffffffffff');
|
60 |
|
|
$this->assertText('Radios value: Option 1');
|
61 |
|
|
$this->assertText('Select value: Another One');
|
62 |
|
|
|
63 |
|
|
// Check that settings are in db.
|
64 |
|
|
$config = unserialize(db_query("SELECT config FROM {feeds_importer} WHERE id='syndication'")->fetchField());
|
65 |
|
|
|
66 |
|
|
$settings = $config['processor']['config']['mappings'][0];
|
67 |
|
|
$this->assertEqual($settings['checkbox'], 1);
|
68 |
|
|
$this->assertEqual($settings['textfield'], 'Some text');
|
69 |
|
|
$this->assertEqual($settings['textarea'], 'Textarea value: Didery dofffffffffffffffffffffffffffffffffffff');
|
70 |
|
|
$this->assertEqual($settings['radios'], 'option1');
|
71 |
|
|
$this->assertEqual($settings['select'], 'option4');
|
72 |
|
|
|
73 |
|
|
|
74 |
|
|
// Check that form validation works.
|
75 |
|
|
// Click gear to get form.
|
76 |
|
|
$this->drupalPostAJAX(NULL, array(), 'mapping_settings_edit_0');
|
77 |
|
|
|
78 |
|
|
// Set some settings.
|
79 |
|
|
$edit = array(
|
80 |
|
|
// Required form item.
|
81 |
|
|
'config[0][settings][textfield]' => '',
|
82 |
|
|
);
|
83 |
|
|
$this->drupalPostAJAX(NULL, $edit, 'mapping_settings_update_0');
|
84 |
|
|
$this->assertText('A text field field is required.');
|
85 |
|
|
$this->drupalPost(NULL, array(), t('Save'));
|
86 |
|
|
// Reload.
|
87 |
|
|
$this->drupalGet('admin/structure/feeds/syndication/mapping');
|
88 |
|
|
// Value has not changed.
|
89 |
|
|
$this->assertText('Textfield value: Some text');
|
90 |
|
|
|
91 |
|
|
// Check that multiple mappings work.
|
92 |
|
|
$this->addMappings('syndication', array(
|
93 |
|
|
1 => array(
|
94 |
|
|
'source' => 'url',
|
95 |
|
|
'target' => 'test_target',
|
96 |
|
|
),
|
97 |
|
|
));
|
98 |
|
|
$this->assertText('Checkbox active.');
|
99 |
|
|
$this->assertText('Checkbox inactive.');
|
100 |
|
|
// Click gear to get form.
|
101 |
|
|
$this->drupalPostAJAX(NULL, array(), 'mapping_settings_edit_1');
|
102 |
|
|
// Set some settings.
|
103 |
|
|
$edit = array(
|
104 |
|
|
'config[1][settings][textfield]' => 'Second mapping text',
|
105 |
|
|
);
|
106 |
|
|
$this->drupalPostAJAX(NULL, $edit, 'mapping_settings_update_1');
|
107 |
|
|
// Click Save.
|
108 |
|
|
$this->drupalPost(NULL, array(), t('Save'));
|
109 |
|
|
// Reload.
|
110 |
|
|
$this->drupalGet('admin/structure/feeds/syndication/mapping');
|
111 |
|
|
$this->assertText('Checkbox active.');
|
112 |
|
|
$this->assertText('Checkbox inactive.');
|
113 |
|
|
$this->assertText('Second mapping text');
|
114 |
|
|
}
|
115 |
|
|
} |