Bugzilla – Attachment 53028 Details for
Bug 14048
Change RefundLostItemFeeOnReturn to be branch specific
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 14048: Use mock_preference in tests
Bug-14048-Use-mockpreference-in-tests.patch (text/plain), 4.28 KB, created by
Jonathan Druart
on 2016-07-01 14:48:39 UTC
(
hide
)
Description:
Bug 14048: Use mock_preference in tests
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2016-07-01 14:48:39 UTC
Size:
4.28 KB
patch
obsolete
>From 6c9c55eef94df25f2598ef52704f11fa320edae3 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Sun, 26 Jun 2016 08:19:12 +0100 >Subject: [PATCH] Bug 14048: Use mock_preference in tests > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >--- > t/db_dependent/RefundLostItemFeeRule.t | 24 ++++++++++-------------- > 1 file changed, 10 insertions(+), 14 deletions(-) > >diff --git a/t/db_dependent/RefundLostItemFeeRule.t b/t/db_dependent/RefundLostItemFeeRule.t >index 383fea1..68746e3 100755 >--- a/t/db_dependent/RefundLostItemFeeRule.t >+++ b/t/db_dependent/RefundLostItemFeeRule.t >@@ -175,22 +175,20 @@ subtest 'Koha::RefundLostItemFeeRules::_choose_branch() tests' => sub { > item_home_branch => 'item_home_branch_code' > }; > >- my $syspref = Koha::Config::SysPrefs->find_or_create({ >- variable => 'RefundLostOnReturnControl', >- value => 'CheckinLibrary' }); >+ t::lib::Mocks::mock_preference( 'RefundLostOnReturnControl', 'CheckinLibrary' ); > > is( Koha::RefundLostItemFeeRules->_choose_branch( $params ), > 'current_branch_code', 'CheckinLibrary is honoured'); > >- $syspref->value( 'ItemHomeBranch' )->store; >+ t::lib::Mocks::mock_preference( 'RefundLostOnReturnControl', 'ItemHomeBranch' ); > is( Koha::RefundLostItemFeeRules->_choose_branch( $params ), > 'item_home_branch_code', 'ItemHomeBranch is honoured'); > >- $syspref->value( 'ItemHoldingBranch' )->store; >+ t::lib::Mocks::mock_preference( 'RefundLostOnReturnControl', 'ItemHoldingBranch' ); > is( Koha::RefundLostItemFeeRules->_choose_branch( $params ), > 'item_holding_branch_code', 'ItemHoldingBranch is honoured'); > >- $syspref->value( 'CheckinLibrary' )->store; >+ t::lib::Mocks::mock_preference( 'RefundLostOnReturnControl', 'CheckinLibrary' ); > eval { > Koha::RefundLostItemFeeRules->_choose_branch(); > }; >@@ -199,7 +197,7 @@ subtest 'Koha::RefundLostItemFeeRules::_choose_branch() tests' => sub { > is( $@->message, 'CheckinLibrary requires the current_branch param', > 'Exception message is correct' ); > >- $syspref->value( 'ItemHomeBranch' )->store; >+ t::lib::Mocks::mock_preference( 'RefundLostOnReturnControl', 'ItemHomeBranch' ); > eval { > Koha::RefundLostItemFeeRules->_choose_branch(); > }; >@@ -208,7 +206,7 @@ subtest 'Koha::RefundLostItemFeeRules::_choose_branch() tests' => sub { > is( $@->message, 'ItemHomeBranch requires the item_home_branch param', > 'Exception message is correct' ); > >- $syspref->value( 'ItemHoldingBranch' )->store; >+ t::lib::Mocks::mock_preference( 'RefundLostOnReturnControl', 'ItemHoldingBranch' ); > eval { > Koha::RefundLostItemFeeRules->_choose_branch(); > }; >@@ -228,9 +226,7 @@ subtest 'Koha::RefundLostItemFeeRules::should_refund() tests' => sub { > # Start transaction > $schema->storage->txn_begin; > >- my $syspref = Koha::Config::SysPrefs->find_or_create({ >- variable => 'RefundLostOnReturnControl', >- value => 'CheckinLibrary' }); >+ t::lib::Mocks::mock_preference( 'RefundLostOnReturnControl', 'CheckinLibrary' ); > > $schema->resultset('RefundLostItemFeeRule')->search()->delete; > >@@ -269,17 +265,17 @@ subtest 'Koha::RefundLostItemFeeRules::should_refund() tests' => sub { > item_home_branch => $branch_without_rule > }; > >- $syspref->value( 'CheckinLibrary' )->store; >+ t::lib::Mocks::mock_preference( 'RefundLostOnReturnControl', 'CheckinLibrary' ); > is( Koha::RefundLostItemFeeRules->should_refund( $params ), > 1,'Specific rule is applied (true)'); > >- $syspref->value( 'ItemHomeBranch' )->store; >+ t::lib::Mocks::mock_preference( 'RefundLostOnReturnControl', 'ItemHomeBranch' ); > is( Koha::RefundLostItemFeeRules->should_refund( $params ), > 1,'No rule for branch, global rule applied (true)'); > > # Change the default value just to try > Koha::RefundLostItemFeeRules->find({ branchcode => '*' })->refund(0)->store; >- $syspref->value( 'ItemHoldingBranch' )->store; >+ t::lib::Mocks::mock_preference( 'RefundLostOnReturnControl', 'ItemHoldingBranch' ); > is( Koha::RefundLostItemFeeRules->should_refund( $params ), > 0,'No rule for branch, global rule applied (false)'); > >-- >2.8.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 14048
:
52016
|
52017
|
52018
|
52019
|
52020
|
52169
|
52170
|
52202
|
52203
|
52286
|
52287
|
52288
|
52289
|
52290
|
52291
|
52292
|
52293
|
52306
|
52444
|
52445
|
52446
|
52447
|
52448
|
52449
|
52450
|
52451
|
52482
|
52658
|
52659
|
52660
|
52661
|
52662
|
52663
|
52664
|
52665
|
52666
|
52667
|
52668
|
52748
|
52749
|
52750
|
52751
|
52752
|
52753
|
52754
|
52755
|
52756
|
52757
|
52835
|
52836
|
52837
|
52838
|
52839
|
52840
|
52841
|
52842
|
52843
|
52844
|
52876
|
52883
|
52894
|
53017
|
53018
|
53019
|
53020
|
53021
|
53022
|
53023
|
53024
|
53025
|
53026
|
53027
| 53028 |
53029