View | Details | Raw Unified | Return to bug 18607
Collapse All | Expand All

(-)a/t/db_dependent/Serials/GetFictiveIssueNumber.t (-2 / +45 lines)
Lines 3-9 Link Here
3
# This test deals with GetFictiveIssueNumber (from C4::Serials)
3
# This test deals with GetFictiveIssueNumber (from C4::Serials)
4
4
5
use Modern::Perl;
5
use Modern::Perl;
6
use Test::More tests => 2;
6
use Test::More tests => 3;
7
7
8
use Koha::Database;
8
use Koha::Database;
9
use C4::Serials;
9
use C4::Serials;
Lines 97-103 subtest 'Tests for yearly frequencies' => sub { Link Here
97
97
98
};
98
};
99
99
100
# TODO: subtest 'Tests for monthly frequencies' => sub {
100
subtest 'Tests for monthly frequencies' => sub {
101
    plan tests => 8;
102
103
    # First add a few frequencies
104
    my $freq_1i_5m = AddSubscriptionFrequency({
105
        description => "1 issue per 5 months",
106
        unit => 'month',
107
        issuesperunit => 1,
108
        unitsperissue => 5,
109
    });
110
    my $freq_4i_1m = AddSubscriptionFrequency({
111
        description => "4 issue per month",
112
        unit => 'month',
113
        issuesperunit => 4,
114
        unitsperissue => 1,
115
    });
116
117
    # TEST CASE - 1 issue per 5 months
118
    my $subscription = {
119
        periodicity => $freq_1i_5m,
120
        firstacquidate => '1972-02-10',
121
        countissuesperunit => 1,
122
    };
123
    is( C4::Serials::GetFictiveIssueNumber($subscription, '1972-07-09'), 1, 'Jul 9 still 1' );
124
    is( C4::Serials::GetFictiveIssueNumber($subscription, '1972-07-10'), 2, 'Jul 10 goes to 2' );
125
    is( C4::Serials::GetFictiveIssueNumber($subscription, '1973-05-09'), 3, 'May 9 still 3' );
126
    is( C4::Serials::GetFictiveIssueNumber($subscription, '1973-05-10'), 4, 'May 10 goes to 4' );
127
128
    # TEST CASE - 4 issue per 1 months
129
    $subscription = {
130
        periodicity => $freq_4i_1m,
131
        firstacquidate => '1972-02-22',
132
        countissuesperunit => 1,
133
    };
134
    is( C4::Serials::GetFictiveIssueNumber($subscription, '1972-02-28'), 1, 'Feb 28 still 1' );
135
    $subscription->{countissuesperunit} = 2;
136
    is( C4::Serials::GetFictiveIssueNumber($subscription, '1972-02-29'), 2, 'Feb 29 goes to 2' );
137
    $subscription->{countissuesperunit} = 4;
138
    is( C4::Serials::GetFictiveIssueNumber($subscription, '1972-03-21'), 4, 'Mar 21 still 4' );
139
    $subscription->{countissuesperunit} = 1;
140
    is( C4::Serials::GetFictiveIssueNumber($subscription, '1972-03-22'), 5, 'Mar 22 goes to 5' );
141
142
};
143
101
# TODO: subtest 'Tests for weekly frequencies' => sub {
144
# TODO: subtest 'Tests for weekly frequencies' => sub {
102
# TODO: subtest 'Tests for dayly frequencies' => sub {
145
# TODO: subtest 'Tests for dayly frequencies' => sub {
103
146
(-)a/t/db_dependent/Serials/GetNextDate.t (-10 / +9 lines)
Lines 372-384 $subscription = { Link Here
372
};
372
};
373
$publisheddate = $subscription->{firstacquidate};
373
$publisheddate = $subscription->{firstacquidate};
374
$publisheddate = GetNextDate($subscription, $publisheddate);
374
$publisheddate = GetNextDate($subscription, $publisheddate);
375
is($publisheddate, '1970-01-16', 'January has 31 days');
375
is($publisheddate, '1970-01-16', 'Jan 16');
376
$publisheddate = GetNextDate($subscription, $publisheddate);
376
$publisheddate = GetNextDate($subscription, $publisheddate);
377
is($publisheddate, '1970-02-01');
377
is($publisheddate, '1970-02-01', 'Feb 1');
378
$publisheddate = GetNextDate($subscription, $publisheddate);
378
$publisheddate = GetNextDate($subscription, $publisheddate);
379
is($publisheddate, '1970-02-15', 'February has only 28 days');
379
is($publisheddate, '1970-02-16', 'Feb 16');
380
$publisheddate = GetNextDate($subscription, $publisheddate);
380
$publisheddate = GetNextDate($subscription, $publisheddate);
381
is($publisheddate, '1970-03-01');
381
is($publisheddate, '1970-03-01', 'Mar 1' );
382
382
383
# TEST CASE - 2 issues per month, irregularities
383
# TEST CASE - 2 issues per month, irregularities
384
$subscription = {
384
$subscription = {
Lines 389-403 $subscription = { Link Here
389
};
389
};
390
$publisheddate = $subscription->{firstacquidate};
390
$publisheddate = $subscription->{firstacquidate};
391
$publisheddate = GetNextDate($subscription, $publisheddate);
391
$publisheddate = GetNextDate($subscription, $publisheddate);
392
is($publisheddate, '1970-01-16', 'January has 31 days');
392
is($publisheddate, '1970-01-16', 'Jan 16' );
393
$publisheddate = GetNextDate($subscription, $publisheddate);
393
$publisheddate = GetNextDate($subscription, $publisheddate);
394
is($publisheddate, '1970-02-15', 'February has only 28 days');
394
is($publisheddate, '1970-02-16', 'Feb 16 (skipping Feb 1)' );
395
$publisheddate = GetNextDate($subscription, $publisheddate);
395
$publisheddate = GetNextDate($subscription, $publisheddate);
396
is($publisheddate, '1970-04-01');
396
is($publisheddate, '1970-04-01', 'Apr 1 (skipping Mar 1 and 16)' );
397
$publisheddate = GetNextDate($subscription, $publisheddate);
397
$publisheddate = GetNextDate($subscription, $publisheddate);
398
is($publisheddate, '1970-04-16', 'April has 30 days');
398
is($publisheddate, '1970-04-16', 'Apr 16' );
399
$publisheddate = GetNextDate($subscription, $publisheddate);
399
$publisheddate = GetNextDate($subscription, $publisheddate);
400
is($publisheddate, '1970-05-01');
400
is($publisheddate, '1970-05-01', 'May 1' );
401
401
402
# TEST CASE - 1 issue per year, no irregularity
402
# TEST CASE - 1 issue per year, no irregularity
403
$id = AddSubscriptionFrequency({
403
$id = AddSubscriptionFrequency({
404
- 

Return to bug 18607