Bugzilla – Attachment 20339 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.50 KB, created by
Jonathan Druart
on 2013-08-14 14:59:25 UTC
(
hide
)
Description:
Bug 10487: UT: GetMaxPickupDate needs unit tests
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2013-08-14 14:59:25 UTC
Size:
4.50 KB
patch
obsolete
>From 1da877a586d319fd35ea8df3fc23d54bb5deb651 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 | 57 ++++++++++++++++++++++++++++++++++++++++++++- > 1 file changed, 56 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Reserves.t b/t/db_dependent/Reserves.t >index 0e0852a..885f8af 100755 >--- a/t/db_dependent/Reserves.t >+++ b/t/db_dependent/Reserves.t >@@ -2,14 +2,19 @@ > > 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'); > } >@@ -76,3 +81,53 @@ is($status, "Reserved", "CheckReserves Test 2"); > > ($status, $reserve, $all_reserves) = CheckReserves(undef, $barcode); > is($status, "Reserved", "CheckReserves Test 3"); >+ >+ >+# GetMaxPickupDate >+my $item = GetItem( $itemnumber ); >+is( C4::Reserves::GetMaxPickupDate(), undef, "GetMaxPickupDate returns 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 returns undef if only reserve is given and waitingdate is not defined" ); >+is( C4::Reserves::GetMaxPickupDate(undef, $item), undef, "GetMaxPickupDate returns undef if only item is given and waitingdate is not defined" ); >+is( C4::Reserves::GetMaxPickupDate($reserve, $item), undef, "GetMaxPickupDate returns undef if reserve and item are given and waitingdate is not defined" ); >+ >+# Set a maxpickupdate value >+C4::Reserves::ModReserveAffect( $item->{itemnumber}, $borrowernumber ); >+my $reserve_id = C4::Reserves::GetReserveId( { borrowernumber => $borrowernumber, biblionumber => $biblionumber } ); >+$reserve = C4::Reserves::GetReserveInfo( $reserve_id ); >+is( C4::Reserves::GetMaxPickupDate($reserve), $reserve->{waitingdate} . 'T00:00:00', "GetMaxPickupDate returns undef if only reserve is given and waitingdate is defined" ); >+is( C4::Reserves::GetMaxPickupDate(undef, $item), $reserve->{waitingdate} . 'T00:00:00', "GetMaxPickupDate returns undef if only item is given and waitingdate is defined" ); >+is( C4::Reserves::GetMaxPickupDate($reserve, $item), $reserve->{waitingdate} . 'T00:00:00', "GetMaxPickupDate returns 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 returns undef if only reserve is given and waitingdate is defined" ); >+is( C4::Reserves::GetMaxPickupDate(undef, $item), $waitingdate_plus_5days, "GetMaxPickupDate returns undef if only item is given and waitingdate is defined" ); >+is( C4::Reserves::GetMaxPickupDate($reserve, $item), $waitingdate_plus_5days, "GetMaxPickupDate returns undef if reserve and item are given and waitingdate is not defined" ); >+ >+# Helper method to set up a Biblio. >+sub create_helper_biblio { >+ my $bib = MARC::Record->new(); >+ my $title = 'Silence in the library'; >+ $bib->append_fields( >+ MARC::Field->new('100', ' ', ' ', a => 'Moffat, Steven'), >+ MARC::Field->new('245', ' ', ' ', a => $title), >+ ); >+ return ($bibnum, $title, $bibitemnum) = AddBiblio($bib, ''); >+} >-- >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