Lines 2602-2608
subtest 'CanBookBeIssued + Koha::Patron->is_debarred|has_overdues' => sub {
Link Here
|
2602 |
|
2602 |
|
2603 |
|
2603 |
|
2604 |
subtest 'CanBookBeReturned + UseBranchTransfertLimits' => sub { |
2604 |
subtest 'CanBookBeReturned + UseBranchTransfertLimits' => sub { |
2605 |
plan tests => 31; |
2605 |
plan tests => 33; |
2606 |
t::lib::Mocks::mock_preference( 'UseBranchTransferLimits', '1' ); |
2606 |
t::lib::Mocks::mock_preference( 'UseBranchTransferLimits', '1' ); |
2607 |
|
2607 |
|
2608 |
my $homebranch = $builder->build( { source => 'Branch' } ); |
2608 |
my $homebranch = $builder->build( { source => 'Branch' } ); |
Lines 2695-2701
subtest 'CanBookBeReturned + UseBranchTransfertLimits' => sub {
Link Here
|
2695 |
# NOTE: This is the ONLY change that bug 7376 introduces currently. |
2695 |
# NOTE: This is the ONLY change that bug 7376 introduces currently. |
2696 |
t::lib::Mocks::mock_preference( 'AllowReturnToBranch', 'anywhere' ); |
2696 |
t::lib::Mocks::mock_preference( 'AllowReturnToBranch', 'anywhere' ); |
2697 |
($allowed, $message) = C4::Circulation::CanBookBeReturned($item, $returnbranch); |
2697 |
($allowed, $message) = C4::Circulation::CanBookBeReturned($item, $returnbranch); |
2698 |
is ( 1 , $allowed , 'Allow return where returnbranch can be transfered to from anywhere'); |
2698 |
is ( 1 , $allowed , 'Allow return where returnbranch can be transfered to holding (homebranch forbidden) from returnbranch'); |
|
|
2699 |
|
2700 |
my $limit_2 = Koha::Item::Transfer::Limit->new({ |
2701 |
toBranch => $holdingbranch->{branchcode}, |
2702 |
fromBranch => $returnbranch->{branchcode}, |
2703 |
itemtype => $item->effective_itemtype, |
2704 |
})->store(); |
2705 |
|
2706 |
diag("Attempt return at returnbranch ('Anywhere' + Return -> Home and Return -> Holding limit)"); |
2707 |
# NOTE: Should we prevent return here.. we cannot transfer from 'returnbranch' |
2708 |
# to 'homebranch' (But we can transfer back to 'holdingbranch'). |
2709 |
# NOTE: This is the ONLY change that bug 7376 introduces currently. |
2710 |
t::lib::Mocks::mock_preference( 'AllowReturnToBranch', 'anywhere' ); |
2711 |
($allowed, $message) = C4::Circulation::CanBookBeReturned($item, $returnbranch); |
2712 |
is ( 0 , $allowed , 'Prevent return where item can\'t be transferred to both homebranch and holding from returnbranch'); |
2713 |
is ( $homebranch->{branchcode} , $message , 'Redirect to homebranch'); |
2714 |
|
2715 |
$limit_2->delete()->store()->discard_changes; |
2699 |
|
2716 |
|
2700 |
# Set limit ( Return -> Holding denied) |
2717 |
# Set limit ( Return -> Holding denied) |
2701 |
$limit->set( |
2718 |
$limit->set( |
Lines 2728-2734
subtest 'CanBookBeReturned + UseBranchTransfertLimits' => sub {
Link Here
|
2728 |
# to 'holdingbranch' (But we can transfer back to 'homebranch'). |
2745 |
# to 'holdingbranch' (But we can transfer back to 'homebranch'). |
2729 |
t::lib::Mocks::mock_preference( 'AllowReturnToBranch', 'anywhere' ); |
2746 |
t::lib::Mocks::mock_preference( 'AllowReturnToBranch', 'anywhere' ); |
2730 |
($allowed, $message) = C4::Circulation::CanBookBeReturned($item, $returnbranch); |
2747 |
($allowed, $message) = C4::Circulation::CanBookBeReturned($item, $returnbranch); |
2731 |
is ( 1 , $allowed , 'Allow return where returnbranch can be transfered to from anywhere'); |
2748 |
is ( 1 , $allowed , 'Allow return where returnbranch can be transferred to homebranch (holdingbranch forbidden) from returnbranch'); |
2732 |
|
2749 |
|
2733 |
# Set limit ( Holding -> Home denied) |
2750 |
# Set limit ( Holding -> Home denied) |
2734 |
$limit->set( |
2751 |
$limit->set( |
Lines 2757-2767
subtest 'CanBookBeReturned + UseBranchTransfertLimits' => sub {
Link Here
|
2757 |
is ( $homebranch->{branchcode} , $message , 'Redirect to homebranch'); |
2774 |
is ( $homebranch->{branchcode} , $message , 'Redirect to homebranch'); |
2758 |
|
2775 |
|
2759 |
diag("Attempt return at returnbranch ('Anywhere' + Holding -> Home limit)"); |
2776 |
diag("Attempt return at returnbranch ('Anywhere' + Holding -> Home limit)"); |
2760 |
# NOTE: A return here can subsequently be transfered to back to homebranch |
2777 |
# NOTE: A return here can subsequently be transferred to back to homebranch |
2761 |
# or holdingbranch. |
2778 |
# or holdingbranch. |
2762 |
t::lib::Mocks::mock_preference( 'AllowReturnToBranch', 'anywhere' ); |
2779 |
t::lib::Mocks::mock_preference( 'AllowReturnToBranch', 'anywhere' ); |
2763 |
($allowed, $message) = C4::Circulation::CanBookBeReturned($item, $returnbranch); |
2780 |
($allowed, $message) = C4::Circulation::CanBookBeReturned($item, $returnbranch); |
2764 |
is ( 1 , $allowed , 'Allow return where returnbranch can be transfered to from anywhere'); |
2781 |
is ( 1 , $allowed , 'Allow return where returnbranch can be transferred to from anywhere'); |
2765 |
}; |
2782 |
}; |
2766 |
|
2783 |
|
2767 |
|
2784 |
|
2768 |
- |
|
|