View | Details | Raw Unified | Return to bug 7376
Collapse All | Expand All

(-)a/t/db_dependent/Circulation.t (-6 / +34 lines)
Lines 2843-2849 subtest 'CanBookBeIssued + Koha::Patron->is_debarred|has_overdues' => sub { Link Here
2843
};
2843
};
2844
2844
2845
subtest 'CanBookBeReturned + UseBranchTransfertLimits' => sub {
2845
subtest 'CanBookBeReturned + UseBranchTransfertLimits' => sub {
2846
    plan tests => 31;
2846
    plan tests => 33;
2847
    t::lib::Mocks::mock_preference( 'UseBranchTransferLimits', '1' );
2847
    t::lib::Mocks::mock_preference( 'UseBranchTransferLimits', '1' );
2848
2848
2849
    my $homebranch    = $builder->build( { source => 'Branch' } );
2849
    my $homebranch    = $builder->build( { source => 'Branch' } );
Lines 2941-2947 subtest 'CanBookBeReturned + UseBranchTransfertLimits' => sub { Link Here
2941
    # NOTE: This is the ONLY change that bug 7376 introduces currently.
2941
    # NOTE: This is the ONLY change that bug 7376 introduces currently.
2942
    t::lib::Mocks::mock_preference( 'AllowReturnToBranch', 'anywhere' );
2942
    t::lib::Mocks::mock_preference( 'AllowReturnToBranch', 'anywhere' );
2943
    ( $allowed, $message ) = C4::Circulation::CanBookBeReturned( $item, $returnbranch );
2943
    ( $allowed, $message ) = C4::Circulation::CanBookBeReturned( $item, $returnbranch );
2944
    is( 1, $allowed, 'Allow return where returnbranch can be transfered to from anywhere' );
2944
    is(
2945
        1, $allowed,
2946
        'Allow return where returnbranch can be transfered to holding (homebranch forbidden) from returnbranch'
2947
    );
2948
2949
    my $limit_2 = Koha::Item::Transfer::Limit->new(
2950
        {
2951
            toBranch   => $holdingbranch->{branchcode},
2952
            fromBranch => $returnbranch->{branchcode},
2953
            itemtype   => $item->effective_itemtype,
2954
        }
2955
    )->store();
2956
2957
    diag("Attempt return at returnbranch ('Anywhere' + Return -> Home and Return -> Holding limit)");
2958
2959
    # NOTE: Should we prevent return here.. we cannot transfer from 'returnbranch'
2960
    # to 'homebranch' (But we can transfer back to 'holdingbranch').
2961
    # NOTE: This is the ONLY change that bug 7376 introduces currently.
2962
    t::lib::Mocks::mock_preference( 'AllowReturnToBranch', 'anywhere' );
2963
    ( $allowed, $message ) = C4::Circulation::CanBookBeReturned( $item, $returnbranch );
2964
    is(
2965
        0, $allowed,
2966
        'Prevent return where item can\'t be transferred to both homebranch and holding from returnbranch'
2967
    );
2968
    is( $homebranch->{branchcode}, $message, 'Redirect to homebranch' );
2969
2970
    $limit_2->delete()->store()->discard_changes;
2945
2971
2946
    # Set limit ( Return -> Holding denied)
2972
    # Set limit ( Return -> Holding denied)
2947
    $limit->set(
2973
    $limit->set(
Lines 2975-2981 subtest 'CanBookBeReturned + UseBranchTransfertLimits' => sub { Link Here
2975
    # to 'holdingbranch' (But we can transfer back to 'homebranch').
3001
    # to 'holdingbranch' (But we can transfer back to 'homebranch').
2976
    t::lib::Mocks::mock_preference( 'AllowReturnToBranch', 'anywhere' );
3002
    t::lib::Mocks::mock_preference( 'AllowReturnToBranch', 'anywhere' );
2977
    ( $allowed, $message ) = C4::Circulation::CanBookBeReturned( $item, $returnbranch );
3003
    ( $allowed, $message ) = C4::Circulation::CanBookBeReturned( $item, $returnbranch );
2978
    is( 1, $allowed, 'Allow return where returnbranch can be transfered to from anywhere' );
3004
    is(
3005
        1, $allowed,
3006
        'Allow return where returnbranch can be transferred to homebranch (holdingbranch forbidden) from returnbranch'
3007
    );
2979
3008
2980
    # Set limit ( Holding -> Home denied)
3009
    # Set limit ( Holding -> Home denied)
2981
    $limit->set(
3010
    $limit->set(
Lines 3005-3015 subtest 'CanBookBeReturned + UseBranchTransfertLimits' => sub { Link Here
3005
3034
3006
    diag("Attempt return at returnbranch ('Anywhere' + Holding -> Home limit)");
3035
    diag("Attempt return at returnbranch ('Anywhere' + Holding -> Home limit)");
3007
3036
3008
    # NOTE: A return here can subsequently be transfered to back to homebranch
3037
    # NOTE: A return here can subsequently be transferred to back to homebranch
3009
    # or holdingbranch.
3038
    # or holdingbranch.
3010
    t::lib::Mocks::mock_preference( 'AllowReturnToBranch', 'anywhere' );
3039
    t::lib::Mocks::mock_preference( 'AllowReturnToBranch', 'anywhere' );
3011
    ( $allowed, $message ) = C4::Circulation::CanBookBeReturned( $item, $returnbranch );
3040
    ( $allowed, $message ) = C4::Circulation::CanBookBeReturned( $item, $returnbranch );
3012
    is( 1, $allowed, 'Allow return where returnbranch can be transfered to from anywhere' );
3041
    is( 1, $allowed, 'Allow return where returnbranch can be transferred to from anywhere' );
3013
};
3042
};
3014
3043
3015
subtest 'Statistic patrons "X"' => sub {
3044
subtest 'Statistic patrons "X"' => sub {
3016
- 

Return to bug 7376