Bugzilla – Attachment 107332 Details for
Bug 25663
Koha::RefundLostItemFeeRules should be merged into Koha::CirculationRules
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 25663: Add unit tests
Bug-25663-Add-unit-tests.patch (text/plain), 5.55 KB, created by
Martin Renvoize (ashimema)
on 2020-07-24 12:14:41 UTC
(
hide
)
Description:
Bug 25663: Add unit tests
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2020-07-24 12:14:41 UTC
Size:
5.55 KB
patch
obsolete
>From d76db9fd8811eee1ff0b95b244bf705165208943 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Wed, 3 Jun 2020 14:13:22 +0100 >Subject: [PATCH] Bug 25663: Add unit tests > >This patch adds unit tests for a new get_lostretun_policy method which >is getting added to Koha::CirculationRules. > >Test plan: >1/ Read the additions to t/db_dependent/CirculationRules.t code > and compare to the t/db_dependent/RefundLostItemFeeRule.t. >2/ Run the test after applying the patch that adds the new method >3/ If the tests all pass, signoff > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > t/db_dependent/Koha/CirculationRules.t | 127 ++++++++++++++++++++++++- > 1 file changed, 126 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Koha/CirculationRules.t b/t/db_dependent/Koha/CirculationRules.t >index f24542e2b6..1473c235d7 100644 >--- a/t/db_dependent/Koha/CirculationRules.t >+++ b/t/db_dependent/Koha/CirculationRules.t >@@ -19,12 +19,13 @@ > > use Modern::Perl; > >-use Test::More tests => 3; >+use Test::More tests => 4; > use Test::Exception; > > use Koha::CirculationRules; > use Koha::Database; > >+use t::lib::Mocks; > use t::lib::TestBuilder; > use t::lib::Mocks; > >@@ -376,3 +377,127 @@ subtest 'get_effective_daysmode' => sub { > > $schema->storage->txn_rollback; > }; >+ >+subtest 'get_lostreturn_policy() tests' => sub { >+ plan tests => 6; >+ >+ $schema->storage->txn_begin; >+ >+ $schema->resultset('CirculationRule')->search()->delete; >+ >+ my $default_rule = $builder->build( >+ { >+ source => 'CirculationRule', >+ value => { >+ branchcode => undef, >+ categorycode => undef, >+ itemtype => undef, >+ rule_name => 'refund', >+ rule_value => 1 >+ } >+ } >+ ); >+ my $branchcode = $builder->build( { source => 'Branch' } )->{branchcode}; >+ my $specific_rule_false = $builder->build( >+ { >+ source => 'CirculationRule', >+ value => { >+ branchcode => $branchcode, >+ categorycode => undef, >+ itemtype => undef, >+ rule_name => 'refund', >+ rule_value => 0 >+ } >+ } >+ ); >+ my $branchcode2 = $builder->build( { source => 'Branch' } )->{branchcode}; >+ my $specific_rule_true = $builder->build( >+ { >+ source => 'CirculationRule', >+ value => { >+ branchcode => $branchcode2, >+ categorycode => undef, >+ itemtype => undef, >+ rule_name => 'refund', >+ rule_value => 1 >+ } >+ } >+ ); >+ # Make sure we have an unused branchcode >+ my $branchcode3 = $builder->build( { source => 'Branch' } )->{branchcode}; >+ my $specific_rule_dummy = $builder->build( >+ { >+ source => 'CirculationRule', >+ value => { >+ branchcode => $branchcode3, >+ categorycode => undef, >+ itemtype => undef, >+ rule_name => 'refund', >+ } >+ } >+ ); >+ my $branch_without_rule = $specific_rule_dummy->{ branchcode }; >+ Koha::CirculationRules >+ ->search( >+ { >+ branchcode => $branch_without_rule, >+ categorycode => undef, >+ itemtype => undef, >+ rule_name => 'refund' >+ } >+ ) >+ ->next >+ ->delete; >+ >+ my $item = $builder->build_sample_item( >+ { >+ homebranch => $specific_rule_true->{branchcode}, >+ holdingbranch => $specific_rule_false->{branchcode} >+ } >+ ); >+ my $params = { >+ return_branch => $specific_rule_true->{ 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)'); >+ >+ t::lib::Mocks::mock_preference( 'RefundLostOnReturnControl', 'ItemHomeBranch' ); >+ is( Koha::CirculationRules->get_lostreturn_policy( $params ), >+ 1,'Specific rule for home branch is applied (true)'); >+ >+ t::lib::Mocks::mock_preference( 'RefundLostOnReturnControl', 'ItemHoldingBranch' ); >+ is( Koha::CirculationRules->get_lostreturn_policy( $params ), >+ 0,'Specific rule for holoding 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)'); >+ >+ # Change the default value just to try >+ Koha::CirculationRules->search({ branchcode => undef, rule_name => 'refund' })->next->rule_value(0)->store; >+ is( Koha::CirculationRules->get_lostreturn_policy( $params ), >+ 0,'No rule for branch, global rule applied (false)'); >+ >+ # No default rule defined check >+ Koha::CirculationRules >+ ->search( >+ { >+ branchcode => undef, >+ categorycode => undef, >+ itemtype => undef, >+ rule_name => 'refund' >+ } >+ ) >+ ->next >+ ->delete; >+ is( Koha::CirculationRules->get_lostreturn_policy( $params ), >+ 1,'No rule for branch, no default rule, fallback default (true)'); >+ >+ $schema->storage->txn_rollback; >+}; >-- >2.20.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 25663
:
105524
|
105525
|
105526
|
105527
|
106105
|
106106
|
106107
|
106108
|
106823
|
106824
|
106825
|
107332
|
107333
|
107334
|
108069
|
108070
|
108071
|
111309