Bug 33028: Unit tests

Add unit tests for is_monetary functionality introduced in the
CirculationRules module.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit 88ccaaf3ac)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
This commit is contained in:
Martin Renvoize 2023-07-19 11:21:46 +01:00 committed by Fridolin Somers
parent f44e411edb
commit f0d56eb1dc
1 changed files with 26 additions and 2 deletions

View File

@ -153,7 +153,7 @@ subtest 'get_effective_issuing_rule' => sub {
};
subtest 'set_rule' => sub {
plan tests => 3;
plan tests => 4;
$schema->storage->txn_begin;
@ -205,7 +205,7 @@ subtest 'set_rule' => sub {
branchcode => $branchcode,
categorycode => $categorycode,
itemtype => $itemtype,
rule_name => 'fine',
rule_name => 'article_requests',
rule_value => '',
} );
}, 'setting fine with branch/category/itemtype succeeds' );
@ -300,6 +300,30 @@ subtest 'set_rule' => sub {
}, qr/categorycode/, 'setting holdallowed with categorycode fails' );
};
subtest 'Call with badly formatted params' => sub {
plan tests => 4;
Koha::CirculationRules->delete;
foreach my $monetary_rule ( ( 'article_request_fee', 'fine', 'overduefinescap', 'recall_overdue_fine' ) ) {
throws_ok(
sub {
Koha::CirculationRules->set_rule(
{
categorycode => '*',
branchcode => '*',
( $monetary_rule ne 'article_request_fee' ? ( itemtype => '*' ) : () ),
rule_name => $monetary_rule,
rule_value => '10,00',
}
);
},
qr/decimal/,
"setting $monetary_rule fails when passed value is not decimal"
);
}
};
$schema->storage->txn_rollback;
};