Bugzilla – Attachment 156118 Details for
Bug 33794
Holds Queue builder skips least cost branch unless target item's homebranch is patron's homebranch
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
WIP Bug 33794: Unit tests
WIP-Bug-33794-Unit-tests.patch (text/plain), 3.89 KB, created by
Kyle M Hall (khall)
on 2023-09-22 16:41:43 UTC
(
hide
)
Description:
WIP Bug 33794: Unit tests
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2023-09-22 16:41:43 UTC
Size:
3.89 KB
patch
obsolete
>From 4570ce70b3e4e7d95f71896b09579250adaa73d9 Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Fri, 22 Sep 2023 11:00:50 -0400 >Subject: [PATCH] WIP Bug 33794: Unit tests > >--- > C4/HoldsQueue.pm | 4 +-- > t/db_dependent/HoldsQueue.t | 60 ++++++++++++++++++++++++++++++++++++- > 2 files changed, 61 insertions(+), 3 deletions(-) > >diff --git a/C4/HoldsQueue.pm b/C4/HoldsQueue.pm >index d2c0d721a7a..13b2cbb6c99 100644 >--- a/C4/HoldsQueue.pm >+++ b/C4/HoldsQueue.pm >@@ -938,8 +938,8 @@ sub update_queue_for_biblio { > } > > sub get_least_cost_item { >- my ( $priority_branch, $holdingbranch, $items_by_branch, $items_by_itemnumber, $libraries, $request ) = @_; >- my $holding_branch_items = $items_by_branch->{$holdingbranch}; >+ my ( $priority_branch, $pickup_branch, $items_by_branch, $items_by_itemnumber, $libraries, $request ) = @_; >+ my $holding_branch_items = $items_by_branch->{$pickup_branch}; > foreach my $item (@$holding_branch_items) { > next if $request->{borrowerbranch} ne $item->{$priority_branch}; > next >diff --git a/t/db_dependent/HoldsQueue.t b/t/db_dependent/HoldsQueue.t >index 7875c69eedd..556c7438d78 100755 >--- a/t/db_dependent/HoldsQueue.t >+++ b/t/db_dependent/HoldsQueue.t >@@ -8,7 +8,7 @@ > > use Modern::Perl; > >-use Test::More tests => 61; >+use Test::More tests => 62; > use Data::Dumper; > > use C4::Calendar qw( new insert_single_holiday ); >@@ -2090,4 +2090,62 @@ subtest "GetItemsAvailableToFillHoldsRequestsForBib" => sub { > 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"); > >+ $schema->storage->txn_rollback; >+}; >+ >+subtest "MapItemsToHoldRequests" => sub { >+ >+ plan tests => 1; >+ >+ $schema->storage->txn_begin; >+ >+ my $branch_closer = $builder->build_object( { class => 'Koha::Libraries' } ); >+ my $branch_farther = $builder->build_object( { class => 'Koha::Libraries' } ); >+ my $branch_pickup = $builder->build_object( { class => 'Koha::Libraries' } ); >+ >+ my $biblio = $builder->build_sample_biblio(); >+ my $item_farther = $builder->build_sample_item( >+ { >+ biblionumber => $biblio->biblionumber, >+ library => $branch_farther->branchcode, >+ } >+ ); >+ my $item_closer = $builder->build_sample_item( >+ { >+ biblionumber => $biblio->biblionumber, >+ library => $branch_closer->branchcode, >+ } >+ ); >+ >+ my $borrower = $builder->build({ >+ source => 'Borrower', >+ value => { >+ branchcode => $branch_pickup->branchcode, >+ } >+ }); >+ >+ my $res = AddReserve( >+ { >+ branchcode => $branch_pickup->branchcode, >+ borrowernumber => $borrower->{borrowernumber}, >+ biblionumber => $item_farther->biblionumber, >+ priority => 1, >+ } >+ ); >+ my $hold = Koha::Holds->find( $res ); >+ >+ my $transport_cost_matrix = {}; >+ $transport_cost_matrix->{$branch_pickup->id}->{$branch_closer->id}->{cost} = 5; >+ $transport_cost_matrix->{$branch_pickup->id}->{$branch_farther->id}->{cost} = 10; >+ my $map = C4::HoldsQueue::MapItemsToHoldRequests([$hold->unblessed], [$item_closer->unblessed, $item_farther->unblessed], undef, $transport_cost_matrix); >+ >+ my $priority_branch = 'homebranch'; >+ my $pickup_branch = $hold->branchcode; >+ my $items_by_branch = { $branch_farther->branchcode => [ $item_farther->unblessed ] }; >+ my $items_by_itemnumber = { $item_farther->id => [ $item_farther->unblessed ] }; >+ my $itemnumber = C4::HoldsQueue::get_least_cost_item( $priority_branch, $holdingbranch, $items_by_branch, $items_by_itemnumber, $libraries, $hold->unblessed ); >+ >+ is( $itemnumber, $item_farther->id, "Got the least cost item" ); >+ >+ $schema->storage->txn_rollback; > }; >-- >2.30.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 33794
:
151712
|
151987
|
156105
|
156115
|
156117
| 156118