From b3b62a5e1e3f1025530f1638ec6b2dc010d4d493 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Wed, 19 Jul 2023 12:11:50 +0100 Subject: [PATCH] Bug 32271: Unit test Add a unit test for the allow blank option added to the monetary check in CirculationRules. Signed-off-by: Martin Renvoize Signed-off-by: Tomas Cohen Arazi (cherry picked from commit 41274ef7516ad09f1f9a5e6723ba7bd53379dd02) Signed-off-by: Fridolin Somers (cherry picked from commit 8d02637bec9848077bec53abfa449fd158ac12c0) Signed-off-by: Pedro Amorim --- t/db_dependent/Koha/CirculationRules.t | 30 +++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/t/db_dependent/Koha/CirculationRules.t b/t/db_dependent/Koha/CirculationRules.t index 7c8ec68cde..90eb827aff 100755 --- a/t/db_dependent/Koha/CirculationRules.t +++ b/t/db_dependent/Koha/CirculationRules.t @@ -441,7 +441,7 @@ subtest 'clone' => sub { }; subtest 'set_rule + get_effective_rule' => sub { - plan tests => 9; + plan tests => 10; $schema->storage->txn_begin; @@ -534,6 +534,30 @@ subtest 'set_rule + get_effective_rule' => sub { } }; + subtest 'test rules that can be blank' => sub { + plan tests => 1; + foreach my $blank_rule ( ('overduefinescap') ) { + Koha::CirculationRules->set_rule( + { + branchcode => $branchcode, + categorycode => '*', + itemtype => '*', + rule_name => $blank_rule, + rule_value => '', + } + ); + + $rule = Koha::CirculationRules->get_effective_rule( + { + branchcode => $branchcode, + categorycode => undef, + itemtype => undef, + rule_name => $blank_rule, + } + ); + is( $rule->rule_value, '', "$blank_rule allowed to be set to blank" ); + } + }; subtest 'test rule matching with different combinations of rule scopes' => sub { my ( $tests, $order ) = _prepare_tests_for_rule_scope_combinations( @@ -575,9 +599,9 @@ subtest 'set_rule + get_effective_rule' => sub { }; my $our_branch_rules = Koha::CirculationRules->search({branchcode => $branchcode}); - is( $our_branch_rules->count, 4, "We added 8 rules"); + is( $our_branch_rules->count, 5, "We added 9 rules"); $our_branch_rules->delete; - is( $our_branch_rules->count, 0, "We deleted 8 rules"); + is( $our_branch_rules->count, 0, "We deleted 9 rules"); $schema->storage->txn_rollback; }; -- 2.20.1