You are here

function BiblioImportExportUnitTest::testBiblioTaggedFileImport in Bibliography Module 6.2

Same name and namespace in other branches
  1. 7.2 tests/import.export.test \BiblioImportExportUnitTest::testBiblioTaggedFileImport()

File

tests/import.export.test, line 77

Class

BiblioImportExportUnitTest

Code

function testBiblioTaggedFileImport() {
  $file = new stdClass();
  $file->filepath = drupal_get_path('module', 'biblio') . '/tests/test.ens';

  //$nids = biblio_import($file, 'tagged', 1, NULL, FALSE, NULL, $context);
  list($nids, $dups) = module_invoke('biblio_tagged', 'biblio_import', $file, NULL, FALSE, NULL);
  if (!empty($nids)) {
    array_merge($this->nids, $nids);
  }
  if (!empty($dups)) {
    array_merge($this->nids, $dups);
    $nids = $dups;
  }
  $this
    ->assertEqual(count($nids), 1, 'Imported 1 Tagged entry');
  $node = $this
    ->createNode();
  $fields = array_filter(unserialize(db_result(db_query("SELECT field_map FROM {biblio_type_maps} WHERE format='tagged'"))));
  $fields += array(
    'title',
    'biblio_contributors',
    'biblio_keywords',
  );
  foreach ($nids as $nid) {
    $this->nids[] = $nid;
    $imported_node = node_load($nid);
    $this
      ->assertBiblioFields($node, $imported_node, $fields);
  }
}