sub DelBiblio {
my ($biblionumber) = @_;
+
+ my $biblio = Koha::Biblios->find( $biblionumber );
+ return unless $biblio; # Should we throw an exception instead?
+
my $dbh = C4::Context->dbh;
my $error; # for error handling
}
# We delete any existing holds
- my $biblio = Koha::Biblios->find( $biblionumber );
my $holds = $biblio->holds;
while ( my $hold = $holds->next ) {
$hold->cancel;
use Modern::Perl;
-use Test::More tests => 9;
+use Test::More tests => 10;
use Test::MockModule;
use List::MoreUtils qw( uniq );
use MARC::Record;
is( $moved, $biblionumber, 'Found in deletedbiblio_metadata' );
};
+subtest 'DelBiblio' => sub {
+ plan tests => 2;
+
+ my ($biblionumber, $biblioitemnumber) = C4::Biblio::AddBiblio(MARC::Record->new, '');
+ my $deleted = C4::Biblio::DelBiblio( $biblionumber );
+ is( $deleted, undef, 'DelBiblio returns undef is the biblio has been deleted correctly - Must be 1 instead'); # FIXME We should return 1 instead!
+
+ $deleted = C4::Biblio::DelBiblio( $biblionumber );
+ is( $deleted, undef, 'DelBiblo should return undef is the record did not exist');
+};
+
# Cleanup
Koha::Caches->get_instance->clear_from_cache( "MarcSubfieldStructure-" );
$schema->storage->txn_rollback;