Bugzilla – Attachment 76102 Details for
Bug 20955
Add ability to trigger holds that violate holds policies (overridden holds)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 20955: Unit tests
Bug-20955-Unit-tests.patch (text/plain), 5.70 KB, created by
Nick Clemens (kidclamp)
on 2018-06-15 14:26:07 UTC
(
hide
)
Description:
Bug 20955: Unit tests
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2018-06-15 14:26:07 UTC
Size:
5.70 KB
patch
obsolete
>From 73e0bf6fb3e517906ebe93c0306bb6170827a18b Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Fri, 15 Jun 2018 14:25:10 +0000 >Subject: [PATCH] Bug 20955: Unit tests > >prove -v t/db_dependent/Holds/HoldFulfillmentPolicy.t >prove -v t/db_dependent/Reserves.t >--- > t/db_dependent/Holds/HoldFulfillmentPolicy.t | 23 ++++++++++++++++++++--- > t/db_dependent/Reserves.t | 9 ++++++++- > 2 files changed, 28 insertions(+), 4 deletions(-) > >diff --git a/t/db_dependent/Holds/HoldFulfillmentPolicy.t b/t/db_dependent/Holds/HoldFulfillmentPolicy.t >index 34bb3ed..25bf5a9 100755 >--- a/t/db_dependent/Holds/HoldFulfillmentPolicy.t >+++ b/t/db_dependent/Holds/HoldFulfillmentPolicy.t >@@ -4,9 +4,10 @@ use Modern::Perl; > > use C4::Context; > >-use Test::More tests => 10; >+use Test::More tests => 14; > > use t::lib::TestBuilder; >+use t::lib::Mocks; > use Koha::Holds; > > BEGIN { >@@ -38,7 +39,6 @@ my $borrower = $builder->build({ > branchcode => $library1->{branchcode}, > } > }); >- > # Test hold_fulfillment_policy > my $borrowernumber = $borrower->{borrowernumber}; > my $library_A = $library1->{branchcode}; >@@ -76,6 +76,7 @@ my $itemnumber = > $dbh->do("DELETE FROM default_circ_rules"); > $dbh->do("INSERT INTO default_circ_rules ( holdallowed, hold_fulfillment_policy ) VALUES ( 2, 'homebranch' )"); > >+t::lib::Mocks::mock_preference('TriggerForbiddenHolds', 0); > # Home branch matches pickup branch > my $reserve_id = AddReserve( $library_A, $borrowernumber, $biblionumber, '', 1 ); > my ( $status ) = CheckReserves($itemnumber); >@@ -86,12 +87,20 @@ Koha::Holds->find( $reserve_id )->cancel; > $reserve_id = AddReserve( $library_B, $borrowernumber, $biblionumber, '', 1 ); > ( $status ) = CheckReserves($itemnumber); > is($status, q{}, "Hold where pickup ne home, pickup eq home not targeted" ); >+t::lib::Mocks::mock_preference('TriggerForbiddenHolds', 1); >+( $status ) = CheckReserves($itemnumber); >+is($status, 'Reserved', "Hold where pickup ne home, pickup eq home targeted when TriggerForbiddenHolds set to yes" ); >+t::lib::Mocks::mock_preference('TriggerForbiddenHolds', 0); > Koha::Holds->find( $reserve_id )->cancel; > > # Neither branch matches pickup branch > $reserve_id = AddReserve( $library_C, $borrowernumber, $biblionumber, '', 1 ); > ( $status ) = CheckReserves($itemnumber); > is( $status, q{}, "Hold where pickup ne home, pickup ne holding not targeted" ); >+t::lib::Mocks::mock_preference('TriggerForbiddenHolds', 1); >+( $status ) = CheckReserves($itemnumber); >+is( $status, 'Reserved', "Hold where pickup ne home, pickup ne holding targeted when TriggerForbiddenHolds set to yes" ); >+t::lib::Mocks::mock_preference('TriggerForbiddenHolds', 0); > Koha::Holds->find( $reserve_id )->cancel; > > # With hold_fulfillment_policy = holdingbranch, hold should only be picked up if pickup branch = holdingbranch >@@ -102,6 +111,10 @@ $dbh->do("INSERT INTO default_circ_rules ( holdallowed, hold_fulfillment_policy > $reserve_id = AddReserve( $library_A, $borrowernumber, $biblionumber, '', 1 ); > ( $status ) = CheckReserves($itemnumber); > is( $status, q{}, "Hold where pickup eq home, pickup ne holding not targeted" ); >+t::lib::Mocks::mock_preference('TriggerForbiddenHolds', 1); >+( $status ) = CheckReserves($itemnumber); >+is( $status, 'Reserved', "Hold where pickup eq home, pickup ne holding targeted when TriggerForbiddenHolds set to yes" ); >+t::lib::Mocks::mock_preference('TriggerForbiddenHolds', 0); > Koha::Holds->find( $reserve_id )->cancel; > > # Holding branch matches pickup branch >@@ -114,9 +127,13 @@ Koha::Holds->find( $reserve_id )->cancel; > $reserve_id = AddReserve( $library_C, $borrowernumber, $biblionumber, '', 1 ); > ( $status ) = CheckReserves($itemnumber); > is( $status, q{}, "Hold where pickup ne home, pickup ne holding not targeted" ); >+t::lib::Mocks::mock_preference('TriggerForbiddenHolds', 1); >+( $status ) = CheckReserves($itemnumber); >+is( $status, 'Reserved', "Hold where pickup ne home, pickup ne holding targeted when TriggerForbiddenHolds set to yes" ); >+t::lib::Mocks::mock_preference('TriggerForbiddenHolds', 0); > Koha::Holds->find( $reserve_id )->cancel; > >-# With hold_fulfillment_policy = any, hold should be pikcup up reguardless of matching home or holding branch >+# With hold_fulfillment_policy = any, hold should be pickup up reguardless of matching home or holding branch > $dbh->do("DELETE FROM default_circ_rules"); > $dbh->do("INSERT INTO default_circ_rules ( holdallowed, hold_fulfillment_policy ) VALUES ( 2, 'any' )"); > >diff --git a/t/db_dependent/Reserves.t b/t/db_dependent/Reserves.t >index 4fae478..911a0ca 100755 >--- a/t/db_dependent/Reserves.t >+++ b/t/db_dependent/Reserves.t >@@ -17,7 +17,7 @@ > > use Modern::Perl; > >-use Test::More tests => 57; >+use Test::More tests => 58; > use Test::MockModule; > use Test::Warn; > >@@ -301,10 +301,17 @@ my $messages; > # Return the CPL item at FPL. The hold that should be triggered is > # the one placed by the CPL patron, as the other two patron's hold > # requests cannot be filled by that item per policy. >+t::lib::Mocks::mock_preference('TriggerForbiddenHolds', 0); > (undef, $messages, undef, undef) = AddReturn('bug10272_CPL', $branch_2); > is( $messages->{ResFound}->{borrowernumber}, > $requesters{$branch_1}, > 'restrictive library\'s items only fill requests by own patrons (bug 10272)'); >+t::lib::Mocks::mock_preference('TriggerForbiddenHolds', 1); >+(undef, $messages, undef, undef) = AddReturn('bug10272_CPL', $branch_2); >+is( $messages->{ResFound}->{borrowernumber}, >+ $requesters{$branch_3}, >+ 'restrictive library\'s items fill requests when TriggerForbiddenHolds set to yes'); >+t::lib::Mocks::mock_preference('TriggerForbiddenHolds', 0); > > # Return the FPL item at FPL. The hold that should be triggered is > # the one placed by the RPL patron, as that patron is first in line >-- >2.1.4
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 20955
:
76101
| 76102