From 7739364c58894e3affcb07f2c4c28d5172e16eeb 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 | 28 ++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/t/db_dependent/Koha/CirculationRules.t b/t/db_dependent/Koha/CirculationRules.t index 18c8653523..7c8ec68cde 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,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; }; -- 2.41.0