Bugzilla – Attachment 22799 Details for
Bug 11218
Due notices broken / not generated
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 11218: Regression tests for Due notice generation
Bug-11218-Regression-tests-for-Due-notice-generati.patch (text/plain), 6.14 KB, created by
Liz Rea
on 2013-11-08 01:12:50 UTC
(
hide
)
Description:
Bug 11218: Regression tests for Due notice generation
Filename:
MIME Type:
Creator:
Liz Rea
Created:
2013-11-08 01:12:50 UTC
Size:
6.14 KB
patch
obsolete
>From c571907fcfaa95dd67ce4bc895727c31e8de9c3d Mon Sep 17 00:00:00 2001 >From: Katrin Fischer <Katrin.Fischer.83@web.de> >Date: Fri, 8 Nov 2013 00:26:45 +0100 >Subject: [PATCH] Bug 11218: Regression tests for Due notice generation > >Changes tests for GetUpcomingDueIssues: > >days_in_advance should be inclusive: > 2 should find items due in 2 days from now. > 1 should find items due tomorrow. > 0 should only find items due today. > >Adds new tests for Bug 11218: > >As the advance_notices.pl, the only script using GetUpcomingDueIssues >is not only used for PREDUE notices, but also for >DUE notices, we need to also select items due today. > >Bug 11218: Due notices not being generated > >To test: >- Check out 2 items, due dates should be today, sometime in the past > and one day after tomorrow. >- Edit the message options - activate DUE and PREDUE notices with > days in advance = 2 >- Run the advance_notices.pl script with -v -c > Result: Only a PREDUE notice is generated >- Run the advance_notices.pl script with -v -c -m 2 > Result: Only the PREDUE message is generated correctly. >- Run t/db_dependent/Circulation.t > - without first patch: all tests pass. > - with first patch: some tests will fail. > >Apply patch. > >- Rerun script, now PREDUE and DUE notices should be > generated. >- Run t/db_dependent/Circulation.t again, all tests should pass. > >Add more items with different due dates, rerun and check results. > >Run t/Circulation.t to confirm all tests pass. >- Apply the patch > >Signed-off-by: Liz Rea <liz@catalyst.net.nz> >Passes functional and automated testing. Due notice functionality restored. >Thanks Katrin! >--- > C4/Circulation.pm | 2 +- > t/db_dependent/Circulation.t | 59 ++++++++++++++++++++++++++++++++++++++++---- > 2 files changed, 55 insertions(+), 6 deletions(-) > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index 34aa358..0a22b76 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -2433,7 +2433,7 @@ FROM issues > LEFT JOIN items USING (itemnumber) > LEFT OUTER JOIN branches USING (branchcode) > WHERE returndate is NULL >-HAVING days_until_due > 0 AND days_until_due < ? >+HAVING days_until_due >= 0 AND days_until_due <= ? > END_SQL > > my @bind_parameters = ( $params->{'days_in_advance'} ); >diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t >index 60b93e2..3b2f7d6 100755 >--- a/t/db_dependent/Circulation.t >+++ b/t/db_dependent/Circulation.t >@@ -9,7 +9,7 @@ use C4::Items; > use C4::Members; > use C4::Reserves; > >-use Test::More tests => 38; >+use Test::More tests => 44; > > BEGIN { > use_ok('C4::Circulation'); >@@ -336,8 +336,28 @@ C4::Context->dbh->do("DELETE FROM accountlines"); > # GetUpcomingDueIssues tests > my $barcode = 'R00000342'; > my $barcode2 = 'R00000343'; >+ my $barcode3 = 'R00000344'; > my $branch = 'MPL'; > >+ #Create another record >+ my $biblio2 = MARC::Record->new(); >+ my $title2 = 'Something is worng here'; >+ $biblio2->append_fields( >+ MARC::Field->new('100', ' ', ' ', a => 'Anonymous'), >+ MARC::Field->new('245', ' ', ' ', a => $title2), >+ ); >+ my ($biblionumber2, $biblioitemnumber2) = AddBiblio($biblio2, ''); >+ >+ #Create third item >+ AddItem( >+ { >+ homebranch => $branch, >+ holdingbranch => $branch, >+ barcode => $barcode3 >+ }, >+ $biblionumber2 >+ ); >+ > # Create a borrower > my %a_borrower_data = ( > firstname => 'Fridolyn', >@@ -351,23 +371,52 @@ C4::Context->dbh->do("DELETE FROM accountlines"); > > my $yesterday = DateTime->today(time_zone => C4::Context->tz())->add( days => -1 ); > my $two_days_ahead = DateTime->today(time_zone => C4::Context->tz())->add( days => 2 ); >+ my $today = DateTime->today(time_zone => C4::Context->tz()); > > my $datedue = AddIssue( $a_borrower, $barcode, $yesterday ); > my $datedue2 = AddIssue( $a_borrower, $barcode2, $two_days_ahead ); > >+ my $upcoming_dues; >+ > diag( "GetUpcomingDueIssues tests" ); > >- for my $i(0..2) { >- my $upcoming_dues = C4::Circulation::GetUpcomingDueIssues( { days_in_advance => $i } ); >- is ( scalar( @$upcoming_dues ), 0, "No items due in less than two days ($i days in advance)" ); >+ for my $i(0..1) { >+ $upcoming_dues = C4::Circulation::GetUpcomingDueIssues( { days_in_advance => $i } ); >+ is ( scalar( @$upcoming_dues ), 0, "No items due in less than one day ($i days in advance)" ); > } > >+ #days_in_advance needs to be inclusive, so 1 matches items due tomorrow, 0 items due today etc. >+ $upcoming_dues = C4::Circulation::GetUpcomingDueIssues( { days_in_advance => 2 } ); >+ is ( scalar ( @$upcoming_dues), 1, "Only one item due in 2 days or less" ); >+ > for my $i(3..5) { >- my $upcoming_dues = C4::Circulation::GetUpcomingDueIssues( { days_in_advance => $i } ); >+ $upcoming_dues = C4::Circulation::GetUpcomingDueIssues( { days_in_advance => $i } ); > is ( scalar( @$upcoming_dues ), 1, > "Bug 9362: Only one item due in more than 2 days ($i days in advance)" ); > } > >+ # Bug 11218 - Due notices not generated - GetUpcomingDueIssues needs to select due today items as well >+ >+ my $datedue2 = AddIssue( $a_borrower, $barcode3, $today ); >+ >+ $upcoming_dues = C4::Circulation::GetUpcomingDueIssues( { days_in_advance => -1 } ); >+ is ( scalar ( @$upcoming_dues), 0, "Overdues can not be selected" ); >+ >+ $upcoming_dues = C4::Circulation::GetUpcomingDueIssues( { days_in_advance => 0 } ); >+ is ( scalar ( @$upcoming_dues), 1, "1 item is due today" ); >+ >+ $upcoming_dues = C4::Circulation::GetUpcomingDueIssues( { days_in_advance => 1 } ); >+ is ( scalar ( @$upcoming_dues), 1, "1 item is due today, none tomorrow" ); >+ >+ $upcoming_dues = C4::Circulation::GetUpcomingDueIssues( { days_in_advance => 2 } ); >+ is ( scalar ( @$upcoming_dues), 2, "2 items are due withing 2 days" ); >+ >+ $upcoming_dues = C4::Circulation::GetUpcomingDueIssues( { days_in_advance => 3 } ); >+ is ( scalar ( @$upcoming_dues), 2, "2 items are due withing 2 days" ); >+ >+ $upcoming_dues = C4::Circulation::GetUpcomingDueIssues(); >+ is ( scalar ( @$upcoming_dues), 2, "days_in_advance is 7 in GetUpcomingDueIssues if not provided" ); >+ > } > > $dbh->rollback; >-- >1.8.1.2
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 11218
:
22795
|
22796
|
22799
|
22802
|
22803
|
22804
|
22823
|
22824
|
22825
|
27531