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

(-)a/t/db_dependent/Circulation.t (-2 / +44 lines)
Lines 19-25 use Modern::Perl; Link Here
19
use utf8;
19
use utf8;
20
20
21
use Test::NoWarnings;
21
use Test::NoWarnings;
22
use Test::More tests => 85;
22
use Test::More tests => 86;
23
use Test::Exception;
23
use Test::Exception;
24
use Test::MockModule;
24
use Test::MockModule;
25
use Test::Deep qw( cmp_deeply );
25
use Test::Deep qw( cmp_deeply );
Lines 2897-2902 subtest 'CanBookBeIssued + Koha::Patron->is_debarred|has_overdues' => sub { Link Here
2897
    );
2897
    );
2898
};
2898
};
2899
2899
2900
subtest 'CanBookBeReturned + UseBranchTransfertLimits' => sub {
2901
    plan tests => 6;
2902
2903
    my $homebranch  = $builder->build( { source => 'Branch' } );
2904
    my $otherbranch = $builder->build( { source => 'Branch' } );
2905
    my $patron =
2906
        $builder->build( { source => 'Borrower', value => { categorycode => $patron_category->{categorycode} } } );
2907
2908
    my $item = $builder->build_sample_item(
2909
        {
2910
            homebranch    => $homebranch->{branchcode},
2911
            holdingbranch => $homebranch->{branchcode},
2912
        }
2913
    );
2914
2915
    t::lib::Mocks::mock_preference( 'AllowReturnToBranch', 'anywhere' );
2916
    set_userenv($homebranch);
2917
    my $issue = AddIssue( $patron, $item->barcode );
2918
    my ( $allowed, $message ) = C4::Circulation::CanBookBeReturned( $item, $otherbranch );
2919
    is( 1,     $allowed, 'with AllowReturnToBranch = anywhere and no limits return to other is allowed' );
2920
    is( undef, $message, 'without limits provides no message' );
2921
2922
    t::lib::Mocks::mock_preference( 'UseBranchTransferLimits',  '1' );
2923
    t::lib::Mocks::mock_preference( 'BranchTransferLimitsType', 'itemtype' );
2924
2925
    # set limit
2926
    my $limit = Koha::Item::Transfer::Limit->new(
2927
        {
2928
            toBranch   => $otherbranch->{branchcode},
2929
            fromBranch => $item->homebranch,
2930
            itemtype   => $item->effective_itemtype,
2931
        }
2932
    )->store();
2933
2934
    ( $allowed, $message ) = C4::Circulation::CanBookBeReturned( $item, $otherbranch );
2935
    is( 0,                         $allowed, 'With transfer limits cannot return to otherbranch' );
2936
    is( $homebranch->{branchcode}, $message, 'With transfer limits asks return to homebranch' );
2937
2938
    ( $allowed, $message ) = C4::Circulation::CanBookBeReturned( $item, $homebranch );
2939
    is( 1,     $allowed, 'With transfer limits can return to homebranch' );
2940
    is( undef, $message, 'With transfer limits and homebranch provides no message' );
2941
};
2942
2900
subtest 'Statistic patrons "X"' => sub {
2943
subtest 'Statistic patrons "X"' => sub {
2901
    plan tests => 15;
2944
    plan tests => 15;
2902
2945
2903
- 

Return to bug 7376