Bugzilla – Attachment 110661 Details for
Bug 23091
Add options to charge new or restore forgiven overdues when a lost item is returned
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 23091: Update unit test
Bug-23091-Update-unit-test.patch (text/plain), 9.82 KB, created by
Martin Renvoize (ashimema)
on 2020-09-24 14:09:29 UTC
(
hide
)
Description:
Bug 23091: Update unit test
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2020-09-24 14:09:29 UTC
Size:
9.82 KB
patch
obsolete
>From e4846d2b28d1ebbc9b015584eb22bb60f8b3e3dc Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >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. > >Test plan: >1/ Read the code changes in t/db_dependant/Koha/CirculationRules and >t/db_dependant/Koha/IssuingRules and confirm they make sense. >2/ Run the updated tests and ensure they pass. > >Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com> >--- > t/db_dependent/Circulation.t | 8 ++-- > t/db_dependent/Koha/CirculationRules.t | 60 ++++++++++++++++---------- > t/db_dependent/Koha/IssuingRules.t | 12 +++--- > 3 files changed, 48 insertions(+), 32 deletions(-) > >diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t >index f26f2f3255..9dfc5b4de9 100755 >--- a/t/db_dependent/Circulation.t >+++ b/t/db_dependent/Circulation.t >@@ -3658,8 +3658,8 @@ subtest 'Tests for NoRefundOnLostReturnedItemsAge with AddReturn' => sub { > branchcode => undef, > categorycode => undef, > itemtype => undef, >- rule_name => 'refund', >- rule_value => 1 >+ rule_name => 'lostreturn', >+ rule_value => 'refund' > } > } > ); >@@ -3851,8 +3851,8 @@ subtest 'Tests for NoRefundOnLostReturnedItemsAge with AddIssue' => sub { > branchcode => undef, > categorycode => undef, > itemtype => undef, >- rule_name => 'refund', >- rule_value => 1 >+ rule_name => 'lostreturn', >+ rule_value => 'refund' > } > } > ); >diff --git a/t/db_dependent/Koha/CirculationRules.t b/t/db_dependent/Koha/CirculationRules.t >index 708168a048..93faa7bf05 100755 >--- a/t/db_dependent/Koha/CirculationRules.t >+++ b/t/db_dependent/Koha/CirculationRules.t >@@ -279,15 +279,15 @@ subtest 'get_lostreturn_policy() tests' => sub { > > $schema->resultset('CirculationRule')->search()->delete; > >- my $default_rule = $builder->build( >+ my $default_rule_charge = $builder->build( > { > source => 'CirculationRule', > value => { > branchcode => undef, > categorycode => undef, > itemtype => undef, >- rule_name => 'refund', >- rule_value => 1 >+ rule_name => 'lostreturn', >+ rule_value => 'charge' > } > } > ); >@@ -299,34 +299,49 @@ 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' > } > } > ); >- # Make sure we have an unused branchcode > my $branchcode3 = $builder->build( { source => 'Branch' } )->{branchcode}; >- my $specific_rule_dummy = $builder->build( >+ my $specific_rule_restore = $builder->build( > { > source => 'CirculationRule', > value => { > branchcode => $branchcode3, > categorycode => undef, > itemtype => undef, >- rule_name => 'refund', >+ rule_name => 'lostreturn', >+ rule_value => 'restore' >+ } >+ } >+ ); >+ >+ # Make sure we have an unused branchcode >+ my $branchcode4 = $builder->build( { source => 'Branch' } )->{branchcode}; >+ my $specific_rule_dummy = $builder->build( >+ { >+ source => 'CirculationRule', >+ value => { >+ branchcode => $branchcode4, >+ categorycode => undef, >+ itemtype => undef, >+ rule_name => 'lostreturn', >+ rule_value => 'refund' > } > } > ); >@@ -337,7 +352,8 @@ subtest 'get_lostreturn_policy() tests' => sub { > branchcode => $branch_without_rule, > categorycode => undef, > itemtype => undef, >- rule_name => 'refund' >+ rule_name => 'lostreturn', >+ rule_value => 'refund' > } > ) > ->next >@@ -345,36 +361,36 @@ subtest 'get_lostreturn_policy() tests' => sub { > > my $item = $builder->build_sample_item( > { >- homebranch => $specific_rule_false->{branchcode}, >- holdingbranch => $specific_rule_true->{branchcode} >+ homebranch => $specific_rule_restore->{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 ), >- 0,'Specific rule for home branch is applied (false)'); >+ 'restore','Specific rule for home branch is applied (restore)'); > > t::lib::Mocks::mock_preference( 'RefundLostOnReturnControl', 'ItemHoldingBranch' ); > is( Koha::CirculationRules->get_lostreturn_policy( $params ), >- 1,'Specific rule for holding branch is applied (true)'); >+ 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)'); > >@@ -385,18 +401,18 @@ 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)'); > > # Fallback to ItemHoldBranch if CheckinLibrary is undefined > $params->{return_branch} = undef; > is( Koha::CirculationRules->get_lostreturn_policy( $params ), >- 0,'return_branch undefined, fallback to ItemHomeBranch rule (false)'); >+ 'restore','return_branch undefined, fallback to ItemHomeBranch rule (restore)'); > > $schema->storage->txn_rollback; > }; >diff --git a/t/db_dependent/Koha/IssuingRules.t b/t/db_dependent/Koha/IssuingRules.t >index 31abe27c4c..afcb2867b7 100755 >--- a/t/db_dependent/Koha/IssuingRules.t >+++ b/t/db_dependent/Koha/IssuingRules.t >@@ -163,10 +163,10 @@ subtest 'set_rule' => sub { > lives_ok( sub { > Koha::CirculationRules->set_rule( { > branchcode => $branchcode, >- rule_name => 'refund', >+ rule_name => 'lostreturn', > rule_value => '', > } ); >- }, 'setting refund with branch' ); >+ }, 'setting lostreturn with branch' ); > > lives_ok( sub { > Koha::CirculationRules->set_rule( { >@@ -204,10 +204,10 @@ subtest 'set_rule' => sub { > > throws_ok( sub { > Koha::CirculationRules->set_rule( { >- rule_name => 'refund', >+ rule_name => 'lostreturn', > rule_value => '', > } ); >- }, qr/branchcode/, 'setting refund without branch fails' ); >+ }, qr/branchcode/, 'setting lostreturn without branch fails' ); > > throws_ok( sub { > Koha::CirculationRules->set_rule( { >@@ -244,10 +244,10 @@ subtest 'set_rule' => sub { > Koha::CirculationRules->set_rule( { > branchcode => $branchcode, > categorycode => $categorycode, >- rule_name => 'refund', >+ rule_name => 'lostreturn', > rule_value => '', > } ); >- }, qr/categorycode/, 'setting refund with categorycode fails' ); >+ }, qr/categorycode/, 'setting lostreturn with categorycode fails' ); > > throws_ok( sub { > Koha::CirculationRules->set_rule( { >-- >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 23091
:
96217
|
105529
|
105530
|
105531
|
105544
|
105545
|
105546
|
105547
|
105567
|
105649
|
106871
|
106872
|
106873
|
106874
|
106875
|
106876
|
106906
|
106907
|
106908
|
106909
|
106910
|
106911
|
106912
|
106961
|
107026
|
107027
|
107028
|
107029
|
107030
|
107031
|
107032
|
107033
|
107034
|
107100
|
107101
|
107102
|
107103
|
107104
|
107105
|
107106
|
107107
|
107108
|
107335
|
107336
|
107337
|
107338
|
107339
|
107340
|
107341
|
107342
|
107343
|
108718
|
108719
|
108720
|
108721
|
108722
|
108723
|
108724
|
109571
|
109572
|
109573
|
109574
|
109575
|
109576
|
109577
|
110660
|
110661
|
110662
|
110663
|
110664
|
110665
|
110666
|
110667
|
110720
|
110721
|
110722
|
110723
|
110724
|
110725
|
110726
|
110727
|
111501
|
111502
|
111503
|
111504
|
111505
|
111506
|
111507
|
111508
|
111935
|
111936
|
111965
|
111979
|
111980
|
111981
|
111982
|
111983
|
111984
|
111985
|
111986
|
111987
|
111988
|
111989
|
113081
|
113082
|
113083
|
113084
|
113085
|
113086
|
113087
|
113088
|
113089
|
113090
|
113091