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