From 0624b744e9a4264f9e9f332108bd0032ab7d48dc Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Wed, 19 Jul 2023 11:21:46 +0100 Subject: [PATCH] Bug 33028: Unit tests Add unit tests for is_monetary functionality introduced in the CirculationRules module. Signed-off-by: Martin Renvoize --- t/db_dependent/Koha/CirculationRules.t | 27 ++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/t/db_dependent/Koha/CirculationRules.t b/t/db_dependent/Koha/CirculationRules.t index 18c8653523..e476142ab8 100755 --- a/t/db_dependent/Koha/CirculationRules.t +++ b/t/db_dependent/Koha/CirculationRules.t @@ -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,29 @@ 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( + { + branchcode => '*', + itemtype => '*', + rule_name => $monetary_rule, + rule_value => '10,00', + } + ); + }, + qr//, + "setting $monetary_rule fails when passed value is not decimal" + ); + } + }; + $schema->storage->txn_rollback; }; -- 2.41.0