Révision ec2b0e7b
Ajouté par Assos Assos il y a presque 7 ans
drupal7/sites/all/modules/feeds/tests/feeds.test | ||
---|---|---|
359 | 359 |
|
360 | 360 |
/** |
361 | 361 |
* Import a file through the import form. Assumes FeedsFileFetcher in place. |
362 |
* |
|
363 |
* @param string $id |
|
364 |
* The ID of the importer. |
|
365 |
* @param string $file |
|
366 |
* The absolute path to the file. |
|
367 |
* @param string $submit |
|
368 |
* (optional) The button to press. |
|
369 |
* Defaults to the button "Import". |
|
362 | 370 |
*/ |
363 |
public function importFile($id, $file) { |
|
364 |
|
|
371 |
public function importFile($id, $file, $submit = NULL) { |
|
365 | 372 |
$this->assertTrue(file_exists($file), 'Source file exists'); |
366 | 373 |
$edit = array( |
367 | 374 |
'files[feeds]' => $file, |
368 | 375 |
); |
369 |
$this->drupalPost('import/' . $id, $edit, 'Import'); |
|
376 |
if (empty($submit)) { |
|
377 |
$submit = 'Import'; |
|
378 |
} |
|
379 |
$this->drupalPost('import/' . $id, $edit, $submit); |
|
380 |
} |
|
381 |
|
|
382 |
/** |
|
383 |
* Asserts that the given number of nodes exist. |
|
384 |
* |
|
385 |
* @param int $expected_node_count |
|
386 |
* The expected number of nodes in the node table. |
|
387 |
* @param string $message |
|
388 |
* (optional) The message to assert. |
|
389 |
*/ |
|
390 |
protected function assertNodeCount($expected_node_count, $message = '') { |
|
391 |
if (!$message) { |
|
392 |
$message = '@expected nodes have been created (actual: @count).'; |
|
393 |
} |
|
394 |
|
|
395 |
$node_count = db_select('node') |
|
396 |
->fields('node', array()) |
|
397 |
->countQuery() |
|
398 |
->execute() |
|
399 |
->fetchField(); |
|
400 |
$this->assertEqual($expected_node_count, $node_count, format_string($message, array( |
|
401 |
'@expected' => $expected_node_count, |
|
402 |
'@count' => $node_count, |
|
403 |
))); |
|
370 | 404 |
} |
371 | 405 |
|
372 | 406 |
/** |
... | ... | |
430 | 464 |
return $this->assertTrue($fields && $found, $message, $group); |
431 | 465 |
} |
432 | 466 |
|
433 |
/** |
|
434 |
* Adds mappings to a given configuration. |
|
435 |
* |
|
436 |
* @param string $id |
|
437 |
* ID of the importer. |
|
438 |
* @param array $mappings |
|
439 |
* An array of mapping arrays. Each mapping array must have a source and |
|
440 |
* an target key and can have a unique key. |
|
441 |
* @param bool $test_mappings |
|
442 |
* (optional) TRUE to automatically test mapping configs. Defaults to TRUE. |
|
443 |
*/ |
|
467 |
/** |
|
468 |
* Asserts that a field in the current page is enabled. |
|
469 |
* |
|
470 |
* @param string $name |
|
471 |
* Name of field to assert. |
|
472 |
* @param string $message |
|
473 |
* (optional) A message to display with the assertion. |
|
474 |
* |
|
475 |
* @return bool |
|
476 |
* TRUE on pass, FALSE on fail. |
|
477 |
*/ |
|
478 |
protected function assertFieldEnabled($name, $message = '') { |
|
479 |
$elements = $this->xpath($this->constructFieldXpath('name', $name)); |
|
480 |
return $this->assertTrue(isset($elements[0]) && empty($elements[0]['disabled']), $message ? $message : t('Field %name is enabled.', array('%name' => $name)), t('Browser')); |
|
481 |
} |
|
482 |
|
|
483 |
/** |
|
484 |
* Asserts that a field in the current page is disabled. |
|
485 |
* |
|
486 |
* @param string $name |
|
487 |
* Name of field to assert. |
|
488 |
* @param string $message |
|
489 |
* (optional) A message to display with the assertion. |
|
490 |
* |
|
491 |
* @return bool |
|
492 |
* TRUE on pass, FALSE on fail. |
|
493 |
*/ |
|
494 |
protected function assertFieldDisabled($name, $message = '') { |
|
495 |
$elements = $this->xpath($this->constructFieldXpath('name', $name)); |
|
496 |
return $this->assertTrue(isset($elements[0]) && !empty($elements[0]['disabled']), $message ? $message : t('Field %name is disabled.', array('%name' => $name)), t('Browser')); |
|
497 |
} |
|
498 |
|
|
499 |
/** |
|
500 |
* Adds mappings to a given configuration. |
|
501 |
* |
|
502 |
* @param string $id |
|
503 |
* ID of the importer. |
|
504 |
* @param array $mappings |
|
505 |
* An array of mapping arrays. Each mapping array must have a source and |
|
506 |
* an target key and can have a unique key. |
|
507 |
* @param bool $test_mappings |
|
508 |
* (optional) TRUE to automatically test mapping configs. Defaults to TRUE. |
|
509 |
*/ |
|
444 | 510 |
public function addMappings($id, array $mappings, $test_mappings = TRUE) { |
445 | 511 |
|
446 | 512 |
$path = "admin/structure/feeds/$id/mapping"; |
Formats disponibles : Unified diff
Weekly update of contrib modules