Bugzilla – Attachment 68146 Details for
Bug 15494
Block renewals by arbitrary item values
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 15494 - Unit tests
Bug-15494---Unit-tests.patch (text/plain), 5.71 KB, created by
Katrin Fischer
on 2017-10-14 23:09:52 UTC
(
hide
)
Description:
Bug 15494 - Unit tests
Filename:
MIME Type:
Creator:
Katrin Fischer
Created:
2017-10-14 23:09:52 UTC
Size:
5.71 KB
patch
obsolete
>From 5b09da36c1710484328219b6c0335002de62fdf6 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Wed, 24 May 2017 08:50:16 -0400 >Subject: [PATCH] Bug 15494 - Unit tests > >prove t/db_dependent/Circulation.t > >Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> >--- > t/db_dependent/Circulation.t | 109 ++++++++++++++++++++++++++++++++++++++++++- > 1 file changed, 107 insertions(+), 2 deletions(-) > >diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t >index 17752bd..dba1997 100755 >--- a/t/db_dependent/Circulation.t >+++ b/t/db_dependent/Circulation.t >@@ -17,7 +17,7 @@ > > use Modern::Perl; > >-use Test::More tests => 103; >+use Test::More tests => 104; > > use DateTime; > >@@ -208,7 +208,7 @@ C4::Context->dbh->do("DELETE FROM borrowers WHERE cardnumber = '99999999999'"); > C4::Context->dbh->do("DELETE FROM accountlines"); > { > # CanBookBeRenewed tests >- >+ t::lib::Mocks::mock_preference( 'ItemsDeniedRenewal', '' ); #Ensure pref doesn't affect current tests > # Generate test biblio > my $biblio = MARC::Record->new(); > my $title = 'Silence in the library'; >@@ -1873,6 +1873,111 @@ subtest 'CanBookBeIssued | is_overdue' => sub { > my ($issuingimpossible, $needsconfirmation) = CanBookBeIssued($patron,$item->{barcode},$ten_days_go, undef, undef, undef); > is( $needsconfirmation->{RENEW_ISSUE}, 1, "This is a renewal"); > is( $needsconfirmation->{TOO_MANY}, undef, "Not too many, is a renewal"); >+}; >+ >+subtest 'ItemsDeniedRenewal preference' => sub { >+ plan tests => 14; >+ >+ t::lib::Mocks::mock_preference( 'ItemsDeniedRenewal', '' ); >+ >+ $dbh->do('DELETE FROM issues'); >+ $dbh->do('DELETE FROM items'); >+ $dbh->do('DELETE FROM issuingrules'); >+ $dbh->do( >+ q{ >+ INSERT INTO issuingrules ( categorycode, branchcode, itemtype, reservesallowed, maxissueqty, issuelength, lengthunit, renewalsallowed, renewalperiod, >+ norenewalbefore, auto_renew, fine, chargeperiod ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? ) >+ }, >+ {}, >+ '*', '*', '*', 25, >+ 20, 14, 'days', >+ 10, 7, >+ undef, 0, >+ .10, 1 >+ ); >+ >+ my $deny_book = $builder->build_object({ class => 'Koha::Items', value => { >+ withdrawn => 1, >+ itype => 'HIDE', >+ location => 'PROC' >+ } >+ }); >+ my $allow_book = $builder->build_object({ class => 'Koha::Items', value => { >+ withdrawn => 0, >+ itype => 'NOHIDE', >+ location => 'NOPROC' >+ } >+ }); >+ >+ my $idr_borrower = $builder->build_object({ class => 'Koha::Patrons'}); >+ >+ my $deny_issue = $builder->build_object({ class => 'Koha::Checkouts', value => { >+ returndate => undef, >+ renewals => 0, >+ auto_renew => 0, >+ borrowernumber => $idr_borrower->borrowernumber, >+ itemnumber => $deny_book->itemnumber, >+ onsite_checkout => 0, >+ } >+ }); >+ my $allow_issue = $builder->build_object({ class => 'Koha::Checkouts', value => { >+ returndate => undef, >+ renewals => 0, >+ auto_renew => 0, >+ borrowernumber => $idr_borrower->borrowernumber, >+ itemnumber => $allow_book->itemnumber, >+ onsite_checkout => 0, >+ } >+ }); >+ >+ my $idr_rules; >+ >+ my ( $idr_mayrenew, $idr_error ) = >+ CanBookBeRenewed( $idr_borrower->borrowernumber, $deny_issue->itemnumber ); >+ is( $idr_mayrenew, 1, 'Renewal allowed when no rules' ); >+ is( $idr_error, undef, 'Renewal allowed when no rules' ); >+ >+ $idr_rules=" >+ withdrawn: [1]"; >+ >+ t::lib::Mocks::mock_preference( 'ItemsDeniedRenewal', $idr_rules ); >+ ( $idr_mayrenew, $idr_error ) = >+ CanBookBeRenewed( $idr_borrower->borrowernumber, $deny_issue->itemnumber ); >+ is( $idr_mayrenew, 0, 'Renewal blocked when 1 rules (withdrawn)' ); >+ is( $idr_error, 'item_denied_renewal', 'Renewal blocked when 1 rule (withdrawn)' ); >+ ( $idr_mayrenew, $idr_error ) = >+ CanBookBeRenewed( $idr_borrower->borrowernumber, $allow_issue->itemnumber ); >+ is( $idr_mayrenew, 1, 'Renewal allowed when 1 rules not matched (withdrawn)' ); >+ is( $idr_error, undef, 'Renewal allowed when 1 rules not matched (withdrawn)' ); >+ >+ $idr_rules=" >+ withdrawn: [1] >+ itype: [HIDE,INVISILE]"; >+ >+ t::lib::Mocks::mock_preference( 'ItemsDeniedRenewal', $idr_rules ); >+ ( $idr_mayrenew, $idr_error ) = >+ CanBookBeRenewed( $idr_borrower->borrowernumber, $deny_issue->itemnumber ); >+ is( $idr_mayrenew, 0, 'Renewal blocked when 2 rules matched (withdrawn, itype)' ); >+ is( $idr_error, 'item_denied_renewal', 'Renewal blocked when 2 rules matched (withdrawn,itype)' ); >+ ( $idr_mayrenew, $idr_error ) = >+ CanBookBeRenewed( $idr_borrower->borrowernumber, $allow_issue->itemnumber ); >+ is( $idr_mayrenew, 1, 'Renewal allowed when 2 rules not matched (withdrawn, itype)' ); >+ is( $idr_error, undef, 'Renewal allowed when 2 rules not matched (withdrawn, itype)' ); >+ >+ $idr_rules=" >+ withdrawn: [1] >+ itype: [HIDE,INVISIBLE] >+ location: [PROC]"; >+ >+ t::lib::Mocks::mock_preference( 'ItemsDeniedRenewal', $idr_rules ); >+ ( $idr_mayrenew, $idr_error ) = >+ CanBookBeRenewed( $idr_borrower->borrowernumber, $deny_issue->itemnumber ); >+ is( $idr_mayrenew, 0, 'Renewal blocked when 3 rules matched (withdrawn, itype, location)' ); >+ is( $idr_error, 'item_denied_renewal', 'Renewal blocked when 3 rules matched (withdrawn,itype, location)' ); >+ ( $idr_mayrenew, $idr_error ) = >+ CanBookBeRenewed( $idr_borrower->borrowernumber, $allow_issue->itemnumber ); >+ is( $idr_mayrenew, 1, 'Renewal allowed when 3 rules not matched (withdrawn, itype, location)' ); >+ is( $idr_error, undef, 'Renewal allowed when 3 rules not matched (withdrawn, itype, location)' ); > > }; > >-- >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 15494
:
63700
|
63701
|
63702
|
63703
|
67886
|
67887
|
67888
|
67889
|
68146
|
68147
|
68148
|
68149
|
70295
|
70629
|
70630
|
70631
|
70632
|
71129
|
71130
|
71131
|
71132
|
71133
|
71134
|
71135
|
71136
|
71137
|
71138
|
79249
|
79250
|
79251
|
79252
|
79253
|
79254
|
79293
|
80327
|
80328
|
80329
|
80330
|
80331
|
80332
|
80333
|
81411
|
81412
|
81413
|
81414
|
81415
|
81416
|
81417