Bugzilla – Attachment 43812 Details for
Bug 14395
Two different ways to calculate 'No renewal before' (days or hours)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 14395: Unit tests
Bug-14395-Unit-tests.patch (text/plain), 5.36 KB, created by
Holger Meißner
on 2015-10-23 09:05:42 UTC
(
hide
)
Description:
Bug 14395: Unit tests
Filename:
MIME Type:
Creator:
Holger Meißner
Created:
2015-10-23 09:05:42 UTC
Size:
5.36 KB
patch
obsolete
>From 30efddabbceb8d07034a484094ffc80e5441f097 Mon Sep 17 00:00:00 2001 >From: =?UTF-8?q?Holger=20Mei=C3=9Fner?= <h.meissner.82@web.de> >Date: Mon, 27 Jul 2015 15:18:53 +0200 >Subject: [PATCH] Bug 14395: Unit tests >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >This patch adds test cases for the new syspref NoRenewalBeforePrecision. >Tests if GetSoonestRenewDate returns correct values for both 'date' and >'exact_time' settings. >Also adds a few comments related to bugs 7413 and 14101. > >To test: > >1) prove t/db_dependent/Circulation.t > >Sponsored-by: Hochschule für Gesundheit (hsg), Germany >--- > t/db_dependent/Circulation.t | 40 +++++++++++++++++++++++++++++----------- > 1 file changed, 29 insertions(+), 11 deletions(-) > >diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t >index 65e951a..6044f7d 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 => 82; >+use Test::More tests => 83; > > BEGIN { > use_ok('C4::Circulation'); >@@ -445,7 +445,9 @@ C4::Context->dbh->do("DELETE FROM accountlines"); > $reserveid = C4::Reserves::GetReserveId({ biblionumber => $biblionumber, itemnumber => $itemnumber, borrowernumber => $reserving_borrowernumber}); > CancelReserve({ reserve_id => $reserveid }); > >+ # Bug 14101 > # Test automatic renewal before value for "norenewalbefore" in policy is set >+ # In this case automatic renewal is not permitted prior to due date > my $barcode4 = '11235813'; > my ( $item_bibnum4, $item_bibitemnum4, $itemnumber4 ) = AddItem( > { >@@ -457,31 +459,47 @@ C4::Context->dbh->do("DELETE FROM accountlines"); > $biblionumber > ); > >- AddIssue( $renewing_borrower, $barcode4, undef, undef, undef, undef, { auto_renew => 1 } ); >+ AddIssue( $renewing_borrower, $barcode4, undef, undef, undef, undef, >+ { auto_renew => 1 } ); > ( $renewokay, $error ) = > CanBookBeRenewed( $renewing_borrowernumber, $itemnumber4 ); > is( $renewokay, 0, 'Bug 14101: Cannot renew, renewal is automatic and premature' ); > is( $error, 'auto_too_soon', > 'Bug 14101: Cannot renew, renewal is automatic and premature, "No renewal before" = undef (returned code is auto_too_soon)' ); > >- # set policy to require that loans cannot be >- # renewed until seven days prior to the due date >+ # Bug 7413 >+ # Test premature manual renewal > $dbh->do('UPDATE issuingrules SET norenewalbefore = 7'); >+ > ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $itemnumber); > is( $renewokay, 0, 'Bug 7413: Cannot renew, renewal is premature'); > is( $error, 'too_soon', 'Bug 7413: Cannot renew, renewal is premature (returned code is too_soon)'); >+ >+ # Bug 14395 >+ # Test 'exact time' setting for syspref NoRenewalBeforePrecision >+ C4::Context->set_preference( 'NoRenewalBeforePrecision', 'exact_time' ); >+ is( >+ GetSoonestRenewDate( $renewing_borrowernumber, $itemnumber ), >+ $datedue->clone->add( days => -7 ), >+ 'Bug 14395: Renewals permitted 7 days before due date, as expected' >+ ); >+ >+ # Bug 14395 >+ # Test 'date' setting for syspref NoRenewalBeforePrecision >+ C4::Context->set_preference( 'NoRenewalBeforePrecision', 'date' ); > is( >- GetSoonestRenewDate($renewing_borrowernumber, $itemnumber), >- $datedue->clone->add(days => -7), >- 'Bug 7413: Renewals permitted 7 days before due date, as expected', >+ GetSoonestRenewDate( $renewing_borrowernumber, $itemnumber ), >+ $datedue->clone->add( days => -7 )->truncate( to => 'day' ), >+ 'Bug 14395: Renewals permitted 7 days before due date, as expected' > ); > >- # Test automatic renewal again >+ # Bug 14101 >+ # Test premature automatic renewal > ( $renewokay, $error ) = > CanBookBeRenewed( $renewing_borrowernumber, $itemnumber4 ); > is( $renewokay, 0, 'Bug 14101: Cannot renew, renewal is automatic and premature' ); > is( $error, 'auto_too_soon', >-'Bug 14101: Cannot renew, renewal is automatic and premature (returned code is auto_too_soon)' >+ 'Bug 14101: Cannot renew, renewal is automatic and premature (returned code is auto_too_soon)' > ); > > # Change policy so that loans can only be renewed exactly on due date (0 days prior to due date) >@@ -491,7 +509,7 @@ C4::Context->dbh->do("DELETE FROM accountlines"); > CanBookBeRenewed( $renewing_borrowernumber, $itemnumber4 ); > is( $renewokay, 0, 'Bug 14101: Cannot renew, renewal is automatic and premature' ); > is( $error, 'auto_too_soon', >-'Bug 14101: Cannot renew, renewal is automatic and premature, "No renewal before" = 0 (returned code is auto_too_soon)' >+ 'Bug 14101: Cannot renew, renewal is automatic and premature, "No renewal before" = 0 (returned code is auto_too_soon)' > ); > > # Change policy so that loans can be renewed 99 days prior to the due date >@@ -501,7 +519,7 @@ C4::Context->dbh->do("DELETE FROM accountlines"); > CanBookBeRenewed( $renewing_borrowernumber, $itemnumber4 ); > is( $renewokay, 0, 'Bug 14101: Cannot renew, renewal is automatic' ); > is( $error, 'auto_renew', >-'Bug 14101: Cannot renew, renewal is automatic (returned code is auto_renew)' >+ 'Bug 14101: Cannot renew, renewal is automatic (returned code is auto_renew)' > ); > > # Too many renewals >-- >1.7.10.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 14395
:
41027
|
41028
|
41029
|
41053
|
41054
|
41189
|
41197
|
42785
|
43810
|
43811
|
43812
|
44950
|
44951
|
44952
|
47777
|
47778
|
47779