Bugzilla – Attachment 37418 Details for
Bug 8236
Prevent renewing if overdue or restriction
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 8236: Tests for Renewing policy in overdue or restriction case
Bug-8236-Tests-for-Renewing-policy-in-overdue-or-r.patch (text/plain), 6.14 KB, created by
Matthias Meusburger
on 2015-04-01 13:06:38 UTC
(
hide
)
Description:
Bug 8236: Tests for Renewing policy in overdue or restriction case
Filename:
MIME Type:
Creator:
Matthias Meusburger
Created:
2015-04-01 13:06:38 UTC
Size:
6.14 KB
patch
obsolete
>From 1a2a1604ed897f20bf3d20e6bf4932976ecf71ed Mon Sep 17 00:00:00 2001 >From: Matthias Meusburger <matthias.meusburger@biblibre.com> >Date: Wed, 1 Apr 2015 15:05:36 +0200 >Subject: [PATCH] Bug 8236: Tests for Renewing policy in overdue or restriction > case > > - Add tests in t/db_dependent/Circulation.t >--- > t/db_dependent/Circulation.t | 84 ++++++++++++++++++++++++++++++++++++++++++-- > 1 file changed, 81 insertions(+), 3 deletions(-) > >diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t >index 02d7b00..2fa07c7 100755 >--- a/t/db_dependent/Circulation.t >+++ b/t/db_dependent/Circulation.t >@@ -27,7 +27,7 @@ use C4::Overdues qw(UpdateFine); > use Koha::DateUtils; > use Koha::Database; > >-use Test::More tests => 60; >+use Test::More tests => 69 ; > > BEGIN { > use_ok('C4::Circulation'); >@@ -234,6 +234,9 @@ C4::Context->dbh->do("DELETE FROM accountlines"); > $biblionumber > ); > >+ >+ >+ > # Create borrowers > my %renewing_borrower_data = ( > firstname => 'John', >@@ -256,11 +259,21 @@ C4::Context->dbh->do("DELETE FROM accountlines"); > branchcode => $branch, > ); > >+ my %restricted_borrower_data = ( >+ firstname => 'Alice', >+ surname => 'Reservation', >+ categorycode => 'S', >+ debarred => '3228-01-01', >+ branchcode => $branch, >+ ); >+ > my $renewing_borrowernumber = AddMember(%renewing_borrower_data); > my $reserving_borrowernumber = AddMember(%reserving_borrower_data); > my $hold_waiting_borrowernumber = AddMember(%hold_waiting_borrower_data); >+ my $restricted_borrowernumber = AddMember(%restricted_borrower_data); > > my $renewing_borrower = GetMember( borrowernumber => $renewing_borrowernumber ); >+ my $restricted_borrower = GetMember( borrowernumber => $restricted_borrowernumber ); > > my $constraint = 'a'; > my $bibitems = ''; >@@ -277,6 +290,7 @@ C4::Context->dbh->do("DELETE FROM accountlines"); > my $datedue2 = AddIssue( $renewing_borrower, $barcode2); > is (defined $datedue2, 1, "Item 2 checked out, due date: $datedue2"); > >+ > my $borrowing_borrowernumber = GetItemIssue($itemnumber)->{borrowernumber}; > is ($borrowing_borrowernumber, $renewing_borrowernumber, "Item checked out to $renewing_borrower->{firstname} $renewing_borrower->{surname}"); > >@@ -348,7 +362,7 @@ C4::Context->dbh->do("DELETE FROM accountlines"); > ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber2, 1); > is( $renewokay, 1, 'Can renew item 2, item-level hold is on item 1'); > >- >+ > # Items can't fill hold for reasons > ModItem({ notforloan => 1 }, $biblionumber, $itemnumber); > ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber, 1); >@@ -357,6 +371,62 @@ C4::Context->dbh->do("DELETE FROM accountlines"); > > # FIXME: Add more for itemtype not for loan etc. > >+ # Restricted users cannot renew when RestrictionBlockRenewing is enabled >+ my $barcode5 = 'R00000347'; >+ my ( $item_bibnum5, $item_bibitemnum5, $itemnumber5 ) = AddItem( >+ { >+ homebranch => $branch, >+ holdingbranch => $branch, >+ barcode => $barcode5, >+ replacementprice => 23.00 >+ }, >+ $biblionumber >+ ); >+ my $datedue5 = AddIssue($restricted_borrower, $barcode5); >+ is (defined $datedue5, 1, "Item with date due checked out, due date: $datedue5"); >+ >+ C4::Context->set_preference('RestrictionBlockRenewing','1'); >+ ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber2); >+ is( $renewokay, 1, '(Bug 8236), Can renew, user is not restricted'); >+ ( $renewokay, $error ) = CanBookBeRenewed($restricted_borrowernumber, $itemnumber5); >+ is( $renewokay, 0, '(Bug 8236), Cannot renew, user is restricted'); >+ >+ # Users cannot renew an overdue item >+ my $barcode6 = 'R00000348'; >+ my ( $item_bibnum6, $item_bibitemnum6, $itemnumber6 ) = AddItem( >+ { >+ homebranch => $branch, >+ holdingbranch => $branch, >+ barcode => $barcode6, >+ replacementprice => 23.00 >+ }, >+ $biblionumber >+ ); >+ >+ my $barcode7 = 'R00000349'; >+ my ( $item_bibnum7, $item_bibitemnum7, $itemnumber7 ) = AddItem( >+ { >+ homebranch => $branch, >+ holdingbranch => $branch, >+ barcode => $barcode7, >+ replacementprice => 23.00 >+ }, >+ $biblionumber >+ ); >+ my $datedue6 = AddIssue( $renewing_borrower, $barcode6); >+ is (defined $datedue6, 1, "Item 2 checked out, due date: $datedue6"); >+ >+ my $passeddatedue1 = AddIssue($renewing_borrower, $barcode7, DateTime->from_epoch(epoch => 1)); >+ is (defined $passeddatedue1, 1, "Item with passed date due checked out, due date: $passeddatedue1"); >+ >+ >+ C4::Context->set_preference('OverduesBlockRenewing','blockitem'); >+ ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber6); >+ is( $renewokay, 1, '(Bug 8236), Can renew, this item is not overdue'); >+ ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber7); >+ is( $renewokay, 0, '(Bug 8236), Cannot renew, this item is overdue'); >+ >+ > $reserveid = C4::Reserves::GetReserveId({ biblionumber => $biblionumber, itemnumber => $itemnumber, borrowernumber => $reserving_borrowernumber}); > CancelReserve({ reserve_id => $reserveid }); > >@@ -452,7 +522,15 @@ C4::Context->dbh->do("DELETE FROM accountlines"); > $future->add( days => 7 ); > my $units = C4::Overdues::_get_chargeable_units('days', $future, $now, 'MPL'); > ok( $units == 0, '_get_chargeable_units returns 0 for items not past due date (Bug 12596)' ); >-} >+ >+ # Users cannot renew any item if there is an overdue item >+ C4::Context->set_preference('OverduesBlockRenewing','block'); >+ ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber6); >+ is( $renewokay, 0, '(Bug 8236), Cannot renew, one of the items is overdue'); >+ ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber7); >+ is( $renewokay, 0, '(Bug 8236), Cannot renew, one of the items is overdue'); >+ >+ } > > { > # GetUpcomingDueIssues tests >-- >1.9.1
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 8236
:
10230
|
11958
|
12362
|
12619
|
12727
|
12790
|
12791
|
13510
|
14433
|
17926
|
18071
|
18073
|
18507
|
18729
|
20716
|
20719
|
21163
|
21223
|
22264
|
22275
|
22280
|
34234
|
34322
|
35372
|
36674
|
36743
|
37407
|
37418
|
37457
|
37458
|
37459
|
41992
|
41993
|
41994
|
42007
|
43628