1 |
85ad3d82
|
Assos Assos
|
<?php
|
2 |
|
|
|
3 |
|
|
/**
|
4 |
|
|
* @file
|
5 |
41cc1b08
|
Assos Assos
|
* Contains FeedsMapperConfigTestCase.
|
6 |
85ad3d82
|
Assos Assos
|
*/
|
7 |
|
|
|
8 |
|
|
/**
|
9 |
41cc1b08
|
Assos Assos
|
* Test cases for Feeds mapping configuration form.
|
10 |
85ad3d82
|
Assos Assos
|
*/
|
11 |
|
|
class FeedsMapperConfigTestCase extends FeedsMapperTestCase {
|
12 |
41cc1b08
|
Assos Assos
|
|
13 |
85ad3d82
|
Assos Assos
|
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 |
41cc1b08
|
Assos Assos
|
$second_callback_value = $this->randomString();
|
42 |
|
|
|
43 |
85ad3d82
|
Assos Assos
|
// 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 |
41cc1b08
|
Assos Assos
|
'config[0][settings][second_value]' => $second_callback_value,
|
51 |
85ad3d82
|
Assos Assos
|
);
|
52 |
|
|
$this->drupalPostAJAX(NULL, $edit, 'mapping_settings_update_0');
|
53 |
41cc1b08
|
Assos Assos
|
$this->assertText(t('* Changes made to target configuration are stored temporarily. Click Save to make your changes permanent.'));
|
54 |
85ad3d82
|
Assos Assos
|
|
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 |
41cc1b08
|
Assos Assos
|
$this->assertText(t('Second summary: @value', array('@value' => $second_callback_value)));
|
68 |
85ad3d82
|
Assos Assos
|
|
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 |
41cc1b08
|
Assos Assos
|
$this->assertEqual($settings['second_value'], $second_callback_value);
|
79 |
85ad3d82
|
Assos Assos
|
|
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 |
41cc1b08
|
Assos Assos
|
|
122 |
85ad3d82
|
Assos Assos
|
} |