From 19f50f18dc4cc655a54ff2486bfc7256e6d57362 Mon Sep 17 00:00:00 2001 From: Bouzid Fergani Date: Fri, 16 Dec 2016 15:32:04 -0500 Subject: [PATCH] Bug 16116 - Add unit tests --- C4/Serials.pm | 3 +++ t/db_dependent/Serials.t | 32 +++++++++++++++++++++++++++++++- 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/C4/Serials.pm b/C4/Serials.pm index 26d0cf3..98fd55c 100644 --- a/C4/Serials.pm +++ b/C4/Serials.pm @@ -87,6 +87,9 @@ BEGIN { HasItems &GetSubscriptionsFromBorrower &subscriptionCurrentlyOnOrder + &_get_next_date_week + &_get_next_date_month + &_get_next_date_year ); } diff --git a/t/db_dependent/Serials.t b/t/db_dependent/Serials.t index e09a076..80b82a2 100755 --- a/t/db_dependent/Serials.t +++ b/t/db_dependent/Serials.t @@ -16,7 +16,7 @@ use C4::Biblio; use C4::Budgets; use Koha::DateUtils; use t::lib::Mocks; -use Test::More tests => 48; +use Test::More tests => 51; BEGIN { use_ok('C4::Serials'); @@ -316,4 +316,34 @@ subtest "Do not generate an expected if one already exists" => sub { is( @serialsByStatus, 1, "ModSerialStatus delete corectly serial expected and not create another if exists" ); }; +#Unit test Bug 16116 + +$frequency_id = AddSubscriptionFrequency({ description => "Test frequency 1",unit => 'week', unitsperissue => 1, issuesperunit => 1 }); +$subscriptionid = NewSubscription( + undef, "", undef, undef, $budget_id, $biblionumber, + '2013-01-01', $frequency_id, undef, undef, undef, + undef, undef, undef, undef, undef, undef, + 1, $notes,undef, '2013-01-01', undef, $pattern_id, + undef, undef, 0, $internalnotes, 0, + undef, undef, 0, undef, '2013-12-31', 0 + ); +#Week +my($year, $month, $day) = ('2016','1','11'); +$subscription = GetSubscription( $subscriptionid ); +my $frequencudata = GetSubscriptionFrequency($subscription->{'periodicity'}); +($year, $month, $day) = _get_next_date_week($subscription,$frequencudata, $year, $month, $day); +is ("$year-$month-$day","2016-1-18","_get_next_date_week return right next date "); + +#Month +ModSubscriptionFrequency({ id => $frequency_id, description => "Test frequency 1",unit => 'month', unitsperissue => 1, issuesperunit => 1 }); +($year, $month, $day) = ('2016','1','11'); +($year, $month, $day) = _get_next_date_month($subscription,$frequencudata, $year, $month, $day); +is ("$year-$month-$day","2016-2-11","_get_next_date_month return right next date"); + +#Year +ModSubscriptionFrequency({ id => $frequency_id, description => "Test frequency 1",unit => 'year', unitsperissue => 1, issuesperunit => 1 }); +($year, $month, $day) = ('2016','1','11'); +($year, $month, $day) = _get_next_date_year($subscription,$frequencudata, $year, $month, $day); +is ("$year-$month-$day","2017-1-11","_get_next_date_year return right next date"); + $dbh->rollback; -- 1.9.1