@@ -, +, @@ --- C4/Serials.pm | 3 +++ t/db_dependent/Serials.t | 32 +++++++++++++++++++++++++++++++- 2 files changed, 34 insertions(+), 1 deletion(-) --- a/C4/Serials.pm +++ a/C4/Serials.pm @@ -87,6 +87,9 @@ BEGIN { HasItems &GetSubscriptionsFromBorrower &subscriptionCurrentlyOnOrder + &_get_next_date_week + &_get_next_date_month + &_get_next_date_year ); } --- a/t/db_dependent/Serials.t +++ a/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; --