You are here

function BiblioContributorUnitTest::testBiblioDeleteOrphanAuthors in Bibliography Module 7.2

Same name and namespace in other branches
  1. 6.2 tests/contributor.test \BiblioContributorUnitTest::testBiblioDeleteOrphanAuthors()

File

tests/contributor.test, line 108

Class

BiblioContributorUnitTest

Code

function testBiblioDeleteOrphanAuthors() {
  $orphan_authors = array();
  $orphan_authors = biblio_get_orphan_authors();

  // first save any existing orphans so we can put them back
  $orphan_count = biblio_count_orphan_authors();
  $author = array(
    'name' => 'Ron J. Jeromezzzzzz',
    'auth_type' => 1,
  );
  biblio_save_contributor($author);

  // create a new orphan so we will have at least one
  $before_count = biblio_count_orphan_authors();
  $this
    ->assertTrue($before_count != 0, "There are {$before_count} orphans to delete");
  biblio_delete_orphan_authors(TRUE);
  $after_count = biblio_count_orphan_authors();
  $this
    ->assertEqual($after_count, 0, "There are now {$after_count} orphans");
  foreach ($orphan_authors as $author) {
    biblio_save_contributor($author);
  }
  $restored_count = biblio_count_orphan_authors();
  $this
    ->assertEqual($orphan_count, $restored_count, "Restored {$restored_count} of {$orphan_count} original orphans");
}