From 20d3308d4fb2a7b8933203310b415b815e627211 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Wed, 3 Jun 2020 16:25:31 +0100 Subject: [PATCH] Bug 23091: Update unit test This patch updates the unit test for get_lostreturn_policy to reflect the rule_name and return code changes. --- t/db_dependent/Koha/CirculationRules.t | 36 ++++++++++++++------------ 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/t/db_dependent/Koha/CirculationRules.t b/t/db_dependent/Koha/CirculationRules.t index 24fc39abf9..ebeab106a5 100644 --- a/t/db_dependent/Koha/CirculationRules.t +++ b/t/db_dependent/Koha/CirculationRules.t @@ -298,8 +298,8 @@ subtest 'get_lostreturn_policy() tests' => sub { branchcode => undef, categorycode => undef, itemtype => undef, - rule_name => 'refund', - rule_value => 1 + rule_name => 'lostreturn', + rule_value => 'charge' } } ); @@ -311,21 +311,21 @@ subtest 'get_lostreturn_policy() tests' => sub { branchcode => $branchcode, categorycode => undef, itemtype => undef, - rule_name => 'refund', + rule_name => 'lostreturn', rule_value => 0 } } ); my $branchcode2 = $builder->build( { source => 'Branch' } )->{branchcode}; - my $specific_rule_true = $builder->build( + my $specific_rule_refund = $builder->build( { source => 'CirculationRule', value => { branchcode => $branchcode2, categorycode => undef, itemtype => undef, - rule_name => 'refund', - rule_value => 1 + rule_name => 'lostreturn', + rule_value => 'refund' } } ); @@ -338,7 +338,8 @@ subtest 'get_lostreturn_policy() tests' => sub { branchcode => $branchcode3, categorycode => undef, itemtype => undef, - rule_name => 'refund', + rule_name => 'lostreturn', + rule_value => 'restore' } } ); @@ -349,7 +350,8 @@ subtest 'get_lostreturn_policy() tests' => sub { branchcode => $branch_without_rule, categorycode => undef, itemtype => undef, - rule_name => 'refund' + rule_name => 'lostreturn', + rule_value => 'restore' } ) ->next @@ -357,36 +359,36 @@ subtest 'get_lostreturn_policy() tests' => sub { my $item = $builder->build_sample_item( { - homebranch => $specific_rule_true->{branchcode}, + homebranch => $specific_rule_refund->{branchcode}, holdingbranch => $specific_rule_false->{branchcode} } ); my $params = { - return_branch => $specific_rule_true->{ branchcode }, + return_branch => $specific_rule_refund->{ branchcode }, item => $item }; # Specific rules t::lib::Mocks::mock_preference( 'RefundLostOnReturnControl', 'CheckinLibrary' ); is( Koha::CirculationRules->get_lostreturn_policy( $params ), - 1,'Specific rule for checkin branch is applied (true)'); + 'refund','Specific rule for checkin branch is applied (refund)'); t::lib::Mocks::mock_preference( 'RefundLostOnReturnControl', 'ItemHomeBranch' ); is( Koha::CirculationRules->get_lostreturn_policy( $params ), - 1,'Specific rule for home branch is applied (true)'); + 'refund','Specific rule for home branch is applied (refund)'); t::lib::Mocks::mock_preference( 'RefundLostOnReturnControl', 'ItemHoldingBranch' ); is( Koha::CirculationRules->get_lostreturn_policy( $params ), - 0,'Specific rule for holoding branch is applied (false)'); + 0,'Specific rule for holding branch is applied (false)'); # Default rule check t::lib::Mocks::mock_preference( 'RefundLostOnReturnControl', 'CheckinLibrary' ); $params->{return_branch} = $branch_without_rule; is( Koha::CirculationRules->get_lostreturn_policy( $params ), - 1,'No rule for branch, global rule applied (true)'); + 'charge','No rule for branch, global rule applied (charge)'); # Change the default value just to try - Koha::CirculationRules->search({ branchcode => undef, rule_name => 'refund' })->next->rule_value(0)->store; + Koha::CirculationRules->search({ branchcode => undef, rule_name => 'lostreturn' })->next->rule_value(0)->store; is( Koha::CirculationRules->get_lostreturn_policy( $params ), 0,'No rule for branch, global rule applied (false)'); @@ -397,13 +399,13 @@ subtest 'get_lostreturn_policy() tests' => sub { branchcode => undef, categorycode => undef, itemtype => undef, - rule_name => 'refund' + rule_name => 'lostreturn' } ) ->next ->delete; is( Koha::CirculationRules->get_lostreturn_policy( $params ), - 1,'No rule for branch, no default rule, fallback default (true)'); + 'refund','No rule for branch, no default rule, fallback default (refund)'); $schema->storage->txn_rollback; }; -- 2.20.1