Bugzilla – Attachment 95445 Details for
Bug 23732
Hold rules checker: show matched rules and syspref values to help understand why a hold is possible or not
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 23732: Add unit tests
Bug-23732-Add-unit-tests.patch (text/plain), 4.67 KB, created by
Victor Grousset/tuxayo
on 2019-11-14 17:01:09 UTC
(
hide
)
Description:
Bug 23732: Add unit tests
Filename:
MIME Type:
Creator:
Victor Grousset/tuxayo
Created:
2019-11-14 17:01:09 UTC
Size:
4.67 KB
patch
obsolete
>From fab86bc8f1a513255f7464e221ba6413120be3b9 Mon Sep 17 00:00:00 2001 >From: Alex Arnaud <alex.arnaud@biblibre.com> >Date: Wed, 2 Oct 2019 14:50:25 +0200 >Subject: [PATCH] Bug 23732: Add unit tests > >== test plan == >1. prove -r t/db_dependent/Reserves >2. Apply bugzilla >3. prove t/db_dependent/Reserves/HoldRulesChecker.t >4. prove -r t/db_dependent/Reserves >--- > t/db_dependent/Reserves/HoldRulesChecker.t | 130 +++++++++++++++++++++ > 1 file changed, 130 insertions(+) > create mode 100644 t/db_dependent/Reserves/HoldRulesChecker.t > >diff --git a/t/db_dependent/Reserves/HoldRulesChecker.t b/t/db_dependent/Reserves/HoldRulesChecker.t >new file mode 100644 >index 0000000000..2d33e78b06 >--- /dev/null >+++ b/t/db_dependent/Reserves/HoldRulesChecker.t >@@ -0,0 +1,130 @@ >+#!/usr/bin/perl >+ >+# Copyright 2019 Biblibre >+# >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+ >+use Test::More tests => 11; >+use t::lib::TestBuilder; >+ >+use C4::Reserves qw( CanBookBeReserved ); >+ >+my $schema = Koha::Database->new->schema; >+$schema->storage->txn_begin; >+ >+my $builder = t::lib::TestBuilder->new(); >+my $library = $builder->build( >+ { >+ source => 'Branch', >+ } >+); >+ >+my $category = $builder->build( >+ { >+ source => 'Category', >+ } >+); >+my $patron = $builder->build( >+ { >+ source => 'Borrower', >+ value => { >+ categorycode => $category->{categorycode}, >+ branchcode => $library->{branchcode}, >+ }, >+ } >+); >+ >+my $itemtype1 = $builder->build( >+ { >+ source => 'Itemtype' >+ } >+); >+ >+my $biblio = $builder->build( >+ { >+ source => 'Biblio', >+ value => { >+ title => 'Title 1', >+ }, >+ } >+); >+my $biblioitem = $builder->build( >+ { >+ source => 'Biblioitem', >+ value => { biblionumber => $biblio->{biblionumber} } >+ } >+); >+my $item1 = $builder->build( >+ { >+ source => 'Item', >+ value => { >+ biblionumber => $biblio->{biblionumber}, >+ itype => $itemtype1->{itemtype}, >+ homebranch => $library->{branchcode}, >+ holdingbranch => $library->{branchcode}, >+ damaged => 0, >+ }, >+ } >+); >+ >+my $rules_rs = Koha::Database->new()->schema()->resultset('Issuingrule'); >+$rules_rs->delete(); >+ >+my $rule1 = $rules_rs->new( >+ { >+ categorycode => '*', >+ itemtype => '*', >+ branchcode => '*', >+ reservesallowed => 1, >+ holds_per_record => 1, >+ } >+)->insert(); >+ >+my $can = CanBookBeReserved($patron->{borrowernumber}, $biblio->{biblionumber}); >+ >+is($can->{issuingrule}{reservesallowed}, 1, 'Matched rule #1 says 1 reserve allowed'); >+is($can->{issuingrule}{holds_per_record}, 1, 'Matched rule #1 says 1 reserve per record allowed'); >+is($can->{issuingrule}{itemtype}, '*', 'Matched rule is for all item types'); >+is($can->{issuingrule}{categorycode}, '*', 'Matched rule is for all patron categories'); >+is($can->{issuingrule}{branchcode}, '*', 'Matched rule is for all branches'); >+ >+is($can->{circulation_rule}, undef, 'No rule matched for holds policy'); >+ >+my $rule2 = $rules_rs->new( >+ { >+ categorycode => $patron->{categorycode}, >+ itemtype => '*', >+ branchcode => $library->{branchcode}, >+ reservesallowed => 5, >+ holds_per_record => 2, >+ } >+)->insert(); >+ >+$can = CanBookBeReserved($patron->{borrowernumber}, $biblio->{biblionumber}); >+ >+is($can->{issuingrule}{reservesallowed}, 5, 'Matched rule #2 says 5 reserve allowed'); >+is($can->{issuingrule}{holds_per_record}, 2, 'Matched rule #2 says 2 reserve per record allowed'); >+ >+Koha::CirculationRules->set_rule({ branchcode => $library->{branchcode}, categorycode => $patron->{categorycode}, itemtype => undef, rule_name => 'max_holds', rule_value => '10'}); >+ >+$can = CanBookBeReserved($patron->{borrowernumber}, $biblio->{biblionumber}); >+is($can->{circulation_rule}->branchcode, $library->{branchcode}); >+is($can->{circulation_rule}->categorycode, $patron->{categorycode}); >+is($can->{circulation_rule}->rule_value, 10); >+ >+$schema->storage->txn_rollback; >-- >2.23.0
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 23732
:
95435
|
95436
|
95443
|
95444
|
95445
|
95934
|
147501
|
147504
|
173427
|
173428