View | Details | Raw Unified | Return to bug 21556
Collapse All | Expand All

(-)a/C4/Biblio.pm (-1 / +4 lines)
Lines 361-366 C<$error> : undef unless an error occurs Link Here
361
361
362
sub DelBiblio {
362
sub DelBiblio {
363
    my ($biblionumber) = @_;
363
    my ($biblionumber) = @_;
364
365
    my $biblio = Koha::Biblios->find( $biblionumber );
366
    return unless $biblio; # Should we throw an exception instead?
367
364
    my $dbh = C4::Context->dbh;
368
    my $dbh = C4::Context->dbh;
365
    my $error;    # for error handling
369
    my $error;    # for error handling
366
370
Lines 383-389 sub DelBiblio { Link Here
383
    }
387
    }
384
388
385
    # We delete any existing holds
389
    # We delete any existing holds
386
    my $biblio = Koha::Biblios->find( $biblionumber );
387
    my $holds = $biblio->holds;
390
    my $holds = $biblio->holds;
388
    while ( my $hold = $holds->next ) {
391
    while ( my $hold = $holds->next ) {
389
        $hold->cancel;
392
        $hold->cancel;
(-)a/t/db_dependent/Biblio.t (-2 / +12 lines)
Lines 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 9;
20
use Test::More tests => 10;
21
use Test::MockModule;
21
use Test::MockModule;
22
use List::MoreUtils qw( uniq );
22
use List::MoreUtils qw( uniq );
23
use MARC::Record;
23
use MARC::Record;
Lines 455-460 subtest 'deletedbiblio_metadata' => sub { Link Here
455
    is( $moved, $biblionumber, 'Found in deletedbiblio_metadata' );
455
    is( $moved, $biblionumber, 'Found in deletedbiblio_metadata' );
456
};
456
};
457
457
458
subtest 'DelBiblio' => sub {
459
    plan tests => 2;
460
461
    my ($biblionumber, $biblioitemnumber) = C4::Biblio::AddBiblio(MARC::Record->new, '');
462
    my $deleted = C4::Biblio::DelBiblio( $biblionumber );
463
    is( $deleted, undef, 'DelBiblio returns undef is the biblio has been deleted correctly - Must be 1 instead'); # FIXME We should return 1 instead!
464
465
    $deleted = C4::Biblio::DelBiblio( $biblionumber );
466
    is( $deleted, undef, 'DelBiblo should return undef is the record did not exist');
467
};
468
458
# Cleanup
469
# Cleanup
459
Koha::Caches->get_instance->clear_from_cache( "MarcSubfieldStructure-" );
470
Koha::Caches->get_instance->clear_from_cache( "MarcSubfieldStructure-" );
460
$schema->storage->txn_rollback;
471
$schema->storage->txn_rollback;
461
- 

Return to bug 21556