Lines 19-25
Link Here
|
19 |
|
19 |
|
20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
21 |
|
21 |
|
22 |
use Test::More tests => 3; |
22 |
use Test::More tests => 4; |
23 |
use Test::Exception; |
23 |
use Test::Exception; |
24 |
|
24 |
|
25 |
use Koha::CirculationRules; |
25 |
use Koha::CirculationRules; |
Lines 376-378
subtest 'get_effective_daysmode' => sub {
Link Here
|
376 |
|
376 |
|
377 |
$schema->storage->txn_rollback; |
377 |
$schema->storage->txn_rollback; |
378 |
}; |
378 |
}; |
379 |
- |
379 |
|
|
|
380 |
subtest 'set_rules() tests' => sub { |
381 |
plan tests => 1; |
382 |
|
383 |
subtest 'scope validation' => sub { |
384 |
plan tests => 6; |
385 |
|
386 |
$schema->storage->txn_begin; |
387 |
|
388 |
my $categorycode = $builder->build_object( { |
389 |
class => 'Koha::Patron::Categories' } )->categorycode; |
390 |
my $itemtype = $builder->build_object( { |
391 |
class => 'Koha::ItemTypes' } )->itemtype; |
392 |
my $branchcode = $builder->build_object( { |
393 |
class => 'Koha::Libraries' } )->branchcode; |
394 |
|
395 |
my $rule; |
396 |
Koha::CirculationRules->delete; |
397 |
|
398 |
is( scalar @{Koha::CirculationRules->set_rules( { |
399 |
branchcode => $branchcode, |
400 |
categorycode => $categorycode, |
401 |
itemtype => $itemtype, |
402 |
rules => { |
403 |
refund => 1, |
404 |
patron_maxissueqty => 2, |
405 |
holdallowed => 3, |
406 |
article_requests => 4, |
407 |
maxissueqty => 5, |
408 |
} |
409 |
} )}, 5, 'All rules added' ); |
410 |
|
411 |
is( Koha::CirculationRules->get_effective_rule( { |
412 |
branchcode => $branchcode, |
413 |
rule_name => 'refund' |
414 |
} )->rule_value, 1, 'Found rule refund' ); |
415 |
|
416 |
is( Koha::CirculationRules->get_effective_rule( { |
417 |
branchcode => $branchcode, |
418 |
categorycode => $categorycode, |
419 |
rule_name => 'patron_maxissueqty' |
420 |
} )->rule_value, 2, 'Found rule patron_maxissueqty' ); |
421 |
|
422 |
is( Koha::CirculationRules->get_effective_rule( { |
423 |
branchcode => $branchcode, |
424 |
itemtype => $itemtype, |
425 |
rule_name => 'holdallowed' |
426 |
} )->rule_value, 3, 'Found rule holdallowed' ); |
427 |
|
428 |
is( Koha::CirculationRules->get_effective_rule( { |
429 |
branchcode => $branchcode, |
430 |
categorycode => $categorycode, |
431 |
itemtype => $itemtype, |
432 |
rule_name => 'article_requests' |
433 |
} )->rule_value, 4, 'Found rule article_requests' ); |
434 |
|
435 |
is( Koha::CirculationRules->get_effective_rule( { |
436 |
branchcode => $branchcode, |
437 |
categorycode => $categorycode, |
438 |
itemtype => $itemtype, |
439 |
rule_name => 'maxissueqty' |
440 |
} )->rule_value, 5, 'Found rule maxissueqty' ); |
441 |
|
442 |
$schema->storage->txn_rollback; |
443 |
}; |
444 |
}; |