From 0b2e9dbf620afeca2ec4a82b583c6787d8f1208b Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Wed, 23 Apr 2014 07:38:11 -0400 Subject: [PATCH] Bug 10694: (follow-up) add unit tests, improve AddReturn POD Signed-off-by: Martin Renvoize Signed-off-by: Galen Charlton --- C4/Circulation.pm | 8 ++++---- t/db_dependent/Circulation_issue.t | 12 +++++++++++- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 3fafdbafe7..91ed2dbecd 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -1634,7 +1634,7 @@ sub GetBranchItemRule { =head2 AddReturn ($doreturn, $messages, $iteminformation, $borrower) = - &AddReturn($barcode, $branch, $exemptfine, $dropbox, $returndate); + &AddReturn( $barcode, $branch [,$exemptfine] [,$dropbox] [,$returndate] ); Returns a book. @@ -1645,16 +1645,16 @@ Returns a book. =item C<$branch> is the code of the branch where the book is being returned. =item C<$exemptfine> indicates that overdue charges for the item will be -removed. +removed. Optional. =item C<$dropbox> indicates that the check-in date is assumed to be yesterday, or the last non-holiday as defined in C4::Calendar . If overdue charges are applied and C<$dropbox> is true, the last charge will be removed. This assumes that the fines accrual script has run -for _today_. +for _today_. Optional. =item C<$return_date> allows the default return date to be overridden -by the given return date. +by the given return date. Optional. =back diff --git a/t/db_dependent/Circulation_issue.t b/t/db_dependent/Circulation_issue.t index 18ef405601..ea701318a6 100644 --- a/t/db_dependent/Circulation_issue.t +++ b/t/db_dependent/Circulation_issue.t @@ -10,7 +10,7 @@ use C4::Circulation; use C4::Items; use C4::Context; -use Test::More tests => 25; +use Test::More tests => 27; BEGIN { use_ok('C4::Circulation'); @@ -331,6 +331,16 @@ is_deeply( "With issuing rules (renewal allowed, 1 remaining) and with a valid parameter, Getrenewcount of item1 returns 0 renews left" ); +$dbh->do("TRUNCATE TABLE old_issues"); +AddReturn('barcode_1'); +my $return = $dbh->selectrow_hashref("SELECT DATE(returndate) AS return_date, CURRENT_DATE() AS today FROM old_issues LIMIT 1" ); +ok( $return->{return_date} eq $return->{today}, "Item returned with no return date specified has todays date" ); + +$dbh->do("TRUNCATE TABLE old_issues"); +C4::Circulation::AddIssue( $borrower_1, 'barcode_1', $daysago10, 0, $today ); +AddReturn('barcode_1', undef, undef, undef, '2014-04-01 23:42'); +$return = $dbh->selectrow_hashref("SELECT * FROM old_issues LIMIT 1" ); +ok( $return->{returndate} eq '2014-04-01 23:42:00', "Item returned with a return date of '2014-04-01 23:42' has that return date" ); #End transaction $dbh->rollback; -- 2.39.5