Révision 41cc1b08
Ajouté par Assos Assos il y a presque 9 ans
drupal7/sites/all/modules/feeds/tests/feeds.test | ||
---|---|---|
18 | 18 |
// array of module names to setUp(). |
19 | 19 |
if (isset($args[0])) { |
20 | 20 |
if (is_array($args[0])) { |
21 |
$modules = $args[0]; |
|
22 |
} |
|
21 |
$modules = $args[0];
|
|
22 |
}
|
|
23 | 23 |
else { |
24 |
$modules = $args; |
|
25 |
} |
|
24 |
$modules = $args;
|
|
25 |
}
|
|
26 | 26 |
} |
27 | 27 |
else { |
28 | 28 |
$modules = array(); |
... | ... | |
89 | 89 |
$permissions[] = 'administer taxonomy'; |
90 | 90 |
$permissions[] = 'administer users'; |
91 | 91 |
$permissions[] = 'administer feeds'; |
92 |
$permissions[] = 'administer filters'; |
|
92 | 93 |
|
93 | 94 |
// Create an admin user and log in. |
94 | 95 |
$this->admin_user = $this->drupalCreateUser($permissions); |
... | ... | |
346 | 347 |
|
347 | 348 |
// Check whether feed got properly added to scheduler. |
348 | 349 |
$this->assertEqual(1, db_query("SELECT COUNT(*) FROM {job_schedule} WHERE type = :id AND id = 0 AND name = 'feeds_source_import' AND last <> 0 AND scheduled = 0", array(':id' => $id))->fetchField()); |
349 |
// There must be only one entry for callback 'expire' - no matter what the feed_nid is. |
|
350 |
$this->assertEqual(0, db_query("SELECT COUNT(*) FROM {job_schedule} WHERE type = :id AND name = 'feeds_importer_expire' AND last <> 0 AND scheduled = 0", array(':id' => $id))->fetchField()); |
|
350 |
// Check expire scheduler. |
|
351 |
if (feeds_importer($id)->processor->expiryTime() == FEEDS_EXPIRE_NEVER) { |
|
352 |
$this->assertEqual(0, db_query("SELECT COUNT(*) FROM {job_schedule} WHERE type = :id AND id = 0 AND name = 'feeds_source_expire'", array(':id' => $id))->fetchField()); |
|
353 |
} |
|
354 |
else { |
|
355 |
$this->assertEqual(1, db_query("SELECT COUNT(*) FROM {job_schedule} WHERE type = :id AND id = 0 AND name = 'feeds_source_expire'", array(':id' => $id))->fetchField()); |
|
356 |
} |
|
351 | 357 |
} |
352 | 358 |
|
353 | 359 |
/** |
... | ... | |
379 | 385 |
$this->assertEqual($config['processor']['plugin_key'], $processor, 'Correct processor'); |
380 | 386 |
} |
381 | 387 |
|
388 |
/** |
|
389 |
* Overrides DrupalWebTestCase::assertFieldByXPath(). |
|
390 |
* |
|
391 |
* The core version has a bug, this is the D8 version. |
|
392 |
* |
|
393 |
* @todo Remove once https://drupal.org/node/2105617 lands. |
|
394 |
*/ |
|
395 |
protected function assertFieldByXPath($xpath, $value = NULL, $message = '', $group = 'Other') { |
|
396 |
$fields = $this->xpath($xpath); |
|
397 |
|
|
398 |
// If value specified then check array for match. |
|
399 |
$found = TRUE; |
|
400 |
if (isset($value)) { |
|
401 |
$found = FALSE; |
|
402 |
if ($fields) { |
|
403 |
foreach ($fields as $field) { |
|
404 |
if (isset($field['value']) && $field['value'] == $value) { |
|
405 |
// Input element with correct value. |
|
406 |
$found = TRUE; |
|
407 |
} |
|
408 |
elseif (isset($field->option) || isset($field->optgroup)) { |
|
409 |
// Select element found. |
|
410 |
$selected = $this->getSelectedItem($field); |
|
411 |
if ($selected === FALSE) { |
|
412 |
// No item selected so use first item. |
|
413 |
$items = $this->getAllOptions($field); |
|
414 |
if (!empty($items) && $items[0]['value'] == $value) { |
|
415 |
$found = TRUE; |
|
416 |
} |
|
417 |
} |
|
418 |
elseif ($selected == $value) { |
|
419 |
$found = TRUE; |
|
420 |
} |
|
421 |
} |
|
422 |
elseif ((string) $field == $value) { |
|
423 |
// Text area with correct text. |
|
424 |
$found = TRUE; |
|
425 |
} |
|
426 |
} |
|
427 |
} |
|
428 |
} |
|
429 |
return $this->assertTrue($fields && $found, $message, $group); |
|
430 |
} |
|
431 |
|
|
382 | 432 |
/** |
383 | 433 |
* Adds mappings to a given configuration. |
384 | 434 |
* |
... | ... | |
390 | 440 |
* @param bool $test_mappings |
391 | 441 |
* (optional) TRUE to automatically test mapping configs. Defaults to TRUE. |
392 | 442 |
*/ |
393 |
public function addMappings($id, $mappings, $test_mappings = TRUE) { |
|
443 |
public function addMappings($id, array $mappings, $test_mappings = TRUE) {
|
|
394 | 444 |
|
395 | 445 |
$path = "admin/structure/feeds/$id/mapping"; |
396 | 446 |
|
... | ... | |
434 | 484 |
/** |
435 | 485 |
* Remove mappings from a given configuration. |
436 | 486 |
* |
487 |
* @param string $id |
|
488 |
* ID of the importer. |
|
437 | 489 |
* @param array $mappings |
438 | 490 |
* An array of mapping arrays. Each mapping array must have a source and |
439 | 491 |
* a target key and can have a unique key. |
440 | 492 |
* @param bool $test_mappings |
441 | 493 |
* (optional) TRUE to automatically test mapping configs. Defaults to TRUE. |
442 | 494 |
*/ |
443 |
public function removeMappings($id, $mappings, $test_mappings = TRUE) { |
|
495 |
public function removeMappings($id, array $mappings, $test_mappings = TRUE) {
|
|
444 | 496 |
$path = "admin/structure/feeds/$id/mapping"; |
445 | 497 |
|
446 |
$current_mappings = $this->getCurrentMappings($id);
|
|
498 |
$edit = array();
|
|
447 | 499 |
|
448 | 500 |
// Iterate through all mappings and remove via the form. |
449 | 501 |
foreach ($mappings as $i => $mapping) { |
... | ... | |
453 | 505 |
$this->assertEqual($current_mapping_key, $i, 'Mapping exists before removal.'); |
454 | 506 |
} |
455 | 507 |
|
456 |
$remove_mapping = array("remove_flags[$i]" => 1); |
|
457 |
|
|
458 |
$this->drupalPost($path, $remove_mapping, t('Save')); |
|
459 |
|
|
460 |
$this->assertText('Your changes have been saved.'); |
|
461 |
|
|
462 |
if ($test_mappings) { |
|
463 |
$current_mapping_key = $this->mappingExists($id, $i, $mapping['source'], $mapping['target']); |
|
464 |
$this->assertEqual($current_mapping_key, -1, 'Mapping does not exist after removal.'); |
|
465 |
} |
|
508 |
$edit["remove_flags[$i]"] = 1; |
|
466 | 509 |
} |
510 |
|
|
511 |
$this->drupalPost($path, $edit, t('Save')); |
|
512 |
$this->assertText('Your changes have been saved.'); |
|
467 | 513 |
} |
468 | 514 |
|
469 | 515 |
/** |
Formats disponibles : Unified diff
Update feeds 7.x-2.0-alpha9 -> 7.x-2.0-beta1
Install lib simplepie 1.3.1