Bugzilla – Attachment 19183 Details for
Bug 10487
UT: GetMaxPickupDate needs unit tests.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 10487: UT: GetMaxPickupDate needs unit tests
Bug-10487-UT-GetMaxPickupDate-needs-unit-tests.patch (text/plain), 4.05 KB, created by
Kyle M Hall (khall)
on 2013-06-21 12:56:50 UTC
(
hide
)
Description:
Bug 10487: UT: GetMaxPickupDate needs unit tests
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2013-06-21 12:56:50 UTC
Size:
4.05 KB
patch
obsolete
>From 1740f1408f5ca0fd3ac07a8191d341861dd51c08 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@biblibre.com> >Date: Tue, 18 Jun 2013 11:56:38 +0200 >Subject: [PATCH] Bug 10487: UT: GetMaxPickupDate needs unit tests > >GetMaxPickupDate is introduced by bug 8367. It needs unit tests. > >$ prove t/db_dependent/Reserves.t >should produce: > t/db_dependent/Reserves.t .. 1/14 # > # Creating biblio instance for testing. > # Creating item instance for testing. > ERROR: GetMaxPickupDate is called without reserve and without itemnumber > ERROR: GetMaxPickupDate is called without reserve and without itemnumber > t/db_dependent/Reserves.t .. 11/14 # Deleting item testing instance. > # Deleting biblio testing instance. > # Deleting borrower. > t/db_dependent/Reserves.t .. ok > All tests successful. > Files=1, Tests=14, 1 wallclock secs ( 0.03 usr 0.00 sys + 0.42 cusr > 0.06 csys = 0.51 CPU) > Result: PASS > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > t/db_dependent/Reserves.t | 47 +++++++++++++++++++++++++++++++++++++++++++- > 1 files changed, 45 insertions(+), 2 deletions(-) > >diff --git a/t/db_dependent/Reserves.t b/t/db_dependent/Reserves.t >index 1e20318..9aeed0b 100755 >--- a/t/db_dependent/Reserves.t >+++ b/t/db_dependent/Reserves.t >@@ -2,12 +2,17 @@ > > use strict; > use warnings; >-use C4::Branch; > >-use Test::More tests => 4; >+use Test::More tests => 14; >+use Test::MockModule; >+ > use MARC::Record; >+use DateTime::Duration; >+ > use C4::Biblio; > use C4::Items; >+use C4::Branch; >+use Koha::DateUtils; > > BEGIN { > use FindBin; >@@ -67,6 +72,44 @@ ok($status eq "Reserved", "CheckReserves Test 2"); > ok($status eq "Reserved", "CheckReserves Test 3"); > > >+# GetMaxPickupDate >+my $item = GetItem( $itemnumber ); >+is( C4::Reserves::GetMaxPickupDate(), undef, "GetMaxPickupDate return undef if no parameter is given" ); >+ >+# There is no issuingrule defined >+my $module = new Test::MockModule('C4::Circulation'); >+$module->mock( >+ 'GetIssuingRule', >+ sub { >+ return; >+ } >+); >+# GetMaxPickupDate returns the same values for the 3 next calls (only reserve, only item and reserve + item) >+is( C4::Reserves::GetMaxPickupDate($reserve), undef, "GetMaxPickupDate return undef if only reserve is given and waitingdate is not defined" ); >+is( C4::Reserves::GetMaxPickupDate(undef, $item), undef, "GetMaxPickupDate return undef if only item is given and waitingdate is not defined" ); >+is( C4::Reserves::GetMaxPickupDate($reserve, $item), undef, "GetMaxPickupDate return undef if reserve and item are given and waitingdate is not defined" ); >+ >+# Set a maxpickupdate value >+C4::Reserves::ModReserveAffect( $item->{itemnumber}, $borrowernumber ); >+$reserve = C4::Reserves::GetReserveInfo( $borrowernumber, $biblionumber ); >+is( C4::Reserves::GetMaxPickupDate($reserve), $reserve->{waitingdate} . 'T00:00:00', "GetMaxPickupDate return undef if only reserve is given and waitingdate is defined" ); >+is( C4::Reserves::GetMaxPickupDate(undef, $item), $reserve->{waitingdate} . 'T00:00:00', "GetMaxPickupDate return undef if only item is given and waitingdate is defined" ); >+is( C4::Reserves::GetMaxPickupDate($reserve, $item), $reserve->{waitingdate} . 'T00:00:00', "GetMaxPickupDate return undef if reserve and item are given and waitingdate is not defined" ); >+ >+my $delay = 5; >+$module->mock( >+ 'GetIssuingRule', >+ sub { >+ return {holdspickupdelay => $delay}; >+ } >+); >+ >+my $waitingdate_plus_5days = dt_from_string( $reserve->{waitingdate} )->add_duration(DateTime::Duration->new( days => $delay )); >+is( C4::Reserves::GetMaxPickupDate($reserve), $waitingdate_plus_5days, "GetMaxPickupDate return undef if only reserve is given and waitingdate is defined" ); >+is( C4::Reserves::GetMaxPickupDate(undef, $item), $waitingdate_plus_5days, "GetMaxPickupDate return undef if only item is given and waitingdate is defined" ); >+is( C4::Reserves::GetMaxPickupDate($reserve, $item), $waitingdate_plus_5days, "GetMaxPickupDate return undef if reserve and item are given and waitingdate is not defined" ); >+ >+ > # Teardown Test--------------------- > # Delete item. > diag("Deleting item testing instance."); >-- >1.7.2.5
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 10487
:
19110
|
19183
|
20339