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

(-)a/t/db_dependent/Circulation.t (-6 / +34 lines)
Lines 2898-2904 subtest 'CanBookBeIssued + Koha::Patron->is_debarred|has_overdues' => sub { Link Here
2898
};
2898
};
2899
2899
2900
subtest 'CanBookBeReturned + UseBranchTransfertLimits' => sub {
2900
subtest 'CanBookBeReturned + UseBranchTransfertLimits' => sub {
2901
    plan tests => 31;
2901
    plan tests => 33;
2902
    t::lib::Mocks::mock_preference( 'UseBranchTransferLimits', '1' );
2902
    t::lib::Mocks::mock_preference( 'UseBranchTransferLimits', '1' );
2903
2903
2904
    my $homebranch    = $builder->build( { source => 'Branch' } );
2904
    my $homebranch    = $builder->build( { source => 'Branch' } );
Lines 2996-3002 subtest 'CanBookBeReturned + UseBranchTransfertLimits' => sub { Link Here
2996
    # NOTE: This is the ONLY change that bug 7376 introduces currently.
2996
    # NOTE: This is the ONLY change that bug 7376 introduces currently.
2997
    t::lib::Mocks::mock_preference( 'AllowReturnToBranch', 'anywhere' );
2997
    t::lib::Mocks::mock_preference( 'AllowReturnToBranch', 'anywhere' );
2998
    ( $allowed, $message ) = C4::Circulation::CanBookBeReturned( $item, $returnbranch );
2998
    ( $allowed, $message ) = C4::Circulation::CanBookBeReturned( $item, $returnbranch );
2999
    is( 1, $allowed, 'Allow return where returnbranch can be transfered to from anywhere' );
2999
    is(
3000
        1, $allowed,
3001
        'Allow return where returnbranch can be transfered to holding (homebranch forbidden) from returnbranch'
3002
    );
3003
3004
    my $limit_2 = Koha::Item::Transfer::Limit->new(
3005
        {
3006
            toBranch   => $holdingbranch->{branchcode},
3007
            fromBranch => $returnbranch->{branchcode},
3008
            itemtype   => $item->effective_itemtype,
3009
        }
3010
    )->store();
3011
3012
    diag("Attempt return at returnbranch ('Anywhere' + Return -> Home and Return -> Holding limit)");
3013
3014
    # NOTE: Should we prevent return here.. we cannot transfer from 'returnbranch'
3015
    # to 'homebranch' (But we can transfer back to 'holdingbranch').
3016
    # NOTE: This is the ONLY change that bug 7376 introduces currently.
3017
    t::lib::Mocks::mock_preference( 'AllowReturnToBranch', 'anywhere' );
3018
    ( $allowed, $message ) = C4::Circulation::CanBookBeReturned( $item, $returnbranch );
3019
    is(
3020
        0, $allowed,
3021
        'Prevent return where item can\'t be transferred to both homebranch and holding from returnbranch'
3022
    );
3023
    is( $homebranch->{branchcode}, $message, 'Redirect to homebranch' );
3024
3025
    $limit_2->delete()->store()->discard_changes;
3000
3026
3001
    # Set limit ( Return -> Holding denied)
3027
    # Set limit ( Return -> Holding denied)
3002
    $limit->set(
3028
    $limit->set(
Lines 3030-3036 subtest 'CanBookBeReturned + UseBranchTransfertLimits' => sub { Link Here
3030
    # to 'holdingbranch' (But we can transfer back to 'homebranch').
3056
    # to 'holdingbranch' (But we can transfer back to 'homebranch').
3031
    t::lib::Mocks::mock_preference( 'AllowReturnToBranch', 'anywhere' );
3057
    t::lib::Mocks::mock_preference( 'AllowReturnToBranch', 'anywhere' );
3032
    ( $allowed, $message ) = C4::Circulation::CanBookBeReturned( $item, $returnbranch );
3058
    ( $allowed, $message ) = C4::Circulation::CanBookBeReturned( $item, $returnbranch );
3033
    is( 1, $allowed, 'Allow return where returnbranch can be transfered to from anywhere' );
3059
    is(
3060
        1, $allowed,
3061
        'Allow return where returnbranch can be transferred to homebranch (holdingbranch forbidden) from returnbranch'
3062
    );
3034
3063
3035
    # Set limit ( Holding -> Home denied)
3064
    # Set limit ( Holding -> Home denied)
3036
    $limit->set(
3065
    $limit->set(
Lines 3060-3070 subtest 'CanBookBeReturned + UseBranchTransfertLimits' => sub { Link Here
3060
3089
3061
    diag("Attempt return at returnbranch ('Anywhere' + Holding -> Home limit)");
3090
    diag("Attempt return at returnbranch ('Anywhere' + Holding -> Home limit)");
3062
3091
3063
    # NOTE: A return here can subsequently be transfered to back to homebranch
3092
    # NOTE: A return here can subsequently be transferred to back to homebranch
3064
    # or holdingbranch.
3093
    # or holdingbranch.
3065
    t::lib::Mocks::mock_preference( 'AllowReturnToBranch', 'anywhere' );
3094
    t::lib::Mocks::mock_preference( 'AllowReturnToBranch', 'anywhere' );
3066
    ( $allowed, $message ) = C4::Circulation::CanBookBeReturned( $item, $returnbranch );
3095
    ( $allowed, $message ) = C4::Circulation::CanBookBeReturned( $item, $returnbranch );
3067
    is( 1, $allowed, 'Allow return where returnbranch can be transfered to from anywhere' );
3096
    is( 1, $allowed, 'Allow return where returnbranch can be transferred to from anywhere' );
3068
};
3097
};
3069
3098
3070
subtest 'Statistic patrons "X"' => sub {
3099
subtest 'Statistic patrons "X"' => sub {
3071
- 

Return to bug 7376