You are here

ImportPreventDuplicates.test in Bibliography Module 7.3

File

tests/ImportPreventDuplicates.test
View source
<?php

/**
 * Test preventing duplication on import.
 */
class BiblioImportPreventDuplicateTestCase extends DrupalWebTestCase {
  public static function getInfo() {
    return array(
      'name' => 'Prevent duplication',
      'description' => 'Test preventing duplication on import.',
      'group' => 'Biblio',
    );
  }
  function setUp() {
    parent::setUp('biblio');
    biblio_create_fields_by_bundle(array(
      'book',
      'journal',
    ));
  }

  /**
   * Test preventing duplicate biblios, using BibTex import.
   */
  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.');
  }

}

Classes

Namesort descending Description
BiblioImportPreventDuplicateTestCase Test preventing duplication on import.