1 |
85ad3d82
|
Assos Assos
|
<?php
|
2 |
|
|
|
3 |
|
|
/**
|
4 |
|
|
* @file
|
5 |
|
|
* Tests for Feeds Admin UI module.
|
6 |
|
|
*/
|
7 |
|
|
|
8 |
|
|
/**
|
9 |
|
|
* Test basic Feeds UI functionality.
|
10 |
|
|
*/
|
11 |
|
|
class FeedsUIUserInterfaceTestCase extends FeedsWebTestCase {
|
12 |
|
|
public static function getInfo() {
|
13 |
|
|
return array(
|
14 |
|
|
'name' => 'Feeds UI user interface',
|
15 |
|
|
'description' => 'Tests Feeds Admin UI module\'s GUI.',
|
16 |
|
|
'group' => 'Feeds',
|
17 |
|
|
);
|
18 |
|
|
}
|
19 |
|
|
|
20 |
41cc1b08
|
Assos Assos
|
public function setUp() {
|
21 |
|
|
parent::setUp(array('php'), array('use PHP for settings'));
|
22 |
|
|
}
|
23 |
|
|
|
24 |
85ad3d82
|
Assos Assos
|
/**
|
25 |
|
|
* UI functionality tests on
|
26 |
|
|
* feeds_ui_overview(),
|
27 |
|
|
* feeds_ui_create_form(),
|
28 |
|
|
* Change plugins on feeds_ui_edit_page().
|
29 |
|
|
*/
|
30 |
|
|
public function testEditFeedConfiguration() {
|
31 |
|
|
|
32 |
|
|
// Create an importer.
|
33 |
|
|
$this->createImporterConfiguration('Test feed', 'test_feed');
|
34 |
|
|
|
35 |
|
|
// Assert UI elements.
|
36 |
|
|
$this->drupalGet('admin/structure/feeds/test_feed');
|
37 |
|
|
$this->assertText('Basic settings');
|
38 |
|
|
$this->assertText('Fetcher');
|
39 |
|
|
$this->assertText('HTTP Fetcher');
|
40 |
|
|
$this->assertText('Parser');
|
41 |
|
|
$this->assertText('Common syndication parser');
|
42 |
|
|
$this->assertText('Processor');
|
43 |
|
|
$this->assertText('Node processor');
|
44 |
|
|
$this->assertText('Getting started');
|
45 |
|
|
$this->assertRaw('admin/structure/feeds/test_feed/settings');
|
46 |
|
|
$this->assertRaw('admin/structure/feeds/test_feed/settings/FeedsNodeProcessor');
|
47 |
|
|
$this->assertRaw('admin/structure/feeds/test_feed/fetcher');
|
48 |
|
|
$this->assertRaw('admin/structure/feeds/test_feed/parser');
|
49 |
|
|
$this->assertRaw('admin/structure/feeds/test_feed/processor');
|
50 |
|
|
$this->drupalGet('import');
|
51 |
|
|
$this->assertText('Basic page');
|
52 |
|
|
|
53 |
|
|
// Select some other plugins.
|
54 |
|
|
$this->drupalGet('admin/structure/feeds/test_feed');
|
55 |
|
|
|
56 |
|
|
$this->clickLink('Change', 0);
|
57 |
|
|
$this->assertText('Select a fetcher');
|
58 |
|
|
$edit = array(
|
59 |
|
|
'plugin_key' => 'FeedsFileFetcher',
|
60 |
|
|
);
|
61 |
|
|
$this->drupalPost('admin/structure/feeds/test_feed/fetcher', $edit, 'Save');
|
62 |
|
|
|
63 |
|
|
$this->clickLink('Change', 1);
|
64 |
|
|
$this->assertText('Select a parser');
|
65 |
|
|
$edit = array(
|
66 |
|
|
'plugin_key' => 'FeedsCSVParser',
|
67 |
|
|
);
|
68 |
|
|
$this->drupalPost('admin/structure/feeds/test_feed/parser', $edit, 'Save');
|
69 |
|
|
|
70 |
|
|
$this->clickLink('Change', 2);
|
71 |
|
|
$this->assertText('Select a processor');
|
72 |
|
|
$edit = array(
|
73 |
|
|
'plugin_key' => 'FeedsUserProcessor',
|
74 |
|
|
);
|
75 |
|
|
$this->drupalPost('admin/structure/feeds/test_feed/processor', $edit, 'Save');
|
76 |
|
|
|
77 |
|
|
// Assert changed configuration.
|
78 |
|
|
$this->assertPlugins('test_feed', 'FeedsFileFetcher', 'FeedsCSVParser', 'FeedsUserProcessor');
|
79 |
|
|
|
80 |
|
|
// Delete importer.
|
81 |
|
|
$this->drupalPost('admin/structure/feeds/test_feed/delete', array(), 'Delete');
|
82 |
|
|
$this->drupalGet('import');
|
83 |
|
|
$this->assertNoText('Test feed');
|
84 |
|
|
|
85 |
|
|
// Create the same importer again.
|
86 |
|
|
$this->createImporterConfiguration('Test feed', 'test_feed');
|
87 |
|
|
|
88 |
|
|
// Test basic settings settings.
|
89 |
|
|
$edit = array(
|
90 |
|
|
'name' => 'Syndication feed',
|
91 |
|
|
'content_type' => 'page',
|
92 |
|
|
'import_period' => 3600,
|
93 |
|
|
);
|
94 |
|
|
$this->setSettings('test_feed', NULL, $edit);
|
95 |
|
|
|
96 |
|
|
// Assert results of change.
|
97 |
|
|
$this->assertText('Syndication feed');
|
98 |
|
|
$this->assertText('Your changes have been saved.');
|
99 |
|
|
$this->assertText('Attached to: Basic page');
|
100 |
|
|
$this->assertText('Periodic import: every 1 hour');
|
101 |
|
|
$this->drupalGet('admin/structure/feeds');
|
102 |
|
|
$this->assertLink('Basic page');
|
103 |
|
|
|
104 |
|
|
// Configure processor.
|
105 |
|
|
$this->setSettings('test_feed', 'FeedsNodeProcessor', array('bundle' => 'article'));
|
106 |
|
|
$this->assertFieldByName('bundle', 'article');
|
107 |
|
|
|
108 |
|
|
// Create a feed node.
|
109 |
|
|
$edit = array(
|
110 |
|
|
'title' => 'Development Seed',
|
111 |
|
|
'feeds[FeedsHTTPFetcher][source]' => $GLOBALS['base_url'] . '/' . drupal_get_path('module', 'feeds') . '/tests/feeds/developmentseed.rss2',
|
112 |
|
|
);
|
113 |
|
|
$this->drupalPost('node/add/page', $edit, 'Save');
|
114 |
|
|
$this->assertText('Basic page Development Seed has been created.');
|
115 |
|
|
|
116 |
|
|
// @todo Refreshing/deleting feed items. Needs to live in feeds.test
|
117 |
|
|
}
|
118 |
41cc1b08
|
Assos Assos
|
|
119 |
|
|
public function testImporterImport() {
|
120 |
|
|
$name = $this->randomString();
|
121 |
|
|
$id = drupal_strtolower($this->randomName());
|
122 |
|
|
$this->createImporterConfiguration($name, $id);
|
123 |
|
|
$this->setPlugin($id, 'FeedsCSVParser');
|
124 |
|
|
$this->setPlugin($id, 'FeedsFileFetcher');
|
125 |
|
|
$this->setPlugin($id, 'FeedsTermProcessor');
|
126 |
|
|
|
127 |
|
|
$this->setSettings($id, 'FeedsFileFetcher', array('allowed_extensions' => 'xml'));
|
128 |
|
|
$this->setSettings($id, 'FeedsCSVParser', array('delimiter' => '|'));
|
129 |
|
|
$this->setSettings($id, 'FeedsUserProcessor', array('skip_hash_check' => TRUE));
|
130 |
|
|
|
131 |
|
|
$this->drupalGet('admin/structure/feeds/' . $id . '/export');
|
132 |
|
|
|
133 |
|
|
$export = $this->xpath('//textarea[1]/text()');
|
134 |
|
|
$export = (string) $export[0];
|
135 |
|
|
|
136 |
|
|
// Delete this importer.
|
137 |
|
|
$this->drupalPost('admin/structure/feeds/' . $id . '/delete', array(), t('Delete'));
|
138 |
|
|
|
139 |
|
|
// Try to import.
|
140 |
|
|
$this->drupalPost('admin/structure/feeds/import', array('importer' => $export), t('Import'));
|
141 |
|
|
|
142 |
|
|
$this->assertText("Successfully imported the $id feeds importer.");
|
143 |
|
|
|
144 |
|
|
// Check that the settings are correct.
|
145 |
|
|
$importer = feeds_importer($id);
|
146 |
|
|
$this->assertEqual('FeedsFileFetcher', get_class($importer->fetcher));
|
147 |
|
|
$this->assertEqual('FeedsCSVParser', get_class($importer->parser));
|
148 |
|
|
$this->assertEqual('FeedsTermProcessor', get_class($importer->processor));
|
149 |
|
|
|
150 |
|
|
$config = $importer->fetcher->getConfig();
|
151 |
|
|
$this->assertEqual('xml', $config['allowed_extensions']);
|
152 |
|
|
|
153 |
|
|
$config = $importer->parser->getConfig();
|
154 |
|
|
$this->assertEqual('|', $config['delimiter']);
|
155 |
|
|
|
156 |
|
|
$config = $importer->processor->getConfig();
|
157 |
|
|
$this->assertTrue($config['skip_hash_check']);
|
158 |
|
|
}
|
159 |
|
|
|
160 |
85ad3d82
|
Assos Assos
|
} |