Lines 175-196
subtest 'Koha::RefundLostItemFeeRules::_choose_branch() tests' => sub {
Link Here
|
175 |
item_home_branch => 'item_home_branch_code' |
175 |
item_home_branch => 'item_home_branch_code' |
176 |
}; |
176 |
}; |
177 |
|
177 |
|
178 |
my $syspref = Koha::Config::SysPrefs->find_or_create({ |
178 |
t::lib::Mocks::mock_preference( 'RefundLostOnReturnControl', 'CheckinLibrary' ); |
179 |
variable => 'RefundLostOnReturnControl', |
|
|
180 |
value => 'CheckinLibrary' }); |
181 |
|
179 |
|
182 |
is( Koha::RefundLostItemFeeRules->_choose_branch( $params ), |
180 |
is( Koha::RefundLostItemFeeRules->_choose_branch( $params ), |
183 |
'current_branch_code', 'CheckinLibrary is honoured'); |
181 |
'current_branch_code', 'CheckinLibrary is honoured'); |
184 |
|
182 |
|
185 |
$syspref->value( 'ItemHomeBranch' )->store; |
183 |
t::lib::Mocks::mock_preference( 'RefundLostOnReturnControl', 'ItemHomeBranch' ); |
186 |
is( Koha::RefundLostItemFeeRules->_choose_branch( $params ), |
184 |
is( Koha::RefundLostItemFeeRules->_choose_branch( $params ), |
187 |
'item_home_branch_code', 'ItemHomeBranch is honoured'); |
185 |
'item_home_branch_code', 'ItemHomeBranch is honoured'); |
188 |
|
186 |
|
189 |
$syspref->value( 'ItemHoldingBranch' )->store; |
187 |
t::lib::Mocks::mock_preference( 'RefundLostOnReturnControl', 'ItemHoldingBranch' ); |
190 |
is( Koha::RefundLostItemFeeRules->_choose_branch( $params ), |
188 |
is( Koha::RefundLostItemFeeRules->_choose_branch( $params ), |
191 |
'item_holding_branch_code', 'ItemHoldingBranch is honoured'); |
189 |
'item_holding_branch_code', 'ItemHoldingBranch is honoured'); |
192 |
|
190 |
|
193 |
$syspref->value( 'CheckinLibrary' )->store; |
191 |
t::lib::Mocks::mock_preference( 'RefundLostOnReturnControl', 'CheckinLibrary' ); |
194 |
eval { |
192 |
eval { |
195 |
Koha::RefundLostItemFeeRules->_choose_branch(); |
193 |
Koha::RefundLostItemFeeRules->_choose_branch(); |
196 |
}; |
194 |
}; |
Lines 199-205
subtest 'Koha::RefundLostItemFeeRules::_choose_branch() tests' => sub {
Link Here
|
199 |
is( $@->message, 'CheckinLibrary requires the current_branch param', |
197 |
is( $@->message, 'CheckinLibrary requires the current_branch param', |
200 |
'Exception message is correct' ); |
198 |
'Exception message is correct' ); |
201 |
|
199 |
|
202 |
$syspref->value( 'ItemHomeBranch' )->store; |
200 |
t::lib::Mocks::mock_preference( 'RefundLostOnReturnControl', 'ItemHomeBranch' ); |
203 |
eval { |
201 |
eval { |
204 |
Koha::RefundLostItemFeeRules->_choose_branch(); |
202 |
Koha::RefundLostItemFeeRules->_choose_branch(); |
205 |
}; |
203 |
}; |
Lines 208-214
subtest 'Koha::RefundLostItemFeeRules::_choose_branch() tests' => sub {
Link Here
|
208 |
is( $@->message, 'ItemHomeBranch requires the item_home_branch param', |
206 |
is( $@->message, 'ItemHomeBranch requires the item_home_branch param', |
209 |
'Exception message is correct' ); |
207 |
'Exception message is correct' ); |
210 |
|
208 |
|
211 |
$syspref->value( 'ItemHoldingBranch' )->store; |
209 |
t::lib::Mocks::mock_preference( 'RefundLostOnReturnControl', 'ItemHoldingBranch' ); |
212 |
eval { |
210 |
eval { |
213 |
Koha::RefundLostItemFeeRules->_choose_branch(); |
211 |
Koha::RefundLostItemFeeRules->_choose_branch(); |
214 |
}; |
212 |
}; |
Lines 228-236
subtest 'Koha::RefundLostItemFeeRules::should_refund() tests' => sub {
Link Here
|
228 |
# Start transaction |
226 |
# Start transaction |
229 |
$schema->storage->txn_begin; |
227 |
$schema->storage->txn_begin; |
230 |
|
228 |
|
231 |
my $syspref = Koha::Config::SysPrefs->find_or_create({ |
229 |
t::lib::Mocks::mock_preference( 'RefundLostOnReturnControl', 'CheckinLibrary' ); |
232 |
variable => 'RefundLostOnReturnControl', |
|
|
233 |
value => 'CheckinLibrary' }); |
234 |
|
230 |
|
235 |
$schema->resultset('RefundLostItemFeeRule')->search()->delete; |
231 |
$schema->resultset('RefundLostItemFeeRule')->search()->delete; |
236 |
|
232 |
|
Lines 269-285
subtest 'Koha::RefundLostItemFeeRules::should_refund() tests' => sub {
Link Here
|
269 |
item_home_branch => $branch_without_rule |
265 |
item_home_branch => $branch_without_rule |
270 |
}; |
266 |
}; |
271 |
|
267 |
|
272 |
$syspref->value( 'CheckinLibrary' )->store; |
268 |
t::lib::Mocks::mock_preference( 'RefundLostOnReturnControl', 'CheckinLibrary' ); |
273 |
is( Koha::RefundLostItemFeeRules->should_refund( $params ), |
269 |
is( Koha::RefundLostItemFeeRules->should_refund( $params ), |
274 |
1,'Specific rule is applied (true)'); |
270 |
1,'Specific rule is applied (true)'); |
275 |
|
271 |
|
276 |
$syspref->value( 'ItemHomeBranch' )->store; |
272 |
t::lib::Mocks::mock_preference( 'RefundLostOnReturnControl', 'ItemHomeBranch' ); |
277 |
is( Koha::RefundLostItemFeeRules->should_refund( $params ), |
273 |
is( Koha::RefundLostItemFeeRules->should_refund( $params ), |
278 |
1,'No rule for branch, global rule applied (true)'); |
274 |
1,'No rule for branch, global rule applied (true)'); |
279 |
|
275 |
|
280 |
# Change the default value just to try |
276 |
# Change the default value just to try |
281 |
Koha::RefundLostItemFeeRules->find({ branchcode => '*' })->refund(0)->store; |
277 |
Koha::RefundLostItemFeeRules->find({ branchcode => '*' })->refund(0)->store; |
282 |
$syspref->value( 'ItemHoldingBranch' )->store; |
278 |
t::lib::Mocks::mock_preference( 'RefundLostOnReturnControl', 'ItemHoldingBranch' ); |
283 |
is( Koha::RefundLostItemFeeRules->should_refund( $params ), |
279 |
is( Koha::RefundLostItemFeeRules->should_refund( $params ), |
284 |
0,'No rule for branch, global rule applied (false)'); |
280 |
0,'No rule for branch, global rule applied (false)'); |
285 |
|
281 |
|
286 |
- |
|
|