Lines 19-570
my $frequency = {
Link Here
|
19 |
issuesperunit => 1, |
19 |
issuesperunit => 1, |
20 |
unitsperissue => 1, |
20 |
unitsperissue => 1, |
21 |
}; |
21 |
}; |
22 |
my $id = AddSubscriptionFrequency($frequency); |
|
|
23 |
|
22 |
|
24 |
my $subscription = { |
23 |
my $subscription = { |
25 |
periodicity => $id, |
|
|
26 |
firstacquidate => '1970-01-01', |
24 |
firstacquidate => '1970-01-01', |
27 |
irregularity => '', |
25 |
irregularity => '', |
28 |
countissuesperunit => 1, |
26 |
countissuesperunit => 1, |
29 |
}; |
27 |
}; |
30 |
my $publisheddate = $subscription->{firstacquidate}; |
28 |
my $publisheddate = $subscription->{firstacquidate}; |
31 |
|
29 |
|
32 |
$publisheddate = GetNextDate($subscription, $publisheddate); |
30 |
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); |
33 |
is($publisheddate, '1970-01-02'); |
31 |
is($publisheddate, '1970-01-02'); |
34 |
$publisheddate = GetNextDate($subscription, $publisheddate); |
32 |
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); |
35 |
is($publisheddate, '1970-01-03'); |
33 |
is($publisheddate, '1970-01-03'); |
36 |
$publisheddate = GetNextDate($subscription, $publisheddate); |
34 |
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); |
37 |
is($publisheddate, '1970-01-04'); |
35 |
is($publisheddate, '1970-01-04'); |
38 |
|
36 |
|
39 |
# TEST CASE - 1 issue per day, irregularities |
37 |
# TEST CASE - 1 issue per day, irregularities |
40 |
$subscription = { |
38 |
$subscription = { |
41 |
periodicity => $id, |
|
|
42 |
firstacquidate => '1970-01-01', |
39 |
firstacquidate => '1970-01-01', |
43 |
irregularity => '2;4', # Skip the second and fourth issues |
40 |
irregularity => '2;4', # Skip the second and fourth issues |
44 |
countissuesperunit => 1, |
41 |
countissuesperunit => 1, |
45 |
}; |
42 |
}; |
46 |
$publisheddate = $subscription->{firstacquidate}; |
43 |
$publisheddate = $subscription->{firstacquidate}; |
47 |
$publisheddate = GetNextDate($subscription, $publisheddate); |
44 |
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); |
48 |
is($publisheddate, '1970-01-03'); |
45 |
is($publisheddate, '1970-01-03'); |
49 |
$publisheddate = GetNextDate($subscription, $publisheddate); |
46 |
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); |
50 |
is($publisheddate, '1970-01-05'); |
47 |
is($publisheddate, '1970-01-05'); |
51 |
$publisheddate = GetNextDate($subscription, $publisheddate); |
48 |
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); |
52 |
is($publisheddate, '1970-01-06'); |
49 |
is($publisheddate, '1970-01-06'); |
53 |
|
50 |
|
54 |
# TEST CASE - 2 issues per day, no irregularity |
51 |
# TEST CASE - 2 issues per day, no irregularity |
55 |
$id = AddSubscriptionFrequency({ |
52 |
$frequency = { |
56 |
description => "Two issues per day", |
53 |
description => "Two issues per day", |
57 |
unit => 'day', |
54 |
unit => 'day', |
58 |
issuesperunit => 2, |
55 |
issuesperunit => 2, |
59 |
unitsperissue => 1, |
56 |
unitsperissue => 1, |
60 |
}); |
57 |
}; |
61 |
$subscription = { |
58 |
$subscription = { |
62 |
periodicity => $id, |
|
|
63 |
firstacquidate => '1970-01-01', |
59 |
firstacquidate => '1970-01-01', |
64 |
irregularity => '', |
60 |
irregularity => '', |
65 |
countissuesperunit => 1, |
61 |
countissuesperunit => 1, |
66 |
}; |
62 |
}; |
67 |
$publisheddate = $subscription->{firstacquidate}; |
63 |
$publisheddate = $subscription->{firstacquidate}; |
68 |
$publisheddate = GetNextDate($subscription, $publisheddate); |
64 |
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); |
69 |
is($publisheddate, '1970-01-01'); |
65 |
is($publisheddate, '1970-01-01'); |
70 |
$publisheddate = GetNextDate($subscription, $publisheddate); |
66 |
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); |
71 |
is($publisheddate, '1970-01-02'); |
67 |
is($publisheddate, '1970-01-02'); |
72 |
$publisheddate = GetNextDate($subscription, $publisheddate); |
68 |
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); |
73 |
is($publisheddate, '1970-01-02'); |
69 |
is($publisheddate, '1970-01-02'); |
74 |
$publisheddate = GetNextDate($subscription, $publisheddate); |
70 |
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); |
75 |
is($publisheddate, '1970-01-03'); |
71 |
is($publisheddate, '1970-01-03'); |
76 |
|
72 |
|
77 |
# TEST CASE - 2 issues per day, irregularities |
73 |
# TEST CASE - 2 issues per day, irregularities |
78 |
$subscription = { |
74 |
$subscription = { |
79 |
periodicity => $id, |
|
|
80 |
firstacquidate => '1970-01-01', |
75 |
firstacquidate => '1970-01-01', |
81 |
irregularity => '3;5;6', |
76 |
irregularity => '3;5;6', |
82 |
countissuesperunit => 1, |
77 |
countissuesperunit => 1, |
83 |
}; |
78 |
}; |
84 |
$publisheddate = $subscription->{firstacquidate}; |
79 |
$publisheddate = $subscription->{firstacquidate}; |
85 |
$publisheddate = GetNextDate($subscription, $publisheddate); |
80 |
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); |
86 |
is($publisheddate, '1970-01-01'); |
81 |
is($publisheddate, '1970-01-01'); |
87 |
$publisheddate = GetNextDate($subscription, $publisheddate); |
82 |
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); |
88 |
is($publisheddate, '1970-01-02'); |
83 |
is($publisheddate, '1970-01-02'); |
89 |
$publisheddate = GetNextDate($subscription, $publisheddate); |
84 |
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); |
90 |
is($publisheddate, '1970-01-04'); |
85 |
is($publisheddate, '1970-01-04'); |
91 |
$publisheddate = GetNextDate($subscription, $publisheddate); |
86 |
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); |
92 |
is($publisheddate, '1970-01-04'); |
87 |
is($publisheddate, '1970-01-04'); |
93 |
$publisheddate = GetNextDate($subscription, $publisheddate); |
88 |
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); |
94 |
is($publisheddate, '1970-01-05'); |
89 |
is($publisheddate, '1970-01-05'); |
95 |
|
90 |
|
96 |
# TEST CASE - 1 issue every 2 days, no irregularity |
91 |
# TEST CASE - 1 issue every 2 days, no irregularity |
97 |
$id = AddSubscriptionFrequency({ |
92 |
$frequency = { |
98 |
description => "one issue every two days", |
93 |
description => "one issue every two days", |
99 |
unit => 'day', |
94 |
unit => 'day', |
100 |
issuesperunit => 1, |
95 |
issuesperunit => 1, |
101 |
unitsperissue => 2, |
96 |
unitsperissue => 2, |
102 |
}); |
97 |
}; |
103 |
$subscription = { |
98 |
$subscription = { |
104 |
periodicity => $id, |
|
|
105 |
firstacquidate => '1970-01-01', |
99 |
firstacquidate => '1970-01-01', |
106 |
irregularity => '', |
100 |
irregularity => '', |
107 |
countissuesperunit => 1, |
101 |
countissuesperunit => 1, |
108 |
}; |
102 |
}; |
109 |
$publisheddate = $subscription->{firstacquidate}; |
103 |
$publisheddate = $subscription->{firstacquidate}; |
110 |
$publisheddate = GetNextDate($subscription, $publisheddate); |
104 |
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); |
111 |
is($publisheddate, '1970-01-03'); |
105 |
is($publisheddate, '1970-01-03'); |
112 |
$publisheddate = GetNextDate($subscription, $publisheddate); |
106 |
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); |
113 |
is($publisheddate, '1970-01-05'); |
107 |
is($publisheddate, '1970-01-05'); |
114 |
|
108 |
|
115 |
# TEST CASE - 1 issue every 2 days, irregularities |
109 |
# TEST CASE - 1 issue every 2 days, irregularities |
116 |
$subscription = { |
110 |
$subscription = { |
117 |
periodicity => $id, |
|
|
118 |
firstacquidate => '1970-01-01', |
111 |
firstacquidate => '1970-01-01', |
119 |
irregularity => '3', |
112 |
irregularity => '3', |
120 |
countissuesperunit => 1, |
113 |
countissuesperunit => 1, |
121 |
}; |
114 |
}; |
122 |
$publisheddate = $subscription->{firstacquidate}; |
115 |
$publisheddate = $subscription->{firstacquidate}; |
123 |
$publisheddate = GetNextDate($subscription, $publisheddate); |
116 |
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); |
124 |
is($publisheddate, '1970-01-03'); |
117 |
is($publisheddate, '1970-01-03'); |
125 |
$publisheddate = GetNextDate($subscription, $publisheddate); |
118 |
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); |
126 |
is($publisheddate, '1970-01-07'); |
119 |
is($publisheddate, '1970-01-07'); |
127 |
$publisheddate = GetNextDate($subscription, $publisheddate); |
120 |
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); |
128 |
is($publisheddate, '1970-01-09'); |
121 |
is($publisheddate, '1970-01-09'); |
129 |
|
122 |
|
130 |
# TEST CASE - 1 issue per week, no irregularity |
123 |
# TEST CASE - 1 issue per week, no irregularity |
131 |
$id = AddSubscriptionFrequency({ |
124 |
$frequency = { |
132 |
description => "one issue per week", |
125 |
description => "one issue per week", |
133 |
unit => 'week', |
126 |
unit => 'week', |
134 |
issuesperunit => 1, |
127 |
issuesperunit => 1, |
135 |
unitsperissue => 1, |
128 |
unitsperissue => 1, |
136 |
}); |
129 |
}; |
137 |
$subscription = { |
130 |
$subscription = { |
138 |
periodicity => $id, |
|
|
139 |
firstacquidate => '1970-01-01', |
131 |
firstacquidate => '1970-01-01', |
140 |
irregularity => '', |
132 |
irregularity => '', |
141 |
countissuesperunit => 1, |
133 |
countissuesperunit => 1, |
142 |
}; |
134 |
}; |
143 |
$publisheddate = $subscription->{firstacquidate}; |
135 |
$publisheddate = $subscription->{firstacquidate}; |
144 |
$publisheddate = GetNextDate($subscription, $publisheddate); |
136 |
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); |
145 |
is($publisheddate, '1970-01-08'); |
137 |
is($publisheddate, '1970-01-08'); |
146 |
$publisheddate = GetNextDate($subscription, $publisheddate); |
138 |
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); |
147 |
is($publisheddate, '1970-01-15'); |
139 |
is($publisheddate, '1970-01-15'); |
148 |
|
140 |
|
149 |
# TEST CASE - 1 issue per week, irregularities |
141 |
# TEST CASE - 1 issue per week, irregularities |
150 |
$subscription = { |
142 |
$subscription = { |
151 |
periodicity => $id, |
|
|
152 |
firstacquidate => '1970-01-01', |
143 |
firstacquidate => '1970-01-01', |
153 |
irregularity => '3', |
144 |
irregularity => '3', |
154 |
countissuesperunit => 1, |
145 |
countissuesperunit => 1, |
155 |
}; |
146 |
}; |
156 |
$publisheddate = $subscription->{firstacquidate}; |
147 |
$publisheddate = $subscription->{firstacquidate}; |
157 |
$publisheddate = GetNextDate($subscription, $publisheddate); |
148 |
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); |
158 |
is($publisheddate, '1970-01-08'); |
149 |
is($publisheddate, '1970-01-08'); |
159 |
$publisheddate = GetNextDate($subscription, $publisheddate); |
150 |
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); |
160 |
is($publisheddate, '1970-01-22'); |
151 |
is($publisheddate, '1970-01-22'); |
161 |
$publisheddate = GetNextDate($subscription, $publisheddate); |
152 |
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); |
162 |
is($publisheddate, '1970-01-29'); |
153 |
is($publisheddate, '1970-01-29'); |
163 |
|
154 |
|
164 |
# TEST CASE - 1 issue every 2 weeks, no irregularity |
155 |
# TEST CASE - 1 issue every 2 weeks, no irregularity |
165 |
$id = AddSubscriptionFrequency({ |
156 |
$frequency = { |
166 |
description => "one issue every 2 weeks", |
157 |
description => "one issue every 2 weeks", |
167 |
unit => 'week', |
158 |
unit => 'week', |
168 |
issuesperunit => 1, |
159 |
issuesperunit => 1, |
169 |
unitsperissue => 2, |
160 |
unitsperissue => 2, |
170 |
}); |
161 |
}; |
171 |
$subscription = { |
162 |
$subscription = { |
172 |
periodicity => $id, |
|
|
173 |
firstacquidate => '1970-01-01', |
163 |
firstacquidate => '1970-01-01', |
174 |
irregularity => '', |
164 |
irregularity => '', |
175 |
countissuesperunit => 1, |
165 |
countissuesperunit => 1, |
176 |
}; |
166 |
}; |
177 |
$publisheddate = $subscription->{firstacquidate}; |
167 |
$publisheddate = $subscription->{firstacquidate}; |
178 |
$publisheddate = GetNextDate($subscription, $publisheddate); |
168 |
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); |
179 |
is($publisheddate, '1970-01-15'); |
169 |
is($publisheddate, '1970-01-15'); |
180 |
$publisheddate = GetNextDate($subscription, $publisheddate); |
170 |
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); |
181 |
is($publisheddate, '1970-01-29'); |
171 |
is($publisheddate, '1970-01-29'); |
182 |
$publisheddate = GetNextDate($subscription, $publisheddate); |
172 |
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); |
183 |
is($publisheddate, '1970-02-12'); |
173 |
is($publisheddate, '1970-02-12'); |
184 |
|
174 |
|
185 |
# TEST CASE - 1 issue every 2 weeks, irregularities |
175 |
# TEST CASE - 1 issue every 2 weeks, irregularities |
186 |
$subscription = { |
176 |
$subscription = { |
187 |
periodicity => $id, |
|
|
188 |
firstacquidate => '1970-01-01', |
177 |
firstacquidate => '1970-01-01', |
189 |
irregularity => '3', |
178 |
irregularity => '3', |
190 |
countissuesperunit => 1, |
179 |
countissuesperunit => 1, |
191 |
}; |
180 |
}; |
192 |
$publisheddate = $subscription->{firstacquidate}; |
181 |
$publisheddate = $subscription->{firstacquidate}; |
193 |
$publisheddate = GetNextDate($subscription, $publisheddate); |
182 |
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); |
194 |
is($publisheddate, '1970-01-15'); |
183 |
is($publisheddate, '1970-01-15'); |
195 |
$publisheddate = GetNextDate($subscription, $publisheddate); |
184 |
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); |
196 |
is($publisheddate, '1970-02-12'); |
185 |
is($publisheddate, '1970-02-12'); |
197 |
$publisheddate = GetNextDate($subscription, $publisheddate); |
186 |
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); |
198 |
is($publisheddate, '1970-02-26'); |
187 |
is($publisheddate, '1970-02-26'); |
199 |
|
188 |
|
200 |
# TEST CASE - 2 issues per week, no irregularity |
189 |
# TEST CASE - 2 issues per week, no irregularity |
201 |
$id = AddSubscriptionFrequency({ |
190 |
$frequency = { |
202 |
description => "two issues per week", |
191 |
description => "two issues per week", |
203 |
unit => 'week', |
192 |
unit => 'week', |
204 |
issuesperunit => 2, |
193 |
issuesperunit => 2, |
205 |
unitsperissue => 1, |
194 |
unitsperissue => 1, |
206 |
}); |
195 |
}; |
207 |
$subscription = { |
196 |
$subscription = { |
208 |
periodicity => $id, |
|
|
209 |
firstacquidate => '1970-01-01', |
197 |
firstacquidate => '1970-01-01', |
210 |
irregularity => '', |
198 |
irregularity => '', |
211 |
countissuesperunit => 1, |
199 |
countissuesperunit => 1, |
212 |
}; |
200 |
}; |
213 |
$publisheddate = $subscription->{firstacquidate}; |
201 |
$publisheddate = $subscription->{firstacquidate}; |
214 |
$publisheddate = GetNextDate($subscription, $publisheddate); |
202 |
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); |
215 |
is($publisheddate, '1970-01-04'); |
203 |
is($publisheddate, '1970-01-04'); |
216 |
$publisheddate = GetNextDate($subscription, $publisheddate); |
204 |
# when more than 1 issue per week, date is automatically set to the same day of |
|
|
205 |
# week as firstacquidate |
206 |
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); |
217 |
is($publisheddate, '1970-01-08'); |
207 |
is($publisheddate, '1970-01-08'); |
218 |
$publisheddate = GetNextDate($subscription, $publisheddate); |
208 |
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); |
219 |
is($publisheddate, '1970-01-11'); |
209 |
is($publisheddate, '1970-01-11'); |
220 |
$publisheddate = GetNextDate($subscription, $publisheddate); |
210 |
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); |
221 |
is($publisheddate, '1970-01-15'); |
211 |
is($publisheddate, '1970-01-15'); |
222 |
|
212 |
|
223 |
# TEST CASE - 2 issues per week, irregularities |
213 |
# TEST CASE - 2 issues per week, irregularities |
224 |
$subscription = { |
214 |
$subscription = { |
225 |
periodicity => $id, |
|
|
226 |
firstacquidate => '1970-01-01', |
215 |
firstacquidate => '1970-01-01', |
227 |
irregularity => '3;5;6', |
216 |
irregularity => '3;5;6', |
228 |
countissuesperunit => 1, |
217 |
countissuesperunit => 1, |
229 |
}; |
218 |
}; |
230 |
$publisheddate = $subscription->{firstacquidate}; |
219 |
$publisheddate = $subscription->{firstacquidate}; |
231 |
$publisheddate = GetNextDate($subscription, $publisheddate); |
220 |
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); |
232 |
is($publisheddate, '1970-01-04'); |
221 |
is($publisheddate, '1970-01-04'); |
233 |
$publisheddate = GetNextDate($subscription, $publisheddate); |
222 |
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); |
234 |
is($publisheddate, '1970-01-11'); |
223 |
is($publisheddate, '1970-01-11'); |
235 |
$publisheddate = GetNextDate($subscription, $publisheddate); |
224 |
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); |
236 |
is($publisheddate, '1970-01-22'); |
225 |
is($publisheddate, '1970-01-22'); |
237 |
$publisheddate = GetNextDate($subscription, $publisheddate); |
226 |
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); |
238 |
is($publisheddate, '1970-01-25'); |
227 |
is($publisheddate, '1970-01-25'); |
239 |
$publisheddate = GetNextDate($subscription, $publisheddate); |
228 |
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); |
240 |
is($publisheddate, '1970-01-29'); |
229 |
is($publisheddate, '1970-01-29'); |
241 |
|
230 |
|
242 |
# TEST CASE - 6 issues per week, no irregularity |
231 |
# TEST CASE - 6 issues per week, no irregularity |
243 |
$id = AddSubscriptionFrequency({ |
232 |
$frequency = { |
244 |
description => "six issues per week", |
233 |
description => "six issues per week", |
245 |
unit => 'week', |
234 |
unit => 'week', |
246 |
issuesperunit => 6, |
235 |
issuesperunit => 6, |
247 |
unitsperissue => 1, |
236 |
unitsperissue => 1, |
248 |
}); |
237 |
}; |
249 |
$subscription = { |
238 |
$subscription = { |
250 |
periodicity => $id, |
|
|
251 |
firstacquidate => '1970-01-06', |
239 |
firstacquidate => '1970-01-06', |
252 |
irregularity => '', |
240 |
irregularity => '', |
253 |
countissuesperunit => 1, |
241 |
countissuesperunit => 1, |
254 |
}; |
242 |
}; |
255 |
$publisheddate = $subscription->{firstacquidate}; |
243 |
$publisheddate = $subscription->{firstacquidate}; |
256 |
$publisheddate = GetNextDate($subscription, $publisheddate); |
244 |
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); |
257 |
is($publisheddate, '1970-01-07'); |
245 |
is($publisheddate, '1970-01-07'); |
258 |
$publisheddate = GetNextDate($subscription, $publisheddate); |
246 |
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); |
259 |
is($publisheddate, '1970-01-08'); |
247 |
is($publisheddate, '1970-01-08'); |
260 |
$publisheddate = GetNextDate($subscription, $publisheddate); |
248 |
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); |
261 |
is($publisheddate, '1970-01-09'); |
249 |
is($publisheddate, '1970-01-09'); |
262 |
$publisheddate = GetNextDate($subscription, $publisheddate); |
250 |
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); |
263 |
is($publisheddate, '1970-01-10'); |
251 |
is($publisheddate, '1970-01-10'); |
264 |
$publisheddate = GetNextDate($subscription, $publisheddate); |
252 |
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); |
265 |
is($publisheddate, '1970-01-11'); |
253 |
is($publisheddate, '1970-01-11'); |
266 |
$publisheddate = GetNextDate($subscription, $publisheddate); |
254 |
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); |
267 |
is($publisheddate, '1970-01-13'); |
255 |
is($publisheddate, '1970-01-13'); |
268 |
|
256 |
|
269 |
# TEST CASE - 6 issues per week, irregularities |
257 |
# TEST CASE - 6 issues per week, irregularities |
270 |
$subscription = { |
258 |
$subscription = { |
271 |
periodicity => $id, |
|
|
272 |
firstacquidate => '1970-01-06', |
259 |
firstacquidate => '1970-01-06', |
273 |
irregularity => '3;5;6', |
260 |
irregularity => '3;5;6', |
274 |
countissuesperunit => 1, |
261 |
countissuesperunit => 1, |
275 |
}; |
262 |
}; |
276 |
$publisheddate = $subscription->{firstacquidate}; |
263 |
$publisheddate = $subscription->{firstacquidate}; |
277 |
$publisheddate = GetNextDate($subscription, $publisheddate); |
264 |
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); |
278 |
is($publisheddate, '1970-01-07'); |
265 |
is($publisheddate, '1970-01-07'); |
279 |
$publisheddate = GetNextDate($subscription, $publisheddate); |
266 |
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); |
280 |
is($publisheddate, '1970-01-09'); |
267 |
is($publisheddate, '1970-01-09'); |
281 |
$publisheddate = GetNextDate($subscription, $publisheddate); |
268 |
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); |
282 |
is($publisheddate, '1970-01-13'); |
269 |
is($publisheddate, '1970-01-13'); |
283 |
$publisheddate = GetNextDate($subscription, $publisheddate); |
270 |
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); |
284 |
is($publisheddate, '1970-01-14'); |
271 |
is($publisheddate, '1970-01-14'); |
285 |
|
272 |
|
286 |
# TEST CASE - 1 issue per month, no irregularity |
273 |
# TEST CASE - 1 issue per month, no irregularity |
287 |
$id = AddSubscriptionFrequency({ |
274 |
$frequency = { |
288 |
description => "1 issue per month", |
275 |
description => "1 issue per month", |
289 |
unit => 'month', |
276 |
unit => 'month', |
290 |
issuesperunit => 1, |
277 |
issuesperunit => 1, |
291 |
unitsperissue => 1, |
278 |
unitsperissue => 1, |
292 |
}); |
279 |
}; |
293 |
$subscription = { |
280 |
$subscription = { |
294 |
periodicity => $id, |
|
|
295 |
firstacquidate => '1970-01-01', |
281 |
firstacquidate => '1970-01-01', |
296 |
irregularity => '', |
282 |
irregularity => '', |
297 |
countissuesperunit => 1, |
283 |
countissuesperunit => 1, |
298 |
}; |
284 |
}; |
299 |
$publisheddate = $subscription->{firstacquidate}; |
285 |
$publisheddate = $subscription->{firstacquidate}; |
300 |
$publisheddate = GetNextDate($subscription, $publisheddate); |
286 |
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); |
301 |
is($publisheddate, '1970-02-01'); |
287 |
is($publisheddate, '1970-02-01'); |
302 |
$publisheddate = GetNextDate($subscription, $publisheddate); |
288 |
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); |
303 |
is($publisheddate, '1970-03-01'); |
289 |
is($publisheddate, '1970-03-01'); |
304 |
$publisheddate = GetNextDate($subscription, $publisheddate); |
290 |
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); |
305 |
is($publisheddate, '1970-04-01'); |
291 |
is($publisheddate, '1970-04-01'); |
306 |
|
292 |
|
307 |
# TEST CASE - 1 issue per month, irregularities |
293 |
# TEST CASE - 1 issue per month, irregularities |
308 |
$subscription = { |
294 |
$subscription = { |
309 |
periodicity => $id, |
|
|
310 |
firstacquidate => '1970-01-01', |
295 |
firstacquidate => '1970-01-01', |
311 |
irregularity => '2;4', |
296 |
irregularity => '2;4', |
312 |
countissuesperunit => 1, |
297 |
countissuesperunit => 1, |
313 |
}; |
298 |
}; |
314 |
$publisheddate = $subscription->{firstacquidate}; |
299 |
$publisheddate = $subscription->{firstacquidate}; |
315 |
$publisheddate = GetNextDate($subscription, $publisheddate); |
300 |
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); |
316 |
is($publisheddate, '1970-03-01'); |
301 |
is($publisheddate, '1970-03-01'); |
317 |
$publisheddate = GetNextDate($subscription, $publisheddate); |
302 |
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); |
318 |
is($publisheddate, '1970-05-01'); |
303 |
is($publisheddate, '1970-05-01'); |
319 |
$publisheddate = GetNextDate($subscription, $publisheddate); |
304 |
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); |
320 |
is($publisheddate, '1970-06-01'); |
305 |
is($publisheddate, '1970-06-01'); |
321 |
|
306 |
|
322 |
# TEST CASE - 1 issue every 2 months, no irregularity |
307 |
# TEST CASE - 1 issue every 2 months, no irregularity |
323 |
$id = AddSubscriptionFrequency({ |
308 |
$frequency = { |
324 |
description => "1 issue every 2 months", |
309 |
description => "1 issue every 2 months", |
325 |
unit => 'month', |
310 |
unit => 'month', |
326 |
issuesperunit => 1, |
311 |
issuesperunit => 1, |
327 |
unitsperissue => 2, |
312 |
unitsperissue => 2, |
328 |
}); |
313 |
}; |
329 |
$subscription = { |
314 |
$subscription = { |
330 |
periodicity => $id, |
|
|
331 |
firstacquidate => '1970-01-01', |
315 |
firstacquidate => '1970-01-01', |
332 |
irregularity => '', |
316 |
irregularity => '', |
333 |
countissuesperunit => 1, |
317 |
countissuesperunit => 1, |
334 |
}; |
318 |
}; |
335 |
$publisheddate = $subscription->{firstacquidate}; |
319 |
$publisheddate = $subscription->{firstacquidate}; |
336 |
$publisheddate = GetNextDate($subscription, $publisheddate); |
320 |
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); |
337 |
is($publisheddate, '1970-03-01'); |
321 |
is($publisheddate, '1970-03-01'); |
338 |
$publisheddate = GetNextDate($subscription, $publisheddate); |
322 |
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); |
339 |
is($publisheddate, '1970-05-01'); |
323 |
is($publisheddate, '1970-05-01'); |
340 |
$publisheddate = GetNextDate($subscription, $publisheddate); |
324 |
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); |
341 |
is($publisheddate, '1970-07-01'); |
325 |
is($publisheddate, '1970-07-01'); |
342 |
|
326 |
|
343 |
# TEST CASE - 1 issue every 2 months, irregularities |
327 |
# TEST CASE - 1 issue every 2 months, irregularities |
344 |
$subscription = { |
328 |
$subscription = { |
345 |
periodicity => $id, |
|
|
346 |
firstacquidate => '1970-01-01', |
329 |
firstacquidate => '1970-01-01', |
347 |
irregularity => '2;3', |
330 |
irregularity => '2;3', |
348 |
countissuesperunit => 1, |
331 |
countissuesperunit => 1, |
349 |
}; |
332 |
}; |
350 |
$publisheddate = $subscription->{firstacquidate}; |
333 |
$publisheddate = $subscription->{firstacquidate}; |
351 |
$publisheddate = GetNextDate($subscription, $publisheddate); |
334 |
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); |
352 |
is($publisheddate, '1970-07-01'); |
335 |
is($publisheddate, '1970-07-01'); |
353 |
$publisheddate = GetNextDate($subscription, $publisheddate); |
336 |
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); |
354 |
is($publisheddate, '1970-09-01'); |
337 |
is($publisheddate, '1970-09-01'); |
355 |
$publisheddate = GetNextDate($subscription, $publisheddate); |
338 |
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); |
356 |
is($publisheddate, '1970-11-01'); |
339 |
is($publisheddate, '1970-11-01'); |
357 |
|
340 |
|
358 |
# TEST CASE - 2 issues per month, no irregularity |
341 |
# TEST CASE - 2 issues per month, no irregularity |
359 |
$id = AddSubscriptionFrequency({ |
342 |
$frequency = { |
360 |
description => "2 issues per month", |
343 |
description => "2 issues per month", |
361 |
unit => 'month', |
344 |
unit => 'month', |
362 |
issuesperunit => 2, |
345 |
issuesperunit => 2, |
363 |
unitsperissue => 1, |
346 |
unitsperissue => 1, |
364 |
}); |
347 |
}; |
365 |
$subscription = { |
348 |
$subscription = { |
366 |
periodicity => $id, |
|
|
367 |
firstacquidate => '1970-01-01', |
349 |
firstacquidate => '1970-01-01', |
368 |
irregularity => '', |
350 |
irregularity => '', |
369 |
countissuesperunit => 1, |
351 |
countissuesperunit => 1, |
370 |
}; |
352 |
}; |
371 |
$publisheddate = $subscription->{firstacquidate}; |
353 |
$publisheddate = $subscription->{firstacquidate}; |
372 |
$publisheddate = GetNextDate($subscription, $publisheddate); |
354 |
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); |
373 |
is($publisheddate, '1970-01-16', 'Jan 16'); |
355 |
is($publisheddate, '1970-01-16', 'January has 31 days'); |
374 |
$publisheddate = GetNextDate($subscription, $publisheddate); |
356 |
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); |
375 |
is($publisheddate, '1970-02-01', 'Feb 1'); |
357 |
is($publisheddate, '1970-02-01'); |
376 |
$publisheddate = GetNextDate($subscription, $publisheddate); |
358 |
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); |
377 |
is($publisheddate, '1970-02-16', 'Feb 16'); |
359 |
is($publisheddate, '1970-02-16', 'February has only 28 days'); |
378 |
$publisheddate = GetNextDate($subscription, $publisheddate); |
360 |
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); |
379 |
is($publisheddate, '1970-03-01', 'Mar 1' ); |
361 |
is($publisheddate, '1970-03-01'); |
380 |
|
362 |
|
381 |
# TEST CASE - 2 issues per month, irregularities |
363 |
# TEST CASE - 2 issues per month, irregularities |
382 |
$subscription = { |
364 |
$subscription = { |
383 |
periodicity => $id, |
|
|
384 |
firstacquidate => '1970-01-01', |
365 |
firstacquidate => '1970-01-01', |
385 |
irregularity => '3;5;6', |
366 |
irregularity => '3;5;6', |
386 |
countissuesperunit => 1, |
367 |
countissuesperunit => 1, |
387 |
}; |
368 |
}; |
388 |
$publisheddate = $subscription->{firstacquidate}; |
369 |
$publisheddate = $subscription->{firstacquidate}; |
389 |
$publisheddate = GetNextDate($subscription, $publisheddate); |
370 |
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); |
390 |
is($publisheddate, '1970-01-16', 'Jan 16' ); |
371 |
is($publisheddate, '1970-01-16', 'January has 31 days'); |
391 |
$publisheddate = GetNextDate($subscription, $publisheddate); |
372 |
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); |
392 |
is($publisheddate, '1970-02-16', 'Feb 16 (skipping Feb 1)' ); |
373 |
is($publisheddate, '1970-02-16', 'February has only 28 days'); |
393 |
$publisheddate = GetNextDate($subscription, $publisheddate); |
374 |
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); |
394 |
is($publisheddate, '1970-04-01', 'Apr 1 (skipping Mar 1 and 16)' ); |
375 |
is($publisheddate, '1970-04-01'); |
395 |
$publisheddate = GetNextDate($subscription, $publisheddate); |
376 |
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); |
396 |
is($publisheddate, '1970-04-16', 'Apr 16' ); |
377 |
is($publisheddate, '1970-04-16', 'April has 30 days'); |
397 |
$publisheddate = GetNextDate($subscription, $publisheddate); |
378 |
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); |
398 |
is($publisheddate, '1970-05-01', 'May 1' ); |
379 |
is($publisheddate, '1970-05-01'); |
399 |
|
380 |
|
400 |
# TEST CASE - 1 issue per year, no irregularity |
381 |
# TEST CASE - 1 issue per year, no irregularity |
401 |
$id = AddSubscriptionFrequency({ |
382 |
$frequency = { |
402 |
description => "1 issue per year", |
383 |
description => "1 issue per year", |
403 |
unit => 'year', |
384 |
unit => 'year', |
404 |
issuesperunit => 1, |
385 |
issuesperunit => 1, |
405 |
unitsperissue => 1, |
386 |
unitsperissue => 1, |
406 |
}); |
387 |
}; |
407 |
$subscription = { |
388 |
$subscription = { |
408 |
periodicity => $id, |
|
|
409 |
firstacquidate => '1970-01-01', |
389 |
firstacquidate => '1970-01-01', |
410 |
irregularity => '', |
390 |
irregularity => '', |
411 |
countissuesperunit => 1, |
391 |
countissuesperunit => 1, |
412 |
}; |
392 |
}; |
413 |
$publisheddate = $subscription->{firstacquidate}; |
393 |
$publisheddate = $subscription->{firstacquidate}; |
414 |
$publisheddate = GetNextDate($subscription, $publisheddate); |
394 |
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); |
415 |
is($publisheddate, '1971-01-01'); |
395 |
is($publisheddate, '1971-01-01'); |
416 |
$publisheddate = GetNextDate($subscription, $publisheddate); |
396 |
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); |
417 |
is($publisheddate, '1972-01-01'); |
397 |
is($publisheddate, '1972-01-01'); |
418 |
$publisheddate = GetNextDate($subscription, $publisheddate); |
398 |
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); |
419 |
is($publisheddate, '1973-01-01'); |
399 |
is($publisheddate, '1973-01-01'); |
420 |
|
400 |
|
421 |
# TEST CASE - 1 issue per year, irregularities |
401 |
# TEST CASE - 1 issue per year, irregularities |
422 |
$subscription = { |
402 |
$subscription = { |
423 |
periodicity => $id, |
|
|
424 |
firstacquidate => '1970-01-01', |
403 |
firstacquidate => '1970-01-01', |
425 |
irregularity => '2;4', |
404 |
irregularity => '2;4', |
426 |
countissuesperunit => 1, |
405 |
countissuesperunit => 1, |
427 |
}; |
406 |
}; |
428 |
$publisheddate = $subscription->{firstacquidate}; |
407 |
$publisheddate = $subscription->{firstacquidate}; |
429 |
$publisheddate = GetNextDate($subscription, $publisheddate); |
408 |
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); |
430 |
is($publisheddate, '1972-01-01'); |
409 |
is($publisheddate, '1972-01-01'); |
431 |
$publisheddate = GetNextDate($subscription, $publisheddate); |
410 |
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); |
432 |
is($publisheddate, '1974-01-01'); |
411 |
is($publisheddate, '1974-01-01'); |
433 |
$publisheddate = GetNextDate($subscription, $publisheddate); |
412 |
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); |
434 |
is($publisheddate, '1975-01-01'); |
413 |
is($publisheddate, '1975-01-01'); |
435 |
|
414 |
|
436 |
# TEST CASE - 1 issue every 2 years, no irregularity |
415 |
# TEST CASE - 1 issue every 2 years, no irregularity |
437 |
$id = AddSubscriptionFrequency({ |
416 |
$frequency = { |
438 |
description => "1 issue every 2 years", |
417 |
description => "1 issue every 2 years", |
439 |
unit => 'year', |
418 |
unit => 'year', |
440 |
issuesperunit => 1, |
419 |
issuesperunit => 1, |
441 |
unitsperissue => 2, |
420 |
unitsperissue => 2, |
442 |
}); |
421 |
}; |
443 |
$subscription = { |
422 |
$subscription = { |
444 |
periodicity => $id, |
|
|
445 |
firstacquidate => '1970-01-01', |
423 |
firstacquidate => '1970-01-01', |
446 |
irregularity => '', |
424 |
irregularity => '', |
447 |
countissuesperunit => 1, |
425 |
countissuesperunit => 1, |
448 |
}; |
426 |
}; |
449 |
$publisheddate = $subscription->{firstacquidate}; |
427 |
$publisheddate = $subscription->{firstacquidate}; |
450 |
$publisheddate = GetNextDate($subscription, $publisheddate); |
428 |
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); |
451 |
is($publisheddate, '1972-01-01'); |
429 |
is($publisheddate, '1972-01-01'); |
452 |
$publisheddate = GetNextDate($subscription, $publisheddate); |
430 |
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); |
453 |
is($publisheddate, '1974-01-01'); |
431 |
is($publisheddate, '1974-01-01'); |
454 |
$publisheddate = GetNextDate($subscription, $publisheddate); |
432 |
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); |
455 |
is($publisheddate, '1976-01-01'); |
433 |
is($publisheddate, '1976-01-01'); |
456 |
|
434 |
|
457 |
# TEST CASE - 1 issue every 2 years, irregularities |
435 |
# TEST CASE - 1 issue every 2 years, irregularities |
458 |
$subscription = { |
436 |
$subscription = { |
459 |
periodicity => $id, |
|
|
460 |
firstacquidate => '1970-01-01', |
437 |
firstacquidate => '1970-01-01', |
461 |
irregularity => '2;4', |
438 |
irregularity => '2;4', |
462 |
countissuesperunit => 1, |
439 |
countissuesperunit => 1, |
463 |
}; |
440 |
}; |
464 |
$publisheddate = $subscription->{firstacquidate}; |
441 |
$publisheddate = $subscription->{firstacquidate}; |
465 |
$publisheddate = GetNextDate($subscription, $publisheddate); |
442 |
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); |
466 |
is($publisheddate, '1974-01-01'); |
443 |
is($publisheddate, '1974-01-01'); |
467 |
$publisheddate = GetNextDate($subscription, $publisheddate); |
444 |
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); |
468 |
is($publisheddate, '1978-01-01'); |
445 |
is($publisheddate, '1978-01-01'); |
469 |
$publisheddate = GetNextDate($subscription, $publisheddate); |
446 |
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); |
470 |
is($publisheddate, '1980-01-01'); |
447 |
is($publisheddate, '1980-01-01'); |
471 |
# Move publisheddate to Feb 29 (leap year 1980) |
448 |
# Move publisheddate to Feb 29 (leap year 1980) |
472 |
$publisheddate = '1980-02-29'; |
449 |
$publisheddate = '1980-02-29'; |
473 |
$publisheddate = GetNextDate( $subscription, $publisheddate ); |
450 |
$publisheddate = GetNextDate( $subscription, $publisheddate, $frequency ); |
474 |
is( $publisheddate, '1982-02-28', 'Test +2 year from Feb 29' ); |
451 |
is( $publisheddate, '1982-02-28', 'Test +2 year from Feb 29' ); |
475 |
|
452 |
|
476 |
# TEST CASE - 2 issues per year, no irregularity |
453 |
# TEST CASE - 2 issues per year, no irregularity |
477 |
$id = AddSubscriptionFrequency({ |
454 |
$frequency = { |
478 |
description => "2 issues per year", |
455 |
description => "1 issue every 2 years", |
479 |
unit => 'year', |
456 |
unit => 'year', |
480 |
issuesperunit => 2, |
457 |
issuesperunit => 2, |
481 |
unitsperissue => 1, |
458 |
unitsperissue => 1, |
482 |
}); |
459 |
}; |
483 |
$subscription = { |
460 |
$subscription = { |
484 |
periodicity => $id, |
|
|
485 |
firstacquidate => '1970-01-01', |
461 |
firstacquidate => '1970-01-01', |
486 |
irregularity => '', |
462 |
irregularity => '', |
487 |
countissuesperunit => 1, |
463 |
countissuesperunit => 1, |
488 |
}; |
464 |
}; |
489 |
$publisheddate = $subscription->{firstacquidate}; |
465 |
$publisheddate = $subscription->{firstacquidate}; |
490 |
$publisheddate = GetNextDate($subscription, $publisheddate); |
466 |
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); |
491 |
is($publisheddate, '1970-07-02'); |
467 |
is($publisheddate, '1970-07-02'); |
492 |
$publisheddate = GetNextDate($subscription, $publisheddate); |
468 |
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); |
493 |
is($publisheddate, '1971-01-01'); |
469 |
is($publisheddate, '1971-01-01'); |
494 |
$publisheddate = GetNextDate($subscription, $publisheddate); |
470 |
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); |
495 |
is($publisheddate, '1971-07-02'); |
471 |
is($publisheddate, '1971-07-02'); |
496 |
$publisheddate = GetNextDate($subscription, $publisheddate); |
472 |
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); |
497 |
is($publisheddate, '1972-01-01'); |
473 |
is($publisheddate, '1972-01-01'); |
498 |
|
474 |
|
499 |
# TEST CASE - 2 issues per year, irregularities |
475 |
# TEST CASE - 2 issues per year, irregularities |
500 |
$subscription = { |
476 |
$subscription = { |
501 |
periodicity => $id, |
|
|
502 |
firstacquidate => '1970-01-01', |
477 |
firstacquidate => '1970-01-01', |
503 |
irregularity => '3;5;6', |
478 |
irregularity => '3;5;6', |
504 |
countissuesperunit => 1, |
479 |
countissuesperunit => 1, |
505 |
}; |
480 |
}; |
506 |
$publisheddate = $subscription->{firstacquidate}; |
481 |
$publisheddate = $subscription->{firstacquidate}; |
507 |
$publisheddate = GetNextDate($subscription, $publisheddate); |
482 |
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); |
508 |
is($publisheddate, '1970-07-02'); |
483 |
is($publisheddate, '1970-07-02'); |
509 |
$publisheddate = GetNextDate($subscription, $publisheddate); |
484 |
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); |
510 |
is($publisheddate, '1971-07-02'); |
485 |
is($publisheddate, '1971-07-02'); |
511 |
$publisheddate = GetNextDate($subscription, $publisheddate); |
486 |
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); |
512 |
is($publisheddate, '1973-01-01'); |
487 |
is($publisheddate, '1973-01-01'); |
513 |
$publisheddate = GetNextDate($subscription, $publisheddate); |
488 |
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); |
514 |
is($publisheddate, '1973-07-02'); |
489 |
is($publisheddate, '1973-07-02'); |
515 |
$publisheddate = GetNextDate($subscription, $publisheddate); |
490 |
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); |
516 |
is($publisheddate, '1974-01-01'); |
491 |
is($publisheddate, '1974-01-01'); |
517 |
|
492 |
|
518 |
# TEST CASE - 9 issues per year, dates spread throughout month |
493 |
# TEST CASE - 9 issues per year, dates spread throughout month |
519 |
$id = AddSubscriptionFrequency({ |
494 |
$frequency = { |
520 |
description => "9 issues per year", |
495 |
description => "9 issues per year", |
521 |
unit => 'year', |
496 |
unit => 'year', |
522 |
issuesperunit => 9, |
497 |
issuesperunit => 9, |
523 |
unitsperissue => 1, |
498 |
unitsperissue => 1, |
524 |
}); |
499 |
}; |
525 |
$subscription = { |
500 |
$subscription = { |
526 |
periodicity => $id, |
|
|
527 |
firstacquidate => '1970-08-10', |
501 |
firstacquidate => '1970-08-10', |
528 |
irregularity => '', |
502 |
irregularity => '', |
529 |
countissuesperunit => 1, |
503 |
countissuesperunit => 1, |
530 |
}; |
504 |
}; |
531 |
my @dates = ( $subscription->{firstacquidate} ); |
505 |
my @dates = ( $subscription->{firstacquidate} ); |
532 |
foreach(1..27) { |
506 |
foreach(1..27) { |
533 |
push @dates, GetNextDate( $subscription, $dates[-1] ); |
507 |
push @dates, GetNextDate( $subscription, $dates[-1], $frequency ); |
534 |
} |
508 |
} |
535 |
is( $dates[9], '1971-08-10', 'Freq 9/yr, 1 year passed' ); |
509 |
is( $dates[9], '1971-08-10', 'Freq 9/yr, 1 year passed' ); |
536 |
is( $dates[18], '1972-08-10', 'Freq 9/yr, 2 years passed (leap year)' ); |
510 |
is( $dates[18], '1972-08-10', 'Freq 9/yr, 2 years passed (leap year)' ); |
537 |
is( $dates[27], '1973-08-10', 'Freq 9/yr, 3 years passed' ); |
511 |
is( $dates[27], '1973-08-10', 'Freq 9/yr, 3 years passed' ); |
538 |
# Keep (first) position in cycle, but shift back 9 days |
512 |
# Keep (first) position in cycle, but shift back 9 days |
539 |
is( GetNextDate( $subscription, '1973-08-01' ), '1973-09-10', 'Back 9 days, without annual correction' ); |
513 |
is( GetNextDate( $subscription, '1973-08-01', $frequency ), '1973-09-10', 'Back 9 days, without annual correction' ); |
540 |
# Set position to last in cycle, and shift back 9 days; annual correction |
514 |
# Set position to last in cycle, and shift back 9 days; annual correction |
541 |
$subscription->{countissuesperunit} = 9; |
515 |
$subscription->{countissuesperunit} = 9; |
542 |
is( GetNextDate( $subscription, '1973-08-01' ), '1973-09-15', 'Last in cycle, back 9 days, expect annual correction' ); |
516 |
is( GetNextDate( $subscription, '1973-08-01', $frequency ), '1973-09-15', 'Last in cycle, back 9 days, expect annual correction' ); |
543 |
|
517 |
|
544 |
# TEST CASE - Irregular |
518 |
# TEST CASE - Irregular |
545 |
$id = AddSubscriptionFrequency({ |
519 |
$frequency = { |
546 |
description => "Irregular", |
520 |
description => "Irregular", |
547 |
unit => undef, |
521 |
unit => undef, |
548 |
issuesperunit => 1, |
522 |
issuesperunit => 1, |
549 |
unitsperissue => 1, |
523 |
unitsperissue => 1, |
550 |
}); |
524 |
}; |
551 |
$subscription = { |
525 |
$subscription = { |
552 |
periodicity => $id, |
|
|
553 |
firstacquidate => '1970-01-01', |
526 |
firstacquidate => '1970-01-01', |
554 |
irregularity => '', |
527 |
irregularity => '', |
555 |
countissuesperunit => 1, |
528 |
countissuesperunit => 1, |
556 |
}; |
529 |
}; |
557 |
$publisheddate = $subscription->{firstacquidate}; |
530 |
$publisheddate = $subscription->{firstacquidate}; |
558 |
# GetNextDate always return undef if subscription is irregular |
531 |
# GetNextDate always return undef if subscription is irregular |
559 |
$publisheddate = GetNextDate($subscription, $publisheddate); |
532 |
$publisheddate = GetNextDate($subscription, $publisheddate, $frequency); |
560 |
is($publisheddate, undef); |
533 |
is($publisheddate, undef); |
561 |
|
534 |
|
562 |
# GetNextDate returns undef if one of two first parameters is undef |
535 |
# GetNextDate returns undef if one of two first parameters is undef |
563 |
$publisheddate = GetNextDate($subscription, undef); |
536 |
$publisheddate = GetNextDate($subscription, undef, $frequency); |
564 |
is($publisheddate, undef); |
537 |
is($publisheddate, undef); |
565 |
$publisheddate = GetNextDate(undef, $subscription->{firstacquidate}); |
538 |
$publisheddate = GetNextDate(undef, $subscription->{firstacquidate}, $frequency); |
566 |
is($publisheddate, undef); |
539 |
is($publisheddate, undef); |
567 |
$publisheddate = GetNextDate(undef, undef); |
540 |
$publisheddate = GetNextDate(undef, undef, $frequency); |
568 |
is($publisheddate, undef); |
541 |
is($publisheddate, undef); |
569 |
|
542 |
|
570 |
$schema->storage->txn_rollback; |
543 |
$schema->storage->txn_rollback; |