Bugzilla – Attachment 63868 Details for
Bug 18697
Fix date calculations for day/week frequencies in Serials
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 18697: Adjusting unit tests for weekly serial frequencies
Bug-18697-Adjusting-unit-tests-for-weekly-serial-f.patch (text/plain), 4.46 KB, created by
Marcel de Rooy
on 2017-05-31 14:32:33 UTC
(
hide
)
Description:
Bug 18697: Adjusting unit tests for weekly serial frequencies
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2017-05-31 14:32:33 UTC
Size:
4.46 KB
patch
obsolete
>From 5c0ab439a53e75442130b44e0715e52f494d0ca4 Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Tue, 30 May 2017 15:56:22 +0200 >Subject: [PATCH] Bug 18697: Adjusting unit tests for weekly serial frequencies >Content-Type: text/plain; charset=utf-8 > >Corrections and added unit tests following the changes of the first patch. > >GetFictiveIssueNumber.t: New subtest for weekly frequencies. > >GetNextDate.t: Correcting a few dates one day. If we use 2/week, we will >calculate an interval of 3 days and correct with 4 days at the end of >the cycle. The connection with firstacqui is not relevant anymore. > >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 | 41 ++++++++++++++++++++++++-- > t/db_dependent/Serials/GetNextDate.t | 12 ++++---- > 2 files changed, 44 insertions(+), 9 deletions(-) > >diff --git a/t/db_dependent/Serials/GetFictiveIssueNumber.t b/t/db_dependent/Serials/GetFictiveIssueNumber.t >index 51cc151..4d72ce8 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 => 3; >+use Test::More tests => 4; > > use Koha::Database; > use C4::Serials; >@@ -141,7 +141,44 @@ subtest 'Tests for monthly frequencies' => sub { > > }; > >-# TODO: subtest 'Tests for weekly frequencies' => sub { >+subtest 'Tests for weekly frequencies' => sub { >+ plan tests => 4; >+ >+ # First add a few frequencies >+ my $freq_1i_7w = AddSubscriptionFrequency({ >+ description => "1 issue per 7 weeks", >+ unit => 'week', >+ issuesperunit => 1, >+ unitsperissue => 7, >+ }); >+ my $freq_3i_1w = AddSubscriptionFrequency({ >+ description => "3 issues per week", >+ unit => 'week', >+ issuesperunit => 3, >+ unitsperissue => 1, >+ }); >+ >+ # TEST CASE - 1 issue per 7 weeks >+ my $subscription = { >+ periodicity => $freq_1i_7w, >+ firstacquidate => '1972-02-10', >+ countissuesperunit => 1, >+ }; >+ is( C4::Serials::GetFictiveIssueNumber($subscription, '1972-03-29'), 1, 'Mar 29 still 1' ); >+ is( C4::Serials::GetFictiveIssueNumber($subscription, '1972-03-30'), 2, 'Mar 30 goes to 2' ); >+ >+ # TEST CASE - 3 issue per 1 week >+ $subscription = { >+ periodicity => $freq_3i_1w, >+ firstacquidate => '1972-02-03', >+ countissuesperunit => 1, >+ }; >+ $subscription->{countissuesperunit} = 3; >+ is( C4::Serials::GetFictiveIssueNumber($subscription, '1972-02-09'), 3, 'Feb 9 still 3' ); >+ $subscription->{countissuesperunit} = 1; >+ is( C4::Serials::GetFictiveIssueNumber($subscription, '1972-02-10'), 4, 'Feb 10 goes to 4' ); >+}; >+ > # TODO: subtest 'Tests for dayly frequencies' => sub { > > $schema->storage->txn_rollback; >diff --git a/t/db_dependent/Serials/GetNextDate.t b/t/db_dependent/Serials/GetNextDate.t >index 7b29e88..a0422d7 100644 >--- a/t/db_dependent/Serials/GetNextDate.t >+++ b/t/db_dependent/Serials/GetNextDate.t >@@ -212,13 +212,11 @@ $subscription = { > }; > $publisheddate = $subscription->{firstacquidate}; > $publisheddate = GetNextDate($subscription, $publisheddate); >-is($publisheddate, '1970-01-03'); >-# when more than 1 issue per week, date is automatically set to the same day of >-# week as firstacquidate >+is($publisheddate, '1970-01-04'); > $publisheddate = GetNextDate($subscription, $publisheddate); > is($publisheddate, '1970-01-08'); > $publisheddate = GetNextDate($subscription, $publisheddate); >-is($publisheddate, '1970-01-10'); >+is($publisheddate, '1970-01-11'); > $publisheddate = GetNextDate($subscription, $publisheddate); > is($publisheddate, '1970-01-15'); > >@@ -231,13 +229,13 @@ $subscription = { > }; > $publisheddate = $subscription->{firstacquidate}; > $publisheddate = GetNextDate($subscription, $publisheddate); >-is($publisheddate, '1970-01-03'); >+is($publisheddate, '1970-01-04'); > $publisheddate = GetNextDate($subscription, $publisheddate); >-is($publisheddate, '1970-01-10'); >+is($publisheddate, '1970-01-11'); > $publisheddate = GetNextDate($subscription, $publisheddate); > is($publisheddate, '1970-01-22'); > $publisheddate = GetNextDate($subscription, $publisheddate); >-is($publisheddate, '1970-01-24'); >+is($publisheddate, '1970-01-25'); > $publisheddate = GetNextDate($subscription, $publisheddate); > is($publisheddate, '1970-01-29'); > >-- >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 18697
:
63846
|
63847
|
63867
|
63868
|
63869
|
63870
|
63871
|
64025
|
64026
|
64027
|
64028
|
64029
|
64317
|
64318
|
64319
|
64320
|
64321