Bugzilla – Attachment 63874 Details for
Bug 18607
Fix date calculations for monthly frequencies in Serials
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 18607: Adjusting unit tests for monthly serial frequencies
Bug-18607-Adjusting-unit-tests-for-monthly-serial-.patch (text/plain), 5.55 KB, created by
Marcel de Rooy
on 2017-05-31 14:36:50 UTC
(
hide
)
Description:
Bug 18607: Adjusting unit tests for monthly serial frequencies
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2017-05-31 14:36:50 UTC
Size:
5.55 KB
patch
obsolete
>From f0077888c6a289fe83b789c72ee0f7b1bd67f105 Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Mon, 29 May 2017 12:08:40 +0200 >Subject: [PATCH] Bug 18607: Adjusting unit tests for monthly serial > frequencies >Content-Type: text/plain; charset=utf-8 > >The changes in the first patch require some corrections as well as >additional test cases. > >GetNextDate.t: Since the calculation for multiple issues per unit has >slightly changed, a few dates (day 15 or day 16) have been changed in the >unit test; when we use 2/month, the algorithm now always adds 15 days. >Added a few test descriptions in this regard too. > >GetFictiveIssueNumber.t: Add the monthly subtest with two test cases. In >the first case we tests multiple units per issue, and in the second case >we test multiple issues per unit (month). > >Test plan: >[1] Run t/db_dependent/Serials/GetFictiveIssueNumber.t >[2] Run t/db_dependent/Serials/GetNextDate.t > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > t/db_dependent/Serials/GetFictiveIssueNumber.t | 47 ++++++++++++++++++++++++-- > t/db_dependent/Serials/GetNextDate.t | 18 +++++----- > 2 files changed, 54 insertions(+), 11 deletions(-) > >diff --git a/t/db_dependent/Serials/GetFictiveIssueNumber.t b/t/db_dependent/Serials/GetFictiveIssueNumber.t >index 0c9c5a2..51cc151 100644 >--- a/t/db_dependent/Serials/GetFictiveIssueNumber.t >+++ b/t/db_dependent/Serials/GetFictiveIssueNumber.t >@@ -3,7 +3,7 @@ > # This test deals with GetFictiveIssueNumber (from C4::Serials) > > use Modern::Perl; >-use Test::More tests => 2; >+use Test::More tests => 3; > > use Koha::Database; > use C4::Serials; >@@ -97,7 +97,50 @@ subtest 'Tests for yearly frequencies' => sub { > > }; > >-# TODO: subtest 'Tests for monthly frequencies' => sub { >+subtest 'Tests for monthly frequencies' => sub { >+ plan tests => 8; >+ >+ # First add a few frequencies >+ my $freq_1i_5m = AddSubscriptionFrequency({ >+ description => "1 issue per 5 months", >+ unit => 'month', >+ issuesperunit => 1, >+ unitsperissue => 5, >+ }); >+ my $freq_4i_1m = AddSubscriptionFrequency({ >+ description => "4 issue per month", >+ unit => 'month', >+ issuesperunit => 4, >+ unitsperissue => 1, >+ }); >+ >+ # TEST CASE - 1 issue per 5 months >+ my $subscription = { >+ periodicity => $freq_1i_5m, >+ firstacquidate => '1972-02-10', >+ countissuesperunit => 1, >+ }; >+ is( C4::Serials::GetFictiveIssueNumber($subscription, '1972-07-09'), 1, 'Jul 9 still 1' ); >+ is( C4::Serials::GetFictiveIssueNumber($subscription, '1972-07-10'), 2, 'Jul 10 goes to 2' ); >+ is( C4::Serials::GetFictiveIssueNumber($subscription, '1973-05-09'), 3, 'May 9 still 3' ); >+ is( C4::Serials::GetFictiveIssueNumber($subscription, '1973-05-10'), 4, 'May 10 goes to 4' ); >+ >+ # TEST CASE - 4 issue per 1 months >+ $subscription = { >+ periodicity => $freq_4i_1m, >+ firstacquidate => '1972-02-22', >+ countissuesperunit => 1, >+ }; >+ is( C4::Serials::GetFictiveIssueNumber($subscription, '1972-02-28'), 1, 'Feb 28 still 1' ); >+ $subscription->{countissuesperunit} = 2; >+ is( C4::Serials::GetFictiveIssueNumber($subscription, '1972-02-29'), 2, 'Feb 29 goes to 2' ); >+ $subscription->{countissuesperunit} = 4; >+ is( C4::Serials::GetFictiveIssueNumber($subscription, '1972-03-21'), 4, 'Mar 21 still 4' ); >+ $subscription->{countissuesperunit} = 1; >+ is( C4::Serials::GetFictiveIssueNumber($subscription, '1972-03-22'), 5, 'Mar 22 goes to 5' ); >+ >+}; >+ > # TODO: subtest 'Tests for weekly frequencies' => sub { > # TODO: subtest 'Tests for dayly frequencies' => sub { > >diff --git a/t/db_dependent/Serials/GetNextDate.t b/t/db_dependent/Serials/GetNextDate.t >index 44dd529..7b29e88 100644 >--- a/t/db_dependent/Serials/GetNextDate.t >+++ b/t/db_dependent/Serials/GetNextDate.t >@@ -372,13 +372,13 @@ $subscription = { > }; > $publisheddate = $subscription->{firstacquidate}; > $publisheddate = GetNextDate($subscription, $publisheddate); >-is($publisheddate, '1970-01-16', 'January has 31 days'); >+is($publisheddate, '1970-01-16', 'Jan 16'); > $publisheddate = GetNextDate($subscription, $publisheddate); >-is($publisheddate, '1970-02-01'); >+is($publisheddate, '1970-02-01', 'Feb 1'); > $publisheddate = GetNextDate($subscription, $publisheddate); >-is($publisheddate, '1970-02-15', 'February has only 28 days'); >+is($publisheddate, '1970-02-16', 'Feb 16'); > $publisheddate = GetNextDate($subscription, $publisheddate); >-is($publisheddate, '1970-03-01'); >+is($publisheddate, '1970-03-01', 'Mar 1' ); > > # TEST CASE - 2 issues per month, irregularities > $subscription = { >@@ -389,15 +389,15 @@ $subscription = { > }; > $publisheddate = $subscription->{firstacquidate}; > $publisheddate = GetNextDate($subscription, $publisheddate); >-is($publisheddate, '1970-01-16', 'January has 31 days'); >+is($publisheddate, '1970-01-16', 'Jan 16' ); > $publisheddate = GetNextDate($subscription, $publisheddate); >-is($publisheddate, '1970-02-15', 'February has only 28 days'); >+is($publisheddate, '1970-02-16', 'Feb 16 (skipping Feb 1)' ); > $publisheddate = GetNextDate($subscription, $publisheddate); >-is($publisheddate, '1970-04-01'); >+is($publisheddate, '1970-04-01', 'Apr 1 (skipping Mar 1 and 16)' ); > $publisheddate = GetNextDate($subscription, $publisheddate); >-is($publisheddate, '1970-04-16', 'April has 30 days'); >+is($publisheddate, '1970-04-16', 'Apr 16' ); > $publisheddate = GetNextDate($subscription, $publisheddate); >-is($publisheddate, '1970-05-01'); >+is($publisheddate, '1970-05-01', 'May 1' ); > > # TEST CASE - 1 issue per year, no irregularity > $id = AddSubscriptionFrequency({ >-- >2.1.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 18607
:
63841
|
63842
|
63843
|
63844
|
63873
|
63874
|
64023
|
64024
|
64315
|
64316