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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
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
<?php
/**
* Tests for hooks invoked by Feeds not related to mapping.
*/
class FeedsHooksTestCase extends FeedsWebTestCase {
/**
* {@inheritdoc}
*/
public static function getInfo() {
return array(
'name' => 'Hooks',
'description' => 'Tests for hooks invoked by Feeds not related to mapping.',
'group' => 'Feeds',
);
}
/**
* Tests the hook hook_config_defaults().
*/
public function testHookConfigDefaults() {
// Switch on hook implementations in the feeds_tests module.
variable_set('feeds_tests_hook_config_defaults', TRUE);
$this->createImporterConfiguration('Config defaults test', 'config_defaults_test');
// Load the importer and check the default value for
// 'feeds_tests_extra_setting'.
$importer = feeds_importer_load('config_defaults_test');
$importer_config = $importer->getConfig();
$this->assertFalse($importer_config['feeds_tests_extra_setting'], "Option 'Extra setting' is disabled.");
// Assert that other configurables do not have this setting.
$fetcher_config = $importer->fetcher->getConfig();
$parser_config = $importer->fetcher->getConfig();
$processor_config = $importer->fetcher->getConfig();
$this->assertFalse(isset($fetcher_config['feeds_tests_extra_setting']));
$this->assertFalse(isset($parser_config['feeds_tests_extra_setting']));
$this->assertFalse(isset($processor_config['feeds_tests_extra_setting']));
// Now change this setting.
$this->setSettings('config_defaults_test', NULL, array(
'feeds_tests_extra_setting' => TRUE,
));
// Reload the importer and assert that the configuration option changed.
drupal_static_reset();
$importer = feeds_importer_load('config_defaults_test');
$importer_config = $importer->getConfig();
$this->assertTrue($importer_config['feeds_tests_extra_setting'], "Option 'Extra setting' is enabled.");
}
/**
* Tests the hook hook_PLUGIN_TYPE_config_defaults().
*/
public function testHookPluginTypeConfigDefaults() {
// Switch on hook implementations in the feeds_tests module.
variable_set('feeds_tests_hook_config_defaults', TRUE);
$this->createImporterConfiguration('Config defaults test', 'config_defaults_test');
// Change parser plugin to CSV as the common syndication parser does not
// have a config form.
$this->setPlugin('config_defaults_test', 'FeedsCSVParser');
// Load the importer and check default values for each plugin.
$importer = feeds_importer_load('config_defaults_test');
$fetcher_config = $importer->fetcher->getConfig();
$parser_config = $importer->parser->getConfig();
$processor_config = $importer->processor->getConfig();
$this->assertFalse($fetcher_config['feeds_tests_fetcher_extra_setting'], "Option 'Extra setting' is disabled for the fetcher.");
$this->assertTrue($parser_config['feeds_tests_parser_extra_setting'], "Option 'Extra setting' is enabled for the parser.");
$this->assertEqual('', $processor_config['feeds_tests_processor_extra_setting'], "Setting 'Extra setting' is empty.");
// Assert that the setting for a particular plugin does not exists for other
// configurables.
$importer_config = $importer->getConfig();
$this->assertFalse(isset($importer_config['feeds_tests_fetcher_extra_setting']));
$this->assertFalse(isset($importer_config['feeds_tests_parser_extra_setting']));
$this->assertFalse(isset($importer_config['feeds_tests_processor_extra_setting']));
$this->assertFalse(isset($fetcher_config['feeds_tests_parser_extra_setting']));
$this->assertFalse(isset($fetcher_config['feeds_tests_processor_extra_setting']));
$this->assertFalse(isset($parser_config['feeds_tests_fetcher_extra_setting']));
$this->assertFalse(isset($parser_config['feeds_tests_processor_extra_setting']));
$this->assertFalse(isset($processor_config['feeds_tests_fetcher_extra_setting']));
$this->assertFalse(isset($processor_config['feeds_tests_parser_extra_setting']));
// Now change the settings for each plugin.
$this->setSettings('config_defaults_test', 'FeedsHTTPFetcher', array(
'feeds_tests_fetcher_extra_setting' => TRUE,
));
$this->setSettings('config_defaults_test', 'FeedsCSVParser', array(
'feeds_tests_parser_extra_setting' => FALSE,
));
$this->setSettings('config_defaults_test', 'FeedsNodeProcessor', array(
'feeds_tests_processor_extra_setting' => 'my setting',
));
// Reload the importer and assert that the configuration changed.
drupal_static_reset();
$importer = feeds_importer_load('config_defaults_test');
$fetcher_config = $importer->fetcher->getConfig();
$parser_config = $importer->parser->getConfig();
$processor_config = $importer->processor->getConfig();
$this->assertTrue($fetcher_config['feeds_tests_fetcher_extra_setting'], "Option 'Extra setting' is enabled for the fetcher.");
$this->assertFalse($parser_config['feeds_tests_parser_extra_setting'], "Option 'Extra setting' is disabled for the parser.");
$this->assertEqual('my setting', $processor_config['feeds_tests_processor_extra_setting'], "Setting 'Extra setting' is 'my setting'.");
}
}