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