From c6998e8be7e22a9b6d30cc9355971c210cce730c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joonas=20Kylm=C3=A4l=C3=A4?= Date: Fri, 13 Nov 2020 13:41:16 +0200 Subject: [PATCH] Bug 27012: Add test for C4::Reserves::MergeHolds This does a basic check whether a hold gets moved to another biblio when MergeHolds() is called. Signed-off-by: Victor Grousset/tuxayo --- t/db_dependent/Reserves.t | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Reserves.t b/t/db_dependent/Reserves.t index 6ddb3f4f56..4faab3c218 100755 --- a/t/db_dependent/Reserves.t +++ b/t/db_dependent/Reserves.t @@ -17,7 +17,7 @@ use Modern::Perl; -use Test::More tests => 65; +use Test::More tests => 66; use Test::MockModule; use Test::Warn; @@ -1190,6 +1190,33 @@ subtest 'AllowHoldOnPatronPossession test' => sub { 'Patron can place hold on an item loaned to itself'); }; +subtest 'MergeHolds' => sub { + + plan tests => 1; + + my $biblio_1 = $builder->build_sample_biblio(); + my $biblio_2 = $builder->build_sample_biblio(); + my $library = $builder->build_object( { class => 'Koha::Libraries' } ); + my $itype = $builder->build_object( + { class => "Koha::ItemTypes", value => { notforloan => 0 } } ); + my $item_1 = $builder->build_sample_item( + { + biblionumber => $biblio_1->biblionumber, + itype => $itype->itemtype, + library => $library->branchcode + } + ); + my $patron_1 = $builder->build_object( { class => "Koha::Patrons" } ); + + # Place a hold on $biblio_1 + my $priority = 1; + place_item_hold( $patron_1, $item_1, $library, $priority ); + + # Move and make sure hold is now on $biblio_2 + C4::Reserves::MergeHolds($dbh, $biblio_2->biblionumber, $biblio_1->biblionumber); + is( $biblio_2->holds->count, 1, 'Hold has been transferred' ); +}; + sub count_hold_print_messages { my $message_count = $dbh->selectall_arrayref(q{ SELECT COUNT(*) -- 2.29.2