Bugzilla – Attachment 71134 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), 6.53 KB, created by
Marcel de Rooy
on 2018-02-02 09:05:25 UTC
(
hide
)
Description:
Bug 15494 - Unit tests
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2018-02-02 09:05:25 UTC
Size:
6.53 KB
patch
obsolete
>From 9962aa87c0184084975440c0c98213c7ab380d09 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 >Content-Type: text/plain; charset=utf-8 > >prove -v t/db_dependent/Circulation.t > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > t/db_dependent/Circulation.t | 118 ++++++++++++++++++++++++++++++++++++++++++- > 1 file changed, 116 insertions(+), 2 deletions(-) > >diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t >index 570ae3c..e845f21 100755 >--- a/t/db_dependent/Circulation.t >+++ b/t/db_dependent/Circulation.t >@@ -17,7 +17,7 @@ > > use Modern::Perl; > >-use Test::More tests => 113; >+use Test::More tests => 114; > > use DateTime; > >@@ -220,7 +220,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 $title = 'Silence in the library'; > my ($biblionumber, $biblioitemnumber) = add_biblio($title, 'Moffat, Steven'); >@@ -2044,7 +2044,121 @@ 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 => 16; > >+ 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', >+ itemcallnumber => undef, >+ itemnotes => "", >+ } >+ }); >+ 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 $future = dt_from_string->add( days => 1 ); >+ 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, >+ date_due => $future, >+ } >+ }); >+ 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, >+ date_due => $future, >+ } >+ }); >+ >+ 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]\ntype: [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]\nitype: [HIDE,INVISIBLE]\nlocation: [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)' ); >+ >+ $idr_rules="itemcallnumber: [NULL]"; >+ 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 for undef when NULL in pref' ); >+ >+ $idr_rules="itemnotes: ['']"; >+ 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 for empty string when "" in pref' ); > }; > > sub set_userenv { >-- >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