From 8aef48d5f34361c42b9f8e0cec8e811d9ca98036 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Tue, 13 Aug 2013 10:44:07 -0300 Subject: [PATCH] Bug 10719 - UT GetUpcomingDueIssues Some unit tests related to Bug 9362. Sponsored-by: Universidad Nacional de Cordoba Signed-off-by: Jonathan Druart http://bugs.koha-community.org/show_bug.cgi?id=10606 Signed-off-by: Katrin Fischer New and old tests pass. Signed-off-by: Galen Charlton --- t/db_dependent/Circulation.t | 40 +++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t index bf27fb5fc8..483ce847ac 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 => 30; +use Test::More tests => 36; BEGIN { use_ok('C4::Circulation'); @@ -283,4 +283,42 @@ C4::Context->dbh->do("DELETE FROM borrowers WHERE cardnumber = '99999999999'"); } +{ + # GetUpcomingDueIssues tests + my $barcode = 'R00000342'; + my $barcode2 = 'R00000343'; + my $branch = 'MPL'; + + # Create a borrower + my %a_borrower_data = ( + firstname => 'Fridolyn', + surname => 'SOMERS', + categorycode => 'S', + branchcode => $branch, + ); + + my $a_borrower_borrowernumber = AddMember(%a_borrower_data); + my $a_borrower = GetMember( borrowernumber => $a_borrower_borrowernumber ); + + 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 $datedue = AddIssue( $a_borrower, $barcode, $yesterday ); + my $datedue2 = AddIssue( $a_borrower, $barcode2, $two_days_ahead ); + + 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(3..5) { + my $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)" ); + } + +} + $dbh->rollback; -- 2.39.5