Lines 36-42
$schema->storage->txn_begin;
Link Here
|
36 |
my $builder = t::lib::TestBuilder->new; |
36 |
my $builder = t::lib::TestBuilder->new; |
37 |
|
37 |
|
38 |
subtest 'get_effective_issuing_rule' => sub { |
38 |
subtest 'get_effective_issuing_rule' => sub { |
39 |
plan tests => 3; |
39 |
plan tests => 2; |
40 |
|
40 |
|
41 |
my $categorycode = $builder->build({ source => 'Category' })->{'categorycode'}; |
41 |
my $categorycode = $builder->build({ source => 'Category' })->{'categorycode'}; |
42 |
my $itemtype = $builder->build({ source => 'Itemtype' })->{'itemtype'}; |
42 |
my $itemtype = $builder->build({ source => 'Itemtype' })->{'itemtype'}; |
Lines 94-394
subtest 'get_effective_issuing_rule' => sub {
Link Here
|
94 |
); |
94 |
); |
95 |
}; |
95 |
}; |
96 |
|
96 |
|
97 |
subtest 'Get effective issuing rule in correct order' => sub { |
|
|
98 |
plan tests => 26; |
99 |
|
100 |
my $rule; |
101 |
Koha::CirculationRules->delete; |
102 |
is(Koha::CirculationRules->search->count, 0, 'There are no issuing rules.'); |
103 |
$rule = Koha::CirculationRules->get_effective_rule({ |
104 |
branchcode => $branchcode, |
105 |
categorycode => $categorycode, |
106 |
itemtype => $itemtype, |
107 |
rule_name => 'fine', |
108 |
}); |
109 |
is($rule, undef, 'When I attempt to get effective issuing rule, then undef' |
110 |
.' is returned.'); |
111 |
|
112 |
# undef, undef, undef => 5 |
113 |
ok(Koha::CirculationRule->new({ |
114 |
branchcode => undef, |
115 |
categorycode => undef, |
116 |
itemtype => undef, |
117 |
rule_name => 'fine', |
118 |
rule_value => 5, |
119 |
})->store, 'Given I added an issuing rule branchcode => undef, categorycode => undef, itemtype => undef,'); |
120 |
$rule = Koha::CirculationRules->get_effective_rule({ |
121 |
branchcode => $branchcode, |
122 |
categorycode => $categorycode, |
123 |
itemtype => $itemtype, |
124 |
rule_name => 'fine', |
125 |
}); |
126 |
_is_row_match( |
127 |
$rule, |
128 |
{ |
129 |
branchcode => undef, |
130 |
categorycode => undef, |
131 |
itemtype => undef, |
132 |
rule_name => 'fine', |
133 |
rule_value => 5, |
134 |
}, |
135 |
'When I attempt to get effective issuing rule,' |
136 |
.' then the above one is returned.' |
137 |
); |
138 |
|
139 |
# undef, undef, undef => 5 |
140 |
# undef, undef, $itemtype => 7 |
141 |
ok( |
142 |
Koha::CirculationRule->new( |
143 |
{ |
144 |
branchcode => undef, |
145 |
categorycode => undef, |
146 |
itemtype => $itemtype, |
147 |
rule_name => 'fine', |
148 |
rule_value => 7, |
149 |
} |
150 |
)->store, |
151 |
"Given I added an issuing rule branchcode => undef, categorycode => undef, itemtype => $itemtype," |
152 |
); |
153 |
$rule = Koha::CirculationRules->get_effective_rule({ |
154 |
branchcode => $branchcode, |
155 |
categorycode => $categorycode, |
156 |
itemtype => $itemtype, |
157 |
rule_name => 'fine', |
158 |
}); |
159 |
_is_row_match( |
160 |
$rule, |
161 |
{ |
162 |
branchcode => undef, |
163 |
categorycode => undef, |
164 |
itemtype => $itemtype, |
165 |
rule_name => 'fine', |
166 |
rule_value => 7, |
167 |
}, |
168 |
'When I attempt to get effective issuing rule,' |
169 |
.' then the above one is returned.' |
170 |
); |
171 |
|
172 |
# undef, undef, undef => 5 |
173 |
# undef, undef, $itemtype => 7 |
174 |
# undef, $categorycode, undef => 9 |
175 |
ok( |
176 |
Koha::CirculationRule->new( |
177 |
{ |
178 |
branchcode => undef, |
179 |
categorycode => $categorycode, |
180 |
itemtype => undef, |
181 |
rule_name => 'fine', |
182 |
rule_value => 9, |
183 |
} |
184 |
)->store, |
185 |
"Given I added an issuing rule branchcode => undef, categorycode => $categorycode, itemtype => undef," |
186 |
); |
187 |
$rule = Koha::CirculationRules->get_effective_rule({ |
188 |
branchcode => $branchcode, |
189 |
categorycode => $categorycode, |
190 |
itemtype => $itemtype, |
191 |
rule_name => 'fine', |
192 |
}); |
193 |
_is_row_match( |
194 |
$rule, |
195 |
{ |
196 |
branchcode => undef, |
197 |
categorycode => $categorycode, |
198 |
itemtype => undef, |
199 |
rule_name => 'fine', |
200 |
rule_value => 9, |
201 |
}, |
202 |
'When I attempt to get effective issuing rule,' |
203 |
.' then the above one is returned.' |
204 |
); |
205 |
|
206 |
# undef, undef, undef => 5 |
207 |
# undef, undef, $itemtype => 7 |
208 |
# undef, $categorycode, undef => 9 |
209 |
# undef, $categorycode, $itemtype => 11 |
210 |
ok( |
211 |
Koha::CirculationRule->new( |
212 |
{ |
213 |
branchcode => undef, |
214 |
categorycode => $categorycode, |
215 |
itemtype => $itemtype, |
216 |
rule_name => 'fine', |
217 |
rule_value => 11, |
218 |
} |
219 |
)->store, |
220 |
"Given I added an issuing rule branchcode => undef, categorycode => $categorycode, itemtype => $itemtype," |
221 |
); |
222 |
$rule = Koha::CirculationRules->get_effective_rule({ |
223 |
branchcode => $branchcode, |
224 |
categorycode => $categorycode, |
225 |
itemtype => $itemtype, |
226 |
rule_name => 'fine', |
227 |
}); |
228 |
_is_row_match( |
229 |
$rule, |
230 |
{ |
231 |
branchcode => undef, |
232 |
categorycode => $categorycode, |
233 |
itemtype => $itemtype, |
234 |
rule_name => 'fine', |
235 |
rule_value => 11, |
236 |
}, |
237 |
'When I attempt to get effective issuing rule,' |
238 |
.' then the above one is returned.' |
239 |
); |
240 |
|
241 |
# undef, undef, undef => 5 |
242 |
# undef, undef, $itemtype => 7 |
243 |
# undef, $categorycode, undef => 9 |
244 |
# undef, $categorycode, $itemtype => 11 |
245 |
# $branchcode, undef, undef => 13 |
246 |
ok( |
247 |
Koha::CirculationRule->new( |
248 |
{ |
249 |
branchcode => $branchcode, |
250 |
categorycode => undef, |
251 |
itemtype => undef, |
252 |
rule_name => 'fine', |
253 |
rule_value => 13, |
254 |
} |
255 |
)->store, |
256 |
"Given I added an issuing rule branchcode => $branchcode, categorycode => undef, itemtype => undef," |
257 |
); |
258 |
$rule = Koha::CirculationRules->get_effective_rule({ |
259 |
branchcode => $branchcode, |
260 |
categorycode => $categorycode, |
261 |
itemtype => $itemtype, |
262 |
rule_name => 'fine', |
263 |
}); |
264 |
_is_row_match( |
265 |
$rule, |
266 |
{ |
267 |
branchcode => $branchcode, |
268 |
categorycode => undef, |
269 |
itemtype => undef, |
270 |
rule_name => 'fine', |
271 |
rule_value => 13, |
272 |
}, |
273 |
'When I attempt to get effective issuing rule,' |
274 |
.' then the above one is returned.' |
275 |
); |
276 |
|
277 |
# undef, undef, undef => 5 |
278 |
# undef, undef, $itemtype => 7 |
279 |
# undef, $categorycode, undef => 9 |
280 |
# undef, $categorycode, $itemtype => 11 |
281 |
# $branchcode, undef, undef => 13 |
282 |
# $branchcode, undef, $itemtype => 15 |
283 |
ok( |
284 |
Koha::CirculationRule->new( |
285 |
{ |
286 |
branchcode => $branchcode, |
287 |
categorycode => undef, |
288 |
itemtype => $itemtype, |
289 |
rule_name => 'fine', |
290 |
rule_value => 15, |
291 |
} |
292 |
)->store, |
293 |
"Given I added an issuing rule branchcode => $branchcode, categorycode => undef, itemtype => $itemtype," |
294 |
); |
295 |
$rule = Koha::CirculationRules->get_effective_rule({ |
296 |
branchcode => $branchcode, |
297 |
categorycode => $categorycode, |
298 |
itemtype => $itemtype, |
299 |
rule_name => 'fine', |
300 |
}); |
301 |
_is_row_match( |
302 |
$rule, |
303 |
{ |
304 |
branchcode => $branchcode, |
305 |
categorycode => undef, |
306 |
itemtype => $itemtype, |
307 |
rule_name => 'fine', |
308 |
rule_value => 15, |
309 |
}, |
310 |
'When I attempt to get effective issuing rule,' |
311 |
.' then the above one is returned.' |
312 |
); |
313 |
|
314 |
# undef, undef, undef => 5 |
315 |
# undef, undef, $itemtype => 7 |
316 |
# undef, $categorycode, undef => 9 |
317 |
# undef, $categorycode, $itemtype => 11 |
318 |
# $branchcode, undef, undef => 13 |
319 |
# $branchcode, undef, $itemtype => 15 |
320 |
# $branchcode, $categorycode, undef => 17 |
321 |
ok( |
322 |
Koha::CirculationRule->new( |
323 |
{ |
324 |
branchcode => $branchcode, |
325 |
categorycode => $categorycode, |
326 |
itemtype => undef, |
327 |
rule_name => 'fine', |
328 |
rule_value => 17, |
329 |
} |
330 |
)->store, |
331 |
"Given I added an issuing rule branchcode => $branchcode, categorycode => $categorycode, itemtype => undef," |
332 |
); |
333 |
$rule = Koha::CirculationRules->get_effective_rule({ |
334 |
branchcode => $branchcode, |
335 |
categorycode => $categorycode, |
336 |
itemtype => $itemtype, |
337 |
rule_name => 'fine', |
338 |
}); |
339 |
_is_row_match( |
340 |
$rule, |
341 |
{ |
342 |
branchcode => $branchcode, |
343 |
categorycode => $categorycode, |
344 |
itemtype => undef, |
345 |
rule_name => 'fine', |
346 |
rule_value => 17, |
347 |
}, |
348 |
'When I attempt to get effective issuing rule,' |
349 |
.' then the above one is returned.' |
350 |
); |
351 |
|
352 |
# undef, undef, undef => 5 |
353 |
# undef, undef, $itemtype => 7 |
354 |
# undef, $categorycode, undef => 9 |
355 |
# undef, $categorycode, $itemtype => 11 |
356 |
# $branchcode, undef, undef => 13 |
357 |
# $branchcode, undef, $itemtype => 15 |
358 |
# $branchcode, $categorycode, undef => 17 |
359 |
# $branchcode, $categorycode, $itemtype => 19 |
360 |
ok( |
361 |
Koha::CirculationRule->new( |
362 |
{ |
363 |
branchcode => $branchcode, |
364 |
categorycode => $categorycode, |
365 |
itemtype => $itemtype, |
366 |
rule_name => 'fine', |
367 |
rule_value => 19, |
368 |
} |
369 |
)->store, |
370 |
"Given I added an issuing rule branchcode => $branchcode, categorycode => $categorycode, itemtype => $itemtype," |
371 |
); |
372 |
$rule = Koha::CirculationRules->get_effective_rule({ |
373 |
branchcode => $branchcode, |
374 |
categorycode => $categorycode, |
375 |
itemtype => $itemtype, |
376 |
rule_name => 'fine', |
377 |
}); |
378 |
_is_row_match( |
379 |
$rule, |
380 |
{ |
381 |
branchcode => $branchcode, |
382 |
categorycode => $categorycode, |
383 |
itemtype => $itemtype, |
384 |
rule_name => 'fine', |
385 |
rule_value => 19, |
386 |
}, |
387 |
'When I attempt to get effective issuing rule,' |
388 |
.' then the above one is returned.' |
389 |
); |
390 |
}; |
391 |
|
392 |
subtest 'Performance' => sub { |
97 |
subtest 'Performance' => sub { |
393 |
plan tests => 4; |
98 |
plan tests => 4; |
394 |
|
99 |
|
395 |
- |
|
|