From 28388d47bafb9fa1c787608c04c351ac63dcd462 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 27 Jan 2020 14:53:23 +0100 Subject: [PATCH] Bug 23070: Add tests --- t/db_dependent/Reserves.t | 44 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Reserves.t b/t/db_dependent/Reserves.t index ef47e26473..52bd33a130 100755 --- a/t/db_dependent/Reserves.t +++ b/t/db_dependent/Reserves.t @@ -17,7 +17,7 @@ use Modern::Perl; -use Test::More tests => 62; +use Test::More tests => 63; use Test::MockModule; use Test::Warn; @@ -1045,6 +1045,48 @@ subtest 'MoveReserve additional test' => sub { }; +subtest 'RevertWaitingStatus' => sub { + + plan tests => 2; + + # Create the items and patrons we need + my $biblio = $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->biblionumber, + itype => $itype->itemtype, + library => $library->branchcode + } + ); + my $patron_1 = $builder->build_object( { class => "Koha::Patrons" } ); + my $patron_2 = $builder->build_object( { class => "Koha::Patrons" } ); + my $patron_3 = $builder->build_object( { class => "Koha::Patrons" } ); + my $patron_4 = $builder->build_object( { class => "Koha::Patrons" } ); + + # Place a hold on the title for both patrons + my $hold_1 = place_item_hold( $patron_1, $item_1, $library, $priority ); + my $hold_2 = place_item_hold( $patron_2, $item_1, $library, $priority ); + my $hold_3 = place_item_hold( $patron_3, $item_1, $library, $priority ); + my $hold_4 = place_item_hold( $patron_4, $item_1, $library, $priority ); + + $hold_1->set_waiting; + AddIssue( $patron_3->unblessed, $item_1->barcode, undef, 'revert' ); + + my $holds = $biblio->holds; + is( $holds->count, 3, 'One hold has been deleted' ); + is_deeply( + [ + $holds->next->priority, $holds->next->priority, + $holds->next->priority + ], + [ 1, 2, 3 ], + 'priorities have been reordered' + ); +}; + sub count_hold_print_messages { my $message_count = $dbh->selectall_arrayref(q{ SELECT COUNT(*) -- 2.11.0