Lines 20-25
Link Here
|
20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
21 |
|
21 |
|
22 |
use Test::More tests => 2; |
22 |
use Test::More tests => 2; |
|
|
23 |
use Test::Deep qw( cmp_methods ); |
24 |
use Test::Exception; |
23 |
|
25 |
|
24 |
use Benchmark; |
26 |
use Benchmark; |
25 |
|
27 |
|
Lines 36-50
my $builder = t::lib::TestBuilder->new;
Link Here
|
36 |
subtest 'get_effective_issuing_rule' => sub { |
38 |
subtest 'get_effective_issuing_rule' => sub { |
37 |
plan tests => 3; |
39 |
plan tests => 3; |
38 |
|
40 |
|
39 |
my $patron = $builder->build({ source => 'Borrower' }); |
41 |
my $categorycode = $builder->build({ source => 'Category' })->{'categorycode'}; |
40 |
my $item = $builder->build({ source => 'Item' }); |
42 |
my $itemtype = $builder->build({ source => 'Itemtype' })->{'itemtype'}; |
41 |
|
43 |
my $branchcode = $builder->build({ source => 'Branch' })->{'branchcode'}; |
42 |
my $categorycode = $patron->{'categorycode'}; |
|
|
43 |
my $itemtype = $item->{'itype'}; |
44 |
my $branchcode = $item->{'homebranch'}; |
45 |
|
44 |
|
46 |
subtest 'Call with undefined values' => sub { |
45 |
subtest 'Call with undefined values' => sub { |
47 |
plan tests => 4; |
46 |
plan tests => 5; |
48 |
|
47 |
|
49 |
my $rule; |
48 |
my $rule; |
50 |
Koha::CirculationRules->delete; |
49 |
Koha::CirculationRules->delete; |
Lines 59-83
subtest 'get_effective_issuing_rule' => sub {
Link Here
|
59 |
is($rule, undef, 'When I attempt to get effective issuing rule by' |
58 |
is($rule, undef, 'When I attempt to get effective issuing rule by' |
60 |
.' providing undefined values, then undef is returned.'); |
59 |
.' providing undefined values, then undef is returned.'); |
61 |
ok(Koha::CirculationRule->new({ |
60 |
ok(Koha::CirculationRule->new({ |
62 |
branchcode => '*', |
61 |
branchcode => undef, |
63 |
categorycode => '*', |
62 |
categorycode => undef, |
64 |
itemtype => '*', |
63 |
itemtype => undef, |
65 |
rule_name => 'fine', |
64 |
rule_name => 'fine', |
66 |
})->store, 'Given I added an issuing rule branchcode => *,' |
65 |
})->store, 'Given I added an issuing rule branchcode => undef,' |
67 |
.' categorycode => *, itemtype => *,'); |
66 |
.' categorycode => undef, itemtype => undef,'); |
68 |
$rule = Koha::CirculationRules->get_effective_rule({ |
67 |
$rule = Koha::CirculationRules->get_effective_rule({ |
69 |
branchcode => '*', |
68 |
branchcode => undef, |
70 |
categorycode => '*', |
69 |
categorycode => undef, |
71 |
itemtype => '*', |
70 |
itemtype => undef, |
72 |
rule_name => 'fine', |
71 |
rule_name => 'fine', |
73 |
}); |
72 |
}); |
74 |
ok(_row_match($rule, '*', '*', '*'), 'When I attempt to get effective' |
73 |
_is_row_match( |
|
|
74 |
$rule, |
75 |
{ |
76 |
branchcode => undef, |
77 |
categorycode => undef, |
78 |
itemtype => undef |
79 |
}, |
80 |
'When I attempt to get effective' |
75 |
.' issuing rule by providing undefined values, then the above one is' |
81 |
.' issuing rule by providing undefined values, then the above one is' |
76 |
.' returned.'); |
82 |
.' returned.' |
|
|
83 |
); |
77 |
}; |
84 |
}; |
78 |
|
85 |
|
79 |
subtest 'Get effective issuing rule in correct order' => sub { |
86 |
subtest 'Get effective issuing rule in correct order' => sub { |
80 |
plan tests => 18; |
87 |
plan tests => 26; |
81 |
|
88 |
|
82 |
my $rule; |
89 |
my $rule; |
83 |
Koha::CirculationRules->delete; |
90 |
Koha::CirculationRules->delete; |
Lines 92-200
subtest 'get_effective_issuing_rule' => sub {
Link Here
|
92 |
.' is returned.'); |
99 |
.' is returned.'); |
93 |
|
100 |
|
94 |
ok(Koha::CirculationRule->new({ |
101 |
ok(Koha::CirculationRule->new({ |
95 |
branchcode => '*', |
102 |
branchcode => undef, |
96 |
categorycode => '*', |
103 |
categorycode => undef, |
97 |
itemtype => '*', |
104 |
itemtype => undef, |
98 |
rule_name => 'fine', |
105 |
rule_name => 'fine', |
99 |
})->store, 'Given I added an issuing rule branchcode => *, categorycode => *, itemtype => *,'); |
106 |
})->store, 'Given I added an issuing rule branchcode => undef, categorycode => undef, itemtype => undef,'); |
100 |
$rule = Koha::CirculationRules->get_effective_rule({ |
107 |
$rule = Koha::CirculationRules->get_effective_rule({ |
101 |
branchcode => $branchcode, |
108 |
branchcode => $branchcode, |
102 |
categorycode => $categorycode, |
109 |
categorycode => $categorycode, |
103 |
itemtype => $itemtype, |
110 |
itemtype => $itemtype, |
104 |
rule_name => 'fine', |
111 |
rule_name => 'fine', |
105 |
}); |
112 |
}); |
106 |
ok(_row_match($rule, '*', '*', '*'), 'When I attempt to get effective issuing rule,' |
113 |
_is_row_match( |
107 |
.' then the above one is returned.'); |
114 |
$rule, |
|
|
115 |
{ |
116 |
branchcode => undef, |
117 |
categorycode => undef, |
118 |
itemtype => undef |
119 |
}, |
120 |
'When I attempt to get effective issuing rule,' |
121 |
.' then the above one is returned.' |
122 |
); |
108 |
|
123 |
|
109 |
ok(Koha::CirculationRule->new({ |
124 |
ok(Koha::CirculationRule->new({ |
110 |
branchcode => '*', |
125 |
branchcode => undef, |
111 |
categorycode => '*', |
126 |
categorycode => undef, |
112 |
itemtype => $itemtype, |
127 |
itemtype => $itemtype, |
113 |
rule_name => 'fine', |
128 |
rule_name => 'fine', |
114 |
})->store, "Given I added an issuing rule branchcode => *, categorycode => *, itemtype => $itemtype,"); |
129 |
})->store, "Given I added an issuing rule branchcode => undef, categorycode => undef, itemtype => $itemtype,"); |
115 |
$rule = Koha::CirculationRules->get_effective_rule({ |
130 |
$rule = Koha::CirculationRules->get_effective_rule({ |
116 |
branchcode => $branchcode, |
131 |
branchcode => $branchcode, |
117 |
categorycode => $categorycode, |
132 |
categorycode => $categorycode, |
118 |
itemtype => $itemtype, |
133 |
itemtype => $itemtype, |
119 |
rule_name => 'fine', |
134 |
rule_name => 'fine', |
120 |
}); |
135 |
}); |
121 |
ok(_row_match($rule, '*', '*', $itemtype), 'When I attempt to get effective issuing rule,' |
136 |
_is_row_match( |
122 |
.' then the above one is returned.'); |
137 |
$rule, |
|
|
138 |
{ |
139 |
branchcode => undef, |
140 |
categorycode => undef, |
141 |
itemtype => $itemtype |
142 |
}, |
143 |
'When I attempt to get effective issuing rule,' |
144 |
.' then the above one is returned.' |
145 |
); |
123 |
|
146 |
|
124 |
ok(Koha::CirculationRule->new({ |
147 |
ok(Koha::CirculationRule->new({ |
125 |
branchcode => '*', |
148 |
branchcode => undef, |
126 |
categorycode => $categorycode, |
149 |
categorycode => $categorycode, |
127 |
itemtype => '*', |
150 |
itemtype => undef, |
128 |
rule_name => 'fine', |
151 |
rule_name => 'fine', |
129 |
})->store, "Given I added an issuing rule branchcode => *, categorycode => $categorycode, itemtype => *,"); |
152 |
})->store, "Given I added an issuing rule branchcode => undef, categorycode => $categorycode, itemtype => undef,"); |
130 |
$rule = Koha::CirculationRules->get_effective_rule({ |
153 |
$rule = Koha::CirculationRules->get_effective_rule({ |
131 |
branchcode => $branchcode, |
154 |
branchcode => $branchcode, |
132 |
categorycode => $categorycode, |
155 |
categorycode => $categorycode, |
133 |
itemtype => $itemtype, |
156 |
itemtype => $itemtype, |
134 |
rule_name => 'fine', |
157 |
rule_name => 'fine', |
135 |
}); |
158 |
}); |
136 |
ok(_row_match($rule, '*', $categorycode, '*'), 'When I attempt to get effective issuing rule,' |
159 |
_is_row_match( |
137 |
.' then the above one is returned.'); |
160 |
$rule, |
|
|
161 |
{ |
162 |
branchcode => undef, |
163 |
categorycode => $categorycode, |
164 |
itemtype => undef |
165 |
}, |
166 |
'When I attempt to get effective issuing rule,' |
167 |
.' then the above one is returned.' |
168 |
); |
138 |
|
169 |
|
139 |
ok(Koha::CirculationRule->new({ |
170 |
ok(Koha::CirculationRule->new({ |
140 |
branchcode => '*', |
171 |
branchcode => undef, |
141 |
categorycode => $categorycode, |
172 |
categorycode => $categorycode, |
142 |
itemtype => $itemtype, |
173 |
itemtype => $itemtype, |
143 |
rule_name => 'fine', |
174 |
rule_name => 'fine', |
144 |
})->store, "Given I added an issuing rule branchcode => *, categorycode => $categorycode, itemtype => $itemtype,"); |
175 |
})->store, "Given I added an issuing rule branchcode => undef, categorycode => $categorycode, itemtype => $itemtype,"); |
145 |
$rule = Koha::CirculationRules->get_effective_rule({ |
176 |
$rule = Koha::CirculationRules->get_effective_rule({ |
146 |
branchcode => $branchcode, |
177 |
branchcode => $branchcode, |
147 |
categorycode => $categorycode, |
178 |
categorycode => $categorycode, |
148 |
itemtype => $itemtype, |
179 |
itemtype => $itemtype, |
149 |
rule_name => 'fine', |
180 |
rule_name => 'fine', |
150 |
}); |
181 |
}); |
151 |
ok(_row_match($rule, '*', $categorycode, $itemtype), 'When I attempt to get effective issuing rule,' |
182 |
_is_row_match( |
152 |
.' then the above one is returned.'); |
183 |
$rule, |
|
|
184 |
{ |
185 |
branchcode => undef, |
186 |
categorycode => $categorycode, |
187 |
itemtype => $itemtype |
188 |
}, |
189 |
'When I attempt to get effective issuing rule,' |
190 |
.' then the above one is returned.' |
191 |
); |
153 |
|
192 |
|
154 |
ok(Koha::CirculationRule->new({ |
193 |
ok(Koha::CirculationRule->new({ |
155 |
branchcode => $branchcode, |
194 |
branchcode => $branchcode, |
156 |
categorycode => '*', |
195 |
categorycode => undef, |
157 |
itemtype => '*', |
196 |
itemtype => undef, |
158 |
rule_name => 'fine', |
197 |
rule_name => 'fine', |
159 |
})->store, "Given I added an issuing rule branchcode => $branchcode, categorycode => '*', itemtype => '*',"); |
198 |
})->store, "Given I added an issuing rule branchcode => $branchcode, categorycode => undef, itemtype => undef,"); |
160 |
$rule = Koha::CirculationRules->get_effective_rule({ |
199 |
$rule = Koha::CirculationRules->get_effective_rule({ |
161 |
branchcode => $branchcode, |
200 |
branchcode => $branchcode, |
162 |
categorycode => $categorycode, |
201 |
categorycode => $categorycode, |
163 |
itemtype => $itemtype, |
202 |
itemtype => $itemtype, |
164 |
rule_name => 'fine', |
203 |
rule_name => 'fine', |
165 |
}); |
204 |
}); |
166 |
ok(_row_match($rule, $branchcode, '*', '*'), 'When I attempt to get effective issuing rule,' |
205 |
_is_row_match( |
167 |
.' then the above one is returned.'); |
206 |
$rule, |
|
|
207 |
{ |
208 |
branchcode => $branchcode, |
209 |
categorycode => undef, |
210 |
itemtype => undef |
211 |
}, |
212 |
'When I attempt to get effective issuing rule,' |
213 |
.' then the above one is returned.' |
214 |
); |
168 |
|
215 |
|
169 |
ok(Koha::CirculationRule->new({ |
216 |
ok(Koha::CirculationRule->new({ |
170 |
branchcode => $branchcode, |
217 |
branchcode => $branchcode, |
171 |
categorycode => '*', |
218 |
categorycode => undef, |
172 |
itemtype => $itemtype, |
219 |
itemtype => $itemtype, |
173 |
rule_name => 'fine', |
220 |
rule_name => 'fine', |
174 |
})->store, "Given I added an issuing rule branchcode => $branchcode, categorycode => '*', itemtype => $itemtype,"); |
221 |
})->store, "Given I added an issuing rule branchcode => $branchcode, categorycode => undef, itemtype => $itemtype,"); |
175 |
$rule = Koha::CirculationRules->get_effective_rule({ |
222 |
$rule = Koha::CirculationRules->get_effective_rule({ |
176 |
branchcode => $branchcode, |
223 |
branchcode => $branchcode, |
177 |
categorycode => $categorycode, |
224 |
categorycode => $categorycode, |
178 |
itemtype => $itemtype, |
225 |
itemtype => $itemtype, |
179 |
rule_name => 'fine', |
226 |
rule_name => 'fine', |
180 |
}); |
227 |
}); |
181 |
ok(_row_match($rule, $branchcode, '*', $itemtype), 'When I attempt to get effective issuing rule,' |
228 |
_is_row_match( |
182 |
.' then the above one is returned.'); |
229 |
$rule, |
|
|
230 |
{ |
231 |
branchcode => $branchcode, |
232 |
categorycode => undef, |
233 |
itemtype => $itemtype |
234 |
}, |
235 |
'When I attempt to get effective issuing rule,' |
236 |
.' then the above one is returned.' |
237 |
); |
183 |
|
238 |
|
184 |
ok(Koha::CirculationRule->new({ |
239 |
ok(Koha::CirculationRule->new({ |
185 |
branchcode => $branchcode, |
240 |
branchcode => $branchcode, |
186 |
categorycode => $categorycode, |
241 |
categorycode => $categorycode, |
187 |
itemtype => '*', |
242 |
itemtype => undef, |
188 |
rule_name => 'fine', |
243 |
rule_name => 'fine', |
189 |
})->store, "Given I added an issuing rule branchcode => $branchcode, categorycode => $categorycode, itemtype => '*',"); |
244 |
})->store, "Given I added an issuing rule branchcode => $branchcode, categorycode => $categorycode, itemtype => undef,"); |
190 |
$rule = Koha::CirculationRules->get_effective_rule({ |
245 |
$rule = Koha::CirculationRules->get_effective_rule({ |
191 |
branchcode => $branchcode, |
246 |
branchcode => $branchcode, |
192 |
categorycode => $categorycode, |
247 |
categorycode => $categorycode, |
193 |
itemtype => $itemtype, |
248 |
itemtype => $itemtype, |
194 |
rule_name => 'fine', |
249 |
rule_name => 'fine', |
195 |
}); |
250 |
}); |
196 |
ok(_row_match($rule, $branchcode, $categorycode, '*'), 'When I attempt to get effective issuing rule,' |
251 |
_is_row_match( |
197 |
.' then the above one is returned.'); |
252 |
$rule, |
|
|
253 |
{ |
254 |
branchcode => $branchcode, |
255 |
categorycode => $categorycode, |
256 |
itemtype => undef |
257 |
}, |
258 |
'When I attempt to get effective issuing rule,' |
259 |
.' then the above one is returned.' |
260 |
); |
198 |
|
261 |
|
199 |
ok(Koha::CirculationRule->new({ |
262 |
ok(Koha::CirculationRule->new({ |
200 |
branchcode => $branchcode, |
263 |
branchcode => $branchcode, |
Lines 208-215
subtest 'get_effective_issuing_rule' => sub {
Link Here
|
208 |
itemtype => $itemtype, |
271 |
itemtype => $itemtype, |
209 |
rule_name => 'fine', |
272 |
rule_name => 'fine', |
210 |
}); |
273 |
}); |
211 |
ok(_row_match($rule, $branchcode, $categorycode, $itemtype), 'When I attempt to get effective issuing rule,' |
274 |
_is_row_match( |
212 |
.' then the above one is returned.'); |
275 |
$rule, |
|
|
276 |
{ |
277 |
branchcode => $branchcode, |
278 |
categorycode => $categorycode, |
279 |
itemtype => $itemtype |
280 |
}, |
281 |
'When I attempt to get effective issuing rule,' |
282 |
.' then the above one is returned.' |
283 |
); |
213 |
}; |
284 |
}; |
214 |
|
285 |
|
215 |
subtest 'Performance' => sub { |
286 |
subtest 'Performance' => sub { |
Lines 266-324
subtest 'get_effective_issuing_rule' => sub {
Link Here
|
266 |
}; |
337 |
}; |
267 |
}; |
338 |
}; |
268 |
|
339 |
|
269 |
subtest 'get_opacitemholds_policy' => sub { |
340 |
subtest 'set_rule' => sub { |
270 |
plan tests => 4; |
341 |
plan tests => 3; |
271 |
my $itype = $builder->build_object({ class => 'Koha::ItemTypes' }); |
342 |
|
272 |
my $itemtype = $builder->build_object({ class => 'Koha::ItemTypes' }); |
343 |
my $branchcode = $builder->build({ source => 'Branch' })->{'branchcode'}; |
273 |
my $library = $builder->build_object({ class => 'Koha::Libraries' }); |
344 |
my $categorycode = $builder->build({ source => 'Category' })->{'categorycode'}; |
274 |
my $patron = $builder->build_object({ class => 'Koha::Patrons' }); |
345 |
my $itemtype = $builder->build({ source => 'Itemtype' })->{'itemtype'}; |
275 |
my $biblio = $builder->build_object({ class => 'Koha::Biblios' }); |
346 |
|
276 |
my $biblioitem = $builder->build_object( { class => 'Koha::Biblioitems', value => { itemtype => $itemtype->itemtype, biblionumber => $biblio->biblionumber } } ); |
347 |
subtest 'Correct call' => sub { |
277 |
my $item = $builder->build_object( |
348 |
plan tests => 4; |
278 |
{ class => 'Koha::Items', |
349 |
|
279 |
value => { |
350 |
Koha::CirculationRules->delete; |
280 |
homebranch => $library->branchcode, |
351 |
|
281 |
holdingbranch => $library->branchcode, |
352 |
lives_ok( sub { |
282 |
notforloan => 0, |
353 |
Koha::CirculationRules->set_rule( { |
283 |
itemlost => 0, |
354 |
branchcode => $branchcode, |
284 |
withdrawn => 0, |
355 |
rule_name => 'refund', |
285 |
biblionumber => $biblio->biblionumber, |
356 |
rule_value => '', |
286 |
biblioitemnumber => $biblioitem->biblioitemnumber, |
357 |
} ); |
287 |
itype => $itype->itemtype, |
358 |
}, 'setting refund with branch' ); |
288 |
} |
359 |
|
289 |
} |
360 |
lives_ok( sub { |
290 |
); |
361 |
Koha::CirculationRules->set_rule( { |
291 |
|
362 |
branchcode => $branchcode, |
292 |
Koha::IssuingRules->delete; |
363 |
categorycode => $categorycode, |
293 |
Koha::IssuingRule->new({categorycode => '*', itemtype => '*', branchcode => '*', opacitemholds => "N"})->store; |
364 |
rule_name => 'patron_maxissueqty', |
294 |
Koha::IssuingRule->new({categorycode => '*', itemtype => $itype->itemtype, branchcode => '*', opacitemholds => "Y"})->store; |
365 |
rule_value => '', |
295 |
Koha::IssuingRule->new({categorycode => '*', itemtype => $itemtype->itemtype, branchcode => '*', opacitemholds => "N"})->store; |
366 |
} ); |
296 |
t::lib::Mocks::mock_preference('item-level_itypes', 1); |
367 |
}, 'setting patron_maxissueqty with branch/category succeeds' ); |
297 |
my $opacitemholds = Koha::IssuingRules->get_opacitemholds_policy( { item => $item, patron => $patron } ); |
368 |
|
298 |
is ( $opacitemholds, 'Y', 'Patrons can place a hold on this itype'); |
369 |
lives_ok( sub { |
299 |
t::lib::Mocks::mock_preference('item-level_itypes', 0); |
370 |
Koha::CirculationRules->set_rule( { |
300 |
$opacitemholds = Koha::IssuingRules->get_opacitemholds_policy( { item => $item, patron => $patron } ); |
371 |
branchcode => $branchcode, |
301 |
is ( $opacitemholds, 'N', 'Patrons cannot place a hold on this itemtype'); |
372 |
itemtype => $itemtype, |
302 |
|
373 |
rule_name => 'holdallowed', |
303 |
Koha::IssuingRules->delete; |
374 |
rule_value => '', |
304 |
Koha::IssuingRule->new({categorycode => '*', itemtype => '*', branchcode => '*', opacitemholds => "N"})->store; |
375 |
} ); |
305 |
Koha::IssuingRule->new({categorycode => '*', itemtype => $itype->itemtype, branchcode => '*', opacitemholds => "N"})->store; |
376 |
}, 'setting holdallowed with branch/itemtype succeeds' ); |
306 |
Koha::IssuingRule->new({categorycode => '*', itemtype => $itemtype->itemtype, branchcode => '*', opacitemholds => "Y"})->store; |
377 |
|
307 |
t::lib::Mocks::mock_preference('item-level_itypes', 1); |
378 |
lives_ok( sub { |
308 |
$opacitemholds = Koha::IssuingRules->get_opacitemholds_policy( { item => $item, patron => $patron } ); |
379 |
Koha::CirculationRules->set_rule( { |
309 |
is ( $opacitemholds, 'N', 'Patrons cannot place a hold on this itype'); |
380 |
branchcode => $branchcode, |
310 |
t::lib::Mocks::mock_preference('item-level_itypes', 0); |
381 |
categorycode => $categorycode, |
311 |
$opacitemholds = Koha::IssuingRules->get_opacitemholds_policy( { item => $item, patron => $patron } ); |
382 |
itemtype => $itemtype, |
312 |
is ( $opacitemholds, 'Y', 'Patrons can place a hold on this itemtype'); |
383 |
rule_name => 'fine', |
313 |
|
384 |
rule_value => '', |
314 |
$patron->delete; |
385 |
} ); |
|
|
386 |
}, 'setting fine with branch/category/itemtype succeeds' ); |
387 |
}; |
388 |
|
389 |
subtest 'Call with missing params' => sub { |
390 |
plan tests => 4; |
391 |
|
392 |
Koha::CirculationRules->delete; |
393 |
|
394 |
throws_ok( sub { |
395 |
Koha::CirculationRules->set_rule( { |
396 |
rule_name => 'refund', |
397 |
rule_value => '', |
398 |
} ); |
399 |
}, qr/branchcode/, 'setting refund without branch fails' ); |
400 |
|
401 |
throws_ok( sub { |
402 |
Koha::CirculationRules->set_rule( { |
403 |
branchcode => $branchcode, |
404 |
rule_name => 'patron_maxissueqty', |
405 |
rule_value => '', |
406 |
} ); |
407 |
}, qr/categorycode/, 'setting patron_maxissueqty without categorycode fails' ); |
408 |
|
409 |
throws_ok( sub { |
410 |
Koha::CirculationRules->set_rule( { |
411 |
branchcode => $branchcode, |
412 |
rule_name => 'holdallowed', |
413 |
rule_value => '', |
414 |
} ); |
415 |
}, qr/itemtype/, 'setting holdallowed without itemtype fails' ); |
416 |
|
417 |
throws_ok( sub { |
418 |
Koha::CirculationRules->set_rule( { |
419 |
branchcode => $branchcode, |
420 |
categorycode => $categorycode, |
421 |
rule_name => 'fine', |
422 |
rule_value => '', |
423 |
} ); |
424 |
}, qr/itemtype/, 'setting fine without itemtype fails' ); |
425 |
}; |
426 |
|
427 |
subtest 'Call with extra params' => sub { |
428 |
plan tests => 3; |
429 |
|
430 |
Koha::CirculationRules->delete; |
431 |
|
432 |
throws_ok( sub { |
433 |
Koha::CirculationRules->set_rule( { |
434 |
branchcode => $branchcode, |
435 |
categorycode => $categorycode, |
436 |
rule_name => 'refund', |
437 |
rule_value => '', |
438 |
} ); |
439 |
}, qr/categorycode/, 'setting refund with categorycode fails' ); |
440 |
|
441 |
throws_ok( sub { |
442 |
Koha::CirculationRules->set_rule( { |
443 |
branchcode => $branchcode, |
444 |
categorycode => $categorycode, |
445 |
itemtype => $itemtype, |
446 |
rule_name => 'patron_maxissueqty', |
447 |
rule_value => '', |
448 |
} ); |
449 |
}, qr/itemtype/, 'setting patron_maxissueqty with itemtype fails' ); |
450 |
|
451 |
throws_ok( sub { |
452 |
Koha::CirculationRules->set_rule( { |
453 |
branchcode => $branchcode, |
454 |
rule_name => 'holdallowed', |
455 |
categorycode => $categorycode, |
456 |
itemtype => $itemtype, |
457 |
rule_value => '', |
458 |
} ); |
459 |
}, qr/categorycode/, 'setting holdallowed with categorycode fails' ); |
460 |
}; |
315 |
}; |
461 |
}; |
316 |
|
462 |
|
317 |
sub _row_match { |
463 |
sub _is_row_match { |
318 |
my ($rule, $branchcode, $categorycode, $itemtype) = @_; |
464 |
my ( $rule, $expected, $message ) = @_; |
319 |
|
465 |
|
320 |
return $rule->branchcode eq $branchcode && $rule->categorycode eq $categorycode |
466 |
ok( $rule, $message ) ? |
321 |
&& $rule->itemtype eq $itemtype; |
467 |
cmp_methods( $rule, [ %$expected ], $message ) : |
|
|
468 |
fail( $message ); |
322 |
} |
469 |
} |
323 |
|
470 |
|
324 |
$schema->storage->txn_rollback; |
471 |
$schema->storage->txn_rollback; |