Bugzilla – Attachment 19110 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), 3.99 KB, created by
Jonathan Druart
on 2013-06-18 09:58:56 UTC
(
hide
)
Description:
Bug 10487: UT: GetMaxPickupDate needs unit tests
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2013-06-18 09:58:56 UTC
Size:
3.99 KB
patch
obsolete
>From 25fb59d0ed36789c8cc88e621419e56d909398fa 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 >--- > t/db_dependent/Reserves.t | 43 ++++++++++++++++++++++++++++++++++++++++++- > 1 file changed, 42 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Reserves.t b/t/db_dependent/Reserves.t >index 385c191..c7703e4 100755 >--- a/t/db_dependent/Reserves.t >+++ b/t/db_dependent/Reserves.t >@@ -2,13 +2,16 @@ > > use Modern::Perl; > >-use Test::More tests => 4; >+use Test::More tests => 14; >+use Test::MockModule; > use MARC::Record; >+use DateTime::Duration; > > use C4::Branch; > use C4::Biblio; > use C4::Items; > use C4::Members; >+use Koha::DateUtils; > > BEGIN { > use_ok('C4::Reserves'); >@@ -73,6 +76,44 @@ is($status, "Reserved", "CheckReserves Test 2"); > is($status, "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.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 10487
:
19110
|
19183
|
20339