Lines 1-6
Link Here
|
1 |
#!/usr/bin/perl |
1 |
#!/usr/bin/perl |
2 |
|
2 |
|
3 |
# Copyright 2018 Koha Development team |
3 |
# Copyright 2020 Koha Development team |
4 |
# |
4 |
# |
5 |
# This file is part of Koha |
5 |
# This file is part of Koha |
6 |
# |
6 |
# |
Lines 19-31
Link Here
|
19 |
|
19 |
|
20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
21 |
|
21 |
|
22 |
use Test::More tests => 2; |
22 |
use Test::More tests => 3; |
23 |
use Test::Exception; |
23 |
use Test::Exception; |
24 |
|
24 |
|
25 |
use Koha::CirculationRules; |
25 |
use Koha::CirculationRules; |
26 |
use Koha::Database; |
26 |
use Koha::Database; |
27 |
|
27 |
|
28 |
use t::lib::TestBuilder; |
28 |
use t::lib::TestBuilder; |
|
|
29 |
use t::lib::Mocks; |
29 |
|
30 |
|
30 |
my $schema = Koha::Database->new->schema; |
31 |
my $schema = Koha::Database->new->schema; |
31 |
my $builder = t::lib::TestBuilder->new; |
32 |
my $builder = t::lib::TestBuilder->new; |
Lines 282-284
subtest 'get_onshelfholds_policy() tests' => sub {
Link Here
|
282 |
|
283 |
|
283 |
$schema->storage->txn_rollback; |
284 |
$schema->storage->txn_rollback; |
284 |
}; |
285 |
}; |
285 |
- |
286 |
|
|
|
287 |
subtest 'get_useDaysMode_effective_value' => sub { |
288 |
plan tests => 4; |
289 |
|
290 |
$schema->storage->txn_begin; |
291 |
|
292 |
my $item_1 = $builder->build_sample_item(); |
293 |
my $item_2 = $builder->build_sample_item(); |
294 |
|
295 |
my $circ_rules = |
296 |
Koha::CirculationRules->search( { rule_name => 'useDaysMode' } )->delete; |
297 |
|
298 |
# Default value 'Datedue' at pref level |
299 |
t::lib::Mocks::mock_preference( 'useDaysMode', 'Datedue' ); |
300 |
|
301 |
is( |
302 |
Koha::CirculationRules->get_useDaysMode_effective_value( |
303 |
{ |
304 |
categorycode => undef, |
305 |
itemtype => $item_1->effective_itemtype, |
306 |
branchcode => undef |
307 |
} |
308 |
), |
309 |
'Datedue', |
310 |
'useDaysMode default to pref value if the rule does not exist' |
311 |
); |
312 |
|
313 |
Koha::CirculationRules->set_rule( |
314 |
{ |
315 |
branchcode => '*', |
316 |
categorycode => '*', |
317 |
itemtype => '*', |
318 |
rule_name => 'useDaysMode', |
319 |
rule_value => 'Calendar', |
320 |
} |
321 |
); |
322 |
Koha::CirculationRules->set_rule( |
323 |
{ |
324 |
branchcode => '*', |
325 |
categorycode => '*', |
326 |
itemtype => $item_1->effective_itemtype, |
327 |
rule_name => 'useDaysMode', |
328 |
rule_value => 'Days', |
329 |
} |
330 |
); |
331 |
|
332 |
is( |
333 |
Koha::CirculationRules->get_useDaysMode_effective_value( |
334 |
{ |
335 |
categorycode => undef, |
336 |
itemtype => $item_1->effective_itemtype, |
337 |
branchcode => undef |
338 |
} |
339 |
), |
340 |
'Days', |
341 |
"useDaysMode for item_1 is the specific rule" |
342 |
); |
343 |
is( |
344 |
Koha::CirculationRules->get_useDaysMode_effective_value( |
345 |
{ |
346 |
categorycode => undef, |
347 |
itemtype => $item_2->effective_itemtype, |
348 |
branchcode => undef |
349 |
} |
350 |
), |
351 |
'Calendar', |
352 |
"useDaysMode for item_2 is the one defined for the default circ rule" |
353 |
); |
354 |
|
355 |
Koha::CirculationRules->set_rule( |
356 |
{ |
357 |
branchcode => '*', |
358 |
categorycode => '*', |
359 |
itemtype => $item_2->effective_itemtype, |
360 |
rule_name => 'useDaysMode', |
361 |
rule_value => '', |
362 |
} |
363 |
); |
364 |
|
365 |
is( |
366 |
Koha::CirculationRules->get_useDaysMode_effective_value( |
367 |
{ |
368 |
categorycode => undef, |
369 |
itemtype => $item_2->effective_itemtype, |
370 |
branchcode => undef |
371 |
} |
372 |
), |
373 |
'Datedue', |
374 |
'useDaysMode default to pref value if the rule exists but set to""' |
375 |
); |
376 |
|
377 |
$schema->storage->txn_rollback; |
378 |
}; |