From 67e9356deab73d52fd5b3256b8bbbcd92ec61a34 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Mon, 15 Aug 2022 13:34:02 +0000 Subject: [PATCH] Bug 33761: Unit test Signed-off-by: Martin Renvoize Signed-off-by: Tomas Cohen Arazi --- t/db_dependent/HoldsQueue.t | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/HoldsQueue.t b/t/db_dependent/HoldsQueue.t index a851cf32be..7eb78ce2bd 100755 --- a/t/db_dependent/HoldsQueue.t +++ b/t/db_dependent/HoldsQueue.t @@ -8,7 +8,7 @@ use Modern::Perl; -use Test::More tests => 60; +use Test::More tests => 61; use Data::Dumper; use C4::Calendar qw( new insert_single_holiday ); @@ -2060,3 +2060,34 @@ subtest "Test HoldsQueuePrioritizeBranch" => sub { $schema->storage->txn_rollback; }; + +subtest "GetItemsAvailableToFillHoldsRequestsForBib" => sub { + plan tests => 2; + + $schema->storage->txn_begin; + + my $item_1 = $builder->build_sample_item(); + my $item_2 = $builder->build_sample_item({ biblionumber => $item_1->biblionumber }); + my $item_3 = $builder->build_sample_item({ biblionumber => $item_1->biblionumber }); + + my $transfer_1 = $builder->build_object({ class => 'Koha::Item::Transfers', value => { + itemnumber => $item_1->itemnumber, + datearrived => undef, + datecancelled => undef + }}); + my $transfer_2 = $builder->build_object({ class => 'Koha::Item::Transfers', value => { + itemnumber => $item_2->itemnumber, + datearrived => dt_from_string, + datecancelled => undef + }}); + my $transfer_3 = $builder->build_object({ class => 'Koha::Item::Transfers', value => { + itemnumber => $item_3->itemnumber, + datearrived => undef, + datecancelled => dt_from_string + }}); + + my $items = C4::HoldsQueue::GetItemsAvailableToFillHoldRequestsForBib( $item_1->biblionumber ); + is( scalar @$items, 2, "Two items without active transfers correctly retrieved"); + is_deeply( [$items->[0]->{itemnumber},$items->[1]->{itemnumber}],[$item_2->itemnumber,$item_3->itemnumber],"Correct two items retrieved"); + +};