Révision ed9a13f1
Ajouté par Assos Assos il y a presque 4 ans
drupal7/sites/all/modules/feeds/tests/feeds_rules.test | ||
---|---|---|
1 | 1 |
<?php |
2 | 2 |
|
3 |
/** |
|
4 |
* @file |
|
5 |
* Contains FeedsRulesTest. |
|
6 |
*/ |
|
7 |
|
|
3 | 8 |
/** |
4 | 9 |
* Tests for Rules integration. |
5 | 10 |
*/ |
6 | 11 |
class FeedsRulesTest extends FeedsWebTestCase { |
7 | 12 |
|
13 |
/** |
|
14 |
* {@inheritdoc} |
|
15 |
*/ |
|
8 | 16 |
public static function getInfo() { |
9 | 17 |
return array( |
10 | 18 |
'name' => 'Rules integration', |
... | ... | |
182 | 190 |
$node = node_load(1); |
183 | 191 |
$this->assertEqual('Ut wisi enim ad minim veniam', $node->title); |
184 | 192 |
} |
193 |
|
|
194 |
/** |
|
195 |
* Tests the Rules action 'feeds_import_feed'. |
|
196 |
*/ |
|
197 |
public function testFeedsImportAction() { |
|
198 |
// Attach importer to content type and set to not import on submission. |
|
199 |
$this->setSettings('node', NULL, array( |
|
200 |
'content_type' => 'page', |
|
201 |
'import_period' => FEEDS_SCHEDULE_NEVER, |
|
202 |
'import_on_create' => FALSE, |
|
203 |
)); |
|
204 |
|
|
205 |
// Create a feed node. |
|
206 |
$source_url = $GLOBALS['base_url'] . '/' . drupal_get_path('module', 'feeds') . '/tests/feeds/content.csv'; |
|
207 |
$this->createFeedNode('node', $source_url, 'Feed node 1', 'page'); |
|
208 |
|
|
209 |
// Assert that nothing has been imported yet. |
|
210 |
$this->assertNodeCount(1); |
|
211 |
|
|
212 |
// Create rule with import action. |
|
213 |
$rule = $this->createTestRule('cron', FALSE); |
|
214 |
$rule->action('feeds_import_feed', array( |
|
215 |
'importer' => 'node', |
|
216 |
'feed_nid' => 1, |
|
217 |
)); |
|
218 |
$rule->integrityCheck()->save(); |
|
219 |
|
|
220 |
// Trigger rules event. |
|
221 |
$this->cronRun(); |
|
222 |
|
|
223 |
// Assert that 2 items have been imported (three nodes exist in total). |
|
224 |
$this->assertNodeCount(3); |
|
225 |
} |
|
226 |
|
|
227 |
/** |
|
228 |
* Tests the Rules action 'feeds_import_feed' with standalone form. |
|
229 |
*/ |
|
230 |
public function testFeedsImportActionUsingStandaloneForm() { |
|
231 |
$this->setSettings('node', NULL, array( |
|
232 |
'import_period' => FEEDS_SCHEDULE_NEVER, |
|
233 |
'import_on_create' => FALSE, |
|
234 |
)); |
|
235 |
|
|
236 |
// Save data on import form. |
|
237 |
$edit = array( |
|
238 |
'feeds[FeedsHTTPFetcher][source]' => $GLOBALS['base_url'] . '/' . drupal_get_path('module', 'feeds') . '/tests/feeds/content.csv', |
|
239 |
); |
|
240 |
$this->drupalPost('import/node', $edit, 'Save'); |
|
241 |
|
|
242 |
// Create rule with import action. |
|
243 |
$rule = $this->createTestRule('cron', FALSE); |
|
244 |
$rule->action('feeds_import_feed', array( |
|
245 |
'importer' => 'node', |
|
246 |
'feed_nid' => 0, |
|
247 |
)); |
|
248 |
$rule->integrityCheck()->save(); |
|
249 |
|
|
250 |
// Trigger rules event. |
|
251 |
$this->cronRun(); |
|
252 |
|
|
253 |
// Assert that 2 items have been imported. |
|
254 |
$this->assertNodeCount(2); |
|
255 |
} |
|
256 |
|
|
257 |
/** |
|
258 |
* Tests the Rules action 'feeds_import_feed' with process in background. |
|
259 |
*/ |
|
260 |
public function testFeedsImportActionWithProcessInBackgroundOption() { |
|
261 |
// Attach importer to content type, set to not import on submission and set |
|
262 |
// to run in background. |
|
263 |
$this->setSettings('node', NULL, array( |
|
264 |
'content_type' => 'page', |
|
265 |
'import_period' => FEEDS_SCHEDULE_NEVER, |
|
266 |
'import_on_create' => FALSE, |
|
267 |
'process_in_background' => TRUE, |
|
268 |
)); |
|
269 |
|
|
270 |
// Create a feed node. |
|
271 |
$source_url = $GLOBALS['base_url'] . '/' . drupal_get_path('module', 'feeds') . '/tests/feeds/content.csv'; |
|
272 |
$this->createFeedNode('node', $source_url, 'Feed node 1', 'page'); |
|
273 |
|
|
274 |
// Assert that nothing has been imported yet. |
|
275 |
$this->assertNodeCount(1); |
|
276 |
|
|
277 |
// Create rule with import action. |
|
278 |
$rule = $this->createTestRule('feeds_tests_rules_event', FALSE); |
|
279 |
$rule->action('feeds_import_feed', array( |
|
280 |
'importer' => 'node', |
|
281 |
'feed_nid' => 1, |
|
282 |
)); |
|
283 |
$rule->integrityCheck()->save(); |
|
284 |
|
|
285 |
// Trigger rules event. |
|
286 |
$this->drupalGet('testing/feeds/trigger-rules-event'); |
|
287 |
|
|
288 |
// Run cron to run background task. |
|
289 |
$this->cronRun(); |
|
290 |
|
|
291 |
// Assert that 2 items have been imported (three nodes exist in total). |
|
292 |
$this->assertNodeCount(3); |
|
293 |
} |
|
294 |
|
|
185 | 295 |
} |
Formats disponibles : Unified diff
Weekly update of contrib modules