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

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

Return to bug 7376