'Biblio import/export unit tests', 'description' => 'Unit tests for import/export functions.', 'group' => 'Biblio', ); } function getTaggedString() { return "%0 Book\r\n%B biblio_secondary_title\r\n%D 2009\r\n%T Biblio Title\r\n%A Ron J. Jeromezzzzzz\r\n%A John Smithzzzzzz\r\n%A George W. Bushzzzzzz\r\n%K biblio_keywords\r\n%X biblio_abst_e\r\n%B biblio_secondary_title\r\n%S biblio_tertiary_title\r\n%7 biblio_edition\r\n%I biblio_publisher\r\n%C biblio_place_published\r\n%V biblio_volume\r\n%P biblio_pages\r\n%8 biblio_date\r\n%@ biblio_isbn\r\n%G biblio_lang\r\n%U biblio_url\r\n%N biblio_issue\r\n%9 biblio_type_of_work\r\n%M biblio_accession_number\r\n%L biblio_call_number\r\n%1 biblio_custom1\r\n%2 biblio_custom2\r\n%3 biblio_custom3\r\n%4 biblio_custom4\r\n%# biblio_custom5\r\n%$ biblio_custom6\r\n%] biblio_custom7\r\n%< biblio_research_notes\r\n%6 biblio_number_of_volumes\r\n%R biblio_doi\r\n%F biblio_label\r\n\r\n"; } function getBibTexString() { return "@book {biblio_citekey,\n\ttitle = {Biblio Title},\n\tseries = {biblio_secondary_title},\n\tvolume = {biblio_volume},\n\tnumber = {biblio_number},\n\tyear = {2009},\n\tnote = {biblio_notes},\n\tmonth = {biblio_date},\n\tpages = {biblio_pages},\n\tpublisher = {biblio_publisher},\n\torganization = {biblio_publisher},\n\ttype = {biblio_type_of_work},\n\tedition = {biblio_edition},\n\tchapter = {biblio_section},\n\taddress = {biblio_place_published},\n\tabstract = {biblio_abst_e},\n\tkeywords = {biblio_keywords},\n\tisbn = {biblio_isbn},\n\tissn = {biblio_issn},\n\tdoi = {biblio_doi},\n\turl = {biblio_url},\n\tauthor = {Ron J. Jeromezzzzzz and John Smithzzzzzz and George W. Bushzzzzzz}\n}\n"; } function getXMLString() { return 'Drupal-Biblio6<style face="normal" font="default" size="100%">Biblio Title</style>
'; } function getRISString() { return "TY - BOOK\r\nTI - Biblio Title\r\nY1 - 2009\r\nN1 - biblio_notes\r\nAU - Ron J. Jeromezzzzzz\r\nAU - John Smithzzzzzz\r\nAU - George W. Bushzzzzzz\r\nKW - biblio_keywords\r\nSP - 1\r\nEP - 2\r\nJO - biblio_short_title\r\nJ1 - biblio_short_title\r\nJ2 - biblio_short_title\r\nVL - biblio_volume\r\nIS - biblio_issue\r\nT2 - biblio_secondary_title\r\nCY - biblio_place_published\r\nPB - biblio_publisher\r\nU1 - biblio_custom1\r\nU2 - biblio_custom2\r\nU3 - biblio_custom3\r\nU4 - biblio_custom4\r\nU5 - biblio_custom5\r\nT3 - biblio_tertiary_title\r\nAB - biblio_abst_e\r\nSN - biblio_isbn\r\nUR - biblio_url\r\nER - \r\n\r\n"; } function testBiblioNodeExport() { module_load_include('inc', 'biblio_xml', 'endnote8_export'); $node = $this->createNode(); $this->assertEqual(_biblio_tagged_export($node), $this->getTaggedString());//, 'Export a node in EndNote Tagged format'); $this->assertEqual(_biblio_bibtex_export($node), $this->getBibTexString(), 'Export a node in BibTex format'); $xml = _endnote8_XML_export('', 'begin'); $xml .= _endnote8_XML_export($node); $xml .= _endnote8_XML_export('', 'end'); $this->assertEqual($xml, $this->getXMLString(), 'Export a node in EndNote XML format'); } function testBiblioXMLFileImport() { $file = file_save_data($this->getXMLString()); $nids = biblio_import($file, 'xml8', 1, NULL, FALSE, NULL, $context); array_merge($this->nids, $nids); $this->assertEqual(count($nids), 1, 'Imported 1 EndNote XML entry'); file_delete($file); $node = $this->createNode(); $fields = array_filter(biblio_get_map('field_map', 'endnote8')); $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); } } function testBiblioTaggedFileImport() { $file = file_save_data($this->getTaggedString()); $nids = biblio_import($file, 'tagged', 1, NULL, FALSE, NULL, $context); array_merge($this->nids, $nids); $this->assertEqual(count($nids), 1, 'Imported 1 Tagged entry'); file_delete($file); $node = $this->createNode(); $fields = array_filter(biblio_get_map('field_map', '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); } } function testBiblioBibtexFileImport() { $file = file_save_data($this->getBibTexString()); $nids = biblio_import($file, 'bib', 1, NULL, FALSE, NULL, $context); array_merge($this->nids, $nids); $this->assertEqual(count($nids), 1, 'Imported 1 Bibtex entry'); file_delete($file); $node = $this->createNode(); $fields = array_filter(biblio_get_map('field_map', 'bibtex')); $fields += array('title', 'biblio_contributors'); foreach ($nids as $nid) { $this->nids[] = $nid; $imported_node = node_load($nid); $this->assertBiblioFields($node, $imported_node, $fields); } } function testBiblioRISFileImport() { $file = file_save_data($this->getRISString()); $nids = biblio_import($file, 'ris', 1, NULL, FALSE, NULL, $context); array_merge($this->nids, $nids); $this->assertEqual(count($nids), 1, 'Imported 1 RIS entry'); file_delete($file); $node = $this->createNode(); $fields = array_unique(array_filter(biblio_get_map('field_map', 'ris'))); $fields += array('title', 'biblio_contributors'); foreach ($nids as $nid) { $this->nids[] = $nid; $imported_node = node_load($nid); $this->assertBiblioFields($node, $imported_node, $fields); } } }