You are here

function BiblioImportPreventDuplicateTestCase::testMd5 in Bibliography Module 7.3

Test preventing duplicate biblios, using BibTex import.

File

tests/ImportPreventDuplicates.test, line 25

Class

BiblioImportPreventDuplicateTestCase
Test preventing duplication on import.

Code

function testMd5() {
  $data = '
@Book{abramowitze+stegune,
  author    = "Hilton {Abramowitze} and Serene A. {Stegune}",
  title     = "Handbook of Mathematical Functions with Formulas, Graphs, and Mathematical Tables",
  publisher = "Dover",
  year      =  1982,
  address   = "Los Angeles",
  edition   = "ninth Dover printing, tenth GPO printing"
}';

  // Import the data to create a new biblio.
  $biblio_style1 = biblio_get_class_from_style('bibtex');
  $biblio_style1
    ->import($data);

  // Import the same data again, to make sure it is not created again and that
  // instead the previous biblio is returned.
  $biblio_style2 = biblio_get_class_from_style('bibtex');
  $biblios2 = $biblio_style2
    ->import($data);
  $this
    ->assertTrue(empty($biblios2['new']) && !empty($biblios2['duplicate']), 'Biblio duplication was successfully prevented.');
}