You are here

public function BiblioContributorWebTestCase::testBiblioDeleteOrphanAuthors in Bibliography Module 7

File

tests/BiblioContributorWebTestCase.test, line 82

Class

BiblioContributorWebTestCase
Web tests for contributor functions.

Code

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

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

  // Create a new orphan so we will have at least one.
  biblio_save_contributor($author);
  $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");
}