function BiblioContributorUnitTest::testBiblioDeleteOrphanAuthors in Bibliography Module 6.2
Same name and namespace in other branches
- 7.2 tests/contributor.test \BiblioContributorUnitTest::testBiblioDeleteOrphanAuthors()
File
- tests/
contributor.test, line 99
Class
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);
if (!biblio_get_contributor($author['aka'])) {
db_query("UPDATE {biblio_contributor_data} SET aka = cid WHERE cid = %d ", array(
$author['cid'],
));
}
}
$restored_count = biblio_count_orphan_authors();
$this
->assertEqual($orphan_count, $restored_count, "Restored {$restored_count} of {$orphan_count} original orphans");
}