From 69c2abf14bb64fd0a925b01087227b772b7942b4 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Fri, 11 Oct 2024 12:49:23 +0000 Subject: [PATCH] Bug 30648: Unit tests MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Anneli Österman Signed-off-by: Martin Renvoize Signed-off-by: Katrin Fischer --- t/db_dependent/Biblio.t | 33 ++++++++++++++++++++++++++++++++- t/lib/TestBuilder.pm | 6 ++++++ 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Biblio.t b/t/db_dependent/Biblio.t index d2d5a5bbff..35df97fd0b 100755 --- a/t/db_dependent/Biblio.t +++ b/t/db_dependent/Biblio.t @@ -676,10 +676,41 @@ subtest 'deletedbiblio_metadata' => sub { subtest 'DelBiblio' => sub { - plan tests => 10; + plan tests => 11; t::lib::Mocks::mock_preference( 'RealTimeHoldsQueue', 0 ); + subtest 'DelBiblio holds handling' => sub { + + plan tests => 3; + my $biblio = $builder->build_sample_biblio; + my $hold = $builder->build_object( + { + class => 'Koha::Holds', + value => { biblionumber => $biblio->biblionumber } + } + ); + my $old_hold = $builder->build_object( + { + class => 'Koha::Old::Holds', + value => { biblionumber => $biblio->biblionumber } + } + ); + + C4::Biblio::DelBiblio($biblio->biblionumber); + $old_hold->discard_changes(); + $hold = Koha::Old::Holds->find( $hold->reserve_id ); + ok( $hold, "Hold has been successfully cancelled on deletion of biblio" ); + is( + $old_hold->deleted_biblionumber, $biblio->biblionumber, + "Biblionumber has been successfully recorded during deletion for old holds" + ); + is( + $hold->deleted_biblionumber, $biblio->biblionumber, + "Biblionumber has been successfully recorded during deletion for existing hold that was cancelled" + ); + }; + 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! diff --git a/t/lib/TestBuilder.pm b/t/lib/TestBuilder.pm index 91c229e80c..0124fe55b0 100644 --- a/t/lib/TestBuilder.pm +++ b/t/lib/TestBuilder.pm @@ -630,6 +630,12 @@ sub _gen_default_values { Reserve => { non_priority => 0, item_group_id => undef, + deleted_biblionumber => undef, + }, + OldReserve => { + non_priority => 0, + item_group_id => undef, + deleted_biblionumber => undef, }, Itemtype => { rentalcharge => 0, -- 2.39.5