Lines 25-31
use Koha::CirculationRules;
Link Here
|
25 |
|
25 |
|
26 |
use Koha::Patrons; |
26 |
use Koha::Patrons; |
27 |
|
27 |
|
28 |
use Test::More tests => 17; |
28 |
use Test::More tests => 18; |
29 |
use t::lib::Mocks; |
29 |
use t::lib::Mocks; |
30 |
use t::lib::TestBuilder; |
30 |
use t::lib::TestBuilder; |
31 |
|
31 |
|
Lines 264-285
is_deeply(
Link Here
|
264 |
$samplebranch1->{branchcode}, |
264 |
$samplebranch1->{branchcode}, |
265 |
$sampleitemtype1->{itemtype}, |
265 |
$sampleitemtype1->{itemtype}, |
266 |
), |
266 |
), |
267 |
{ returnbranch => 'homebranch', holdallowed => 'invalid_value', @lazy_any }, |
267 |
{ holdallowed => 'invalid_value', @lazy_any }, |
268 |
"GetBranchitem returns holdallowed and return branch" |
268 |
"GetBranchitem returns holdallowed and return branch" |
269 |
); |
269 |
); |
270 |
is_deeply( |
270 |
is_deeply( |
271 |
GetBranchItemRule(), |
271 |
GetBranchItemRule(), |
272 |
{ returnbranch => 'homebranch', holdallowed => 'from_local_hold_group', @lazy_any }, |
272 |
{ holdallowed => 'from_local_hold_group', @lazy_any }, |
273 |
"Without parameters GetBranchItemRule returns the values in default_circ_rules" |
273 |
"Without parameters GetBranchItemRule returns the values in default_circ_rules" |
274 |
); |
274 |
); |
275 |
is_deeply( |
275 |
is_deeply( |
276 |
GetBranchItemRule( $samplebranch2->{branchcode} ), |
276 |
GetBranchItemRule( $samplebranch2->{branchcode} ), |
277 |
{ returnbranch => 'holdingbranch', holdallowed => 'from_home_library', @lazy_any }, |
277 |
{ holdallowed => 'from_home_library', @lazy_any }, |
278 |
"With only a branchcode GetBranchItemRule returns values in default_branch_circ_rules" |
278 |
"With only a branchcode GetBranchItemRule returns values in default_branch_circ_rules" |
279 |
); |
279 |
); |
280 |
is_deeply( |
280 |
is_deeply( |
281 |
GetBranchItemRule( -1, -1 ), |
281 |
GetBranchItemRule( -1, -1 ), |
282 |
{ returnbranch => 'homebranch', holdallowed => 'from_local_hold_group', @lazy_any }, |
282 |
{ holdallowed => 'from_local_hold_group', @lazy_any }, |
283 |
"With only one parametern GetBranchItemRule returns default values" |
283 |
"With only one parametern GetBranchItemRule returns default values" |
284 |
); |
284 |
); |
285 |
|
285 |
|
Lines 329-333
t::lib::Mocks::mock_preference( 'item-level_itypes', 1 );
Link Here
|
329 |
is($messages->{NeedsTransfer},undef,"AddReturn respects branch item return policy - noreturn"); |
329 |
is($messages->{NeedsTransfer},undef,"AddReturn respects branch item return policy - noreturn"); |
330 |
t::lib::Mocks::mock_preference( 'item-level_itypes', 0 ); |
330 |
t::lib::Mocks::mock_preference( 'item-level_itypes', 0 ); |
331 |
|
331 |
|
332 |
$schema->storage->txn_rollback; |
332 |
subtest "Test GetBranchItemRule" => sub { |
|
|
333 |
plan tests => 3; |
334 |
|
335 |
$schema->storage->txn_begin; |
336 |
|
337 |
$dbh->do('DELETE FROM circulation_rules'); |
338 |
|
339 |
my $homebranch = $builder->build( { source => 'Branch' } )->{branchcode}; |
340 |
my $holdingbranch = $builder->build( { source => 'Branch' } )->{branchcode}; |
341 |
my $checkinbranch = $builder->build( { source => 'Branch' } )->{branchcode}; |
333 |
|
342 |
|
334 |
- |
343 |
my $manager = $builder->build_object( { class => "Koha::Patrons" } ); |
|
|
344 |
t::lib::Mocks::mock_userenv( |
345 |
{ |
346 |
patron => $manager, |
347 |
branchcode => $checkinbranch, |
348 |
} |
349 |
); |
350 |
|
351 |
my $item = Koha::Item->new( |
352 |
{ |
353 |
biblionumber => $biblionumber, |
354 |
homebranch => $homebranch, |
355 |
holdingbranch => $holdingbranch, |
356 |
itype => $sampleitemtype1->{itemtype} |
357 |
} |
358 |
)->store; |
359 |
|
360 |
Koha::CirculationRules->set_rule( |
361 |
{ |
362 |
branchcode => $homebranch, |
363 |
itemtype => undef, |
364 |
rule_name => 'returnbranch', |
365 |
rule_value => 'homebranch', |
366 |
} |
367 |
); |
368 |
|
369 |
Koha::CirculationRules->set_rule( |
370 |
{ |
371 |
branchcode => $holdingbranch, |
372 |
itemtype => undef, |
373 |
rule_name => 'returnbranch', |
374 |
rule_value => 'holdingbranch', |
375 |
} |
376 |
); |
377 |
|
378 |
Koha::CirculationRules->set_rule( |
379 |
{ |
380 |
branchcode => $checkinbranch, |
381 |
itemtype => undef, |
382 |
rule_name => 'returnbranch', |
383 |
rule_value => 'noreturn', |
384 |
} |
385 |
); |
386 |
|
387 |
t::lib::Mocks::mock_preference( 'CircControlReturnsBranch', 'ItemHomeLibrary' ); |
388 |
is( Koha::CirculationRules->get_return_branch_policy($item), 'homebranch' ); |
389 |
|
390 |
t::lib::Mocks::mock_preference( 'CircControlReturnsBranch', 'ItemHoldingLibrary' ); |
391 |
is( Koha::CirculationRules->get_return_branch_policy($item), 'holdingbranch' ); |
392 |
|
393 |
t::lib::Mocks::mock_preference( 'CircControlReturnsBranch', 'CheckInLibrary' ); |
394 |
is( Koha::CirculationRules->get_return_branch_policy($item), 'noreturn' ); |
395 |
|
396 |
$schema->storage->txn_rollback; |
397 |
}; |
398 |
|
399 |
$schema->storage->txn_rollback; |