Bugzilla – Attachment 159335 Details for
Bug 35431
TransportCostMatrix should be checked after HoldsQueuePrioritizeBranch
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 35431: Unit tests
Bug-35431-Unit-tests.patch (text/plain), 3.74 KB, created by
Nick Clemens (kidclamp)
on 2023-11-29 13:37:33 UTC
(
hide
)
Description:
Bug 35431: Unit tests
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2023-11-29 13:37:33 UTC
Size:
3.74 KB
patch
obsolete
>From 716dec0e43dcd283f3c7fb617bb383d345c9a36a Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Wed, 29 Nov 2023 13:05:40 +0000 >Subject: [PATCH] Bug 35431: Unit tests > >--- > t/db_dependent/HoldsQueue.t | 73 ++++++++++++++++++++++++++++++++++++- > 1 file changed, 72 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/HoldsQueue.t b/t/db_dependent/HoldsQueue.t >index 7875c69eedd..78e27e67ecc 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 ); >@@ -23,6 +23,8 @@ use Koha::CirculationRules; > > use t::lib::TestBuilder; > use t::lib::Mocks; >+use Test::MockModule; >+use Test::Warn; > > BEGIN { > use FindBin; >@@ -38,6 +40,72 @@ $dbh->do("DELETE FROM circulation_rules"); > > my $builder = t::lib::TestBuilder->new; > >+subtest "MapItemsToHoldRequests tests" => sub { >+ plan tests => 1; >+ >+ $schema->storage->txn_begin; >+ >+ subtest "TransportCostMatrix tests" => sub { >+ t::lib::Mocks::mock_preference( 'LocalHoldsPriority', 0 ); >+ t::lib::Mocks::mock_preference( 'HoldsQueuePrioritizeBranch', 'homebranch' ); >+ my $HoldsQueue = Test::MockModule->new('C4::HoldsQueue'); >+ $HoldsQueue->mock( >+ 'least_cost_branch', >+ sub { >+ warn "Checking transport cost matrix"; >+ return; >+ } >+ ); >+ >+ my $branch_a = $builder->build_object( { class => 'Koha::Libraries', value => { pickup_location => 1 } } ); >+ my $branch_b = $builder->build_object( { class => 'Koha::Libraries', value => { pickup_location => 1 } } ); >+ my $item_1 = $builder->build_sample_item( >+ { homebranch => $branch_a->branchcode, holdingbranch => $branch_b->branchcode } ); >+ my $patron = $builder->build_object( >+ { >+ class => "Koha::Patrons", >+ value => { >+ branchcode => $branch_b->branchcode, >+ } >+ } >+ ); >+ my $hold = $builder->build_object( >+ { >+ class => 'Koha::Holds', >+ value => { >+ itemnumber => undef, >+ biblionumber => $item_1->biblionumber, >+ branchcode => $branch_b->branchcode, >+ item_level_hold => 0, >+ item_group_id => undef, >+ itemtype => undef, >+ borrowernumber => $patron->id, >+ } >+ } >+ ); >+ >+ my $tcm = { >+ $branch_b->branchcode => { >+ $branch_a->branchcode => { cost => 10 }, >+ } >+ }; >+ >+ my $hq_item = $item_1->unblessed; >+ $hq_item->{holdallowed} = 'from_any_library'; >+ $hq_item->{hold_fullfillment_policy} = 'any'; >+ my $hq_hold = $hold->unblessed; >+ $hq_hold->{borrowerbranch} = $branch_b->branchcode; >+ warning_is { >+ C4::HoldsQueue::MapItemsToHoldRequests( [$hq_hold], [$hq_item], [ $branch_a->branchcode ], $tcm ); >+ } >+ "Checking transport cost matrix", >+ "Transport cost matrix is checked when HoldsQueuePrioritizeBranch does not match"; >+ >+ }; >+ >+ $schema->storage->txn_rollback; >+}; >+ > t::lib::Mocks::mock_preference( 'UseBranchTransferLimits', '0' ); > t::lib::Mocks::mock_preference( 'BranchTransferLimitsType', 'itemtype' ); > >@@ -2091,3 +2159,6 @@ subtest "GetItemsAvailableToFillHoldsRequestsForBib" => sub { > is_deeply( [$items->[0]->{itemnumber},$items->[1]->{itemnumber}],[$item_2->itemnumber,$item_3->itemnumber],"Correct two items retrieved"); > > }; >+ >+ >+ >-- >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 35431
: 159335 |
159336