Bugzilla – Attachment 63700 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.62 KB, created by
Nick Clemens (kidclamp)
on 2017-05-24 14:46:16 UTC
(
hide
)
Description:
Bug 15494 - Unit tests
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2017-05-24 14:46:16 UTC
Size:
5.62 KB
patch
obsolete
>From b750d935311b5c7386a43857acdfd84b40ebcc4b 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 >--- > t/db_dependent/Circulation.t | 110 ++++++++++++++++++++++++++++++++++++++++++- > 1 file changed, 108 insertions(+), 2 deletions(-) > >diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t >index 9a5b821..8fb3ede 100755 >--- a/t/db_dependent/Circulation.t >+++ b/t/db_dependent/Circulation.t >@@ -17,7 +17,7 @@ > > use Modern::Perl; > >-use Test::More tests => 95; >+use Test::More tests => 96; > > use DateTime; > >@@ -205,7 +205,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'; >@@ -1626,6 +1626,112 @@ subtest 'AddReturn + CumulativeRestrictionPeriods' => sub { > is( $debarments->[0]->{expiration}, $expected_expiration ); > }; > >+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)' ); >+ >+}; >+ > sub set_userenv { > my ( $library ) = @_; > C4::Context->set_userenv(0,0,0,'firstname','surname', $library->{branchcode}, $library->{branchname}, '', '', ''); >-- >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