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

(-)a/t/db_dependent/Circulation.t (-2 / +43 lines)
Lines 18-24 Link Here
18
use Modern::Perl;
18
use Modern::Perl;
19
use utf8;
19
use utf8;
20
20
21
use Test::More tests => 75;
21
use Test::More tests => 76;
22
use Test::Exception;
22
use Test::Exception;
23
use Test::MockModule;
23
use Test::MockModule;
24
use Test::Deep qw( cmp_deeply );
24
use Test::Deep qw( cmp_deeply );
Lines 2600-2605 subtest 'CanBookBeIssued + Koha::Patron->is_debarred|has_overdues' => sub { Link Here
2600
    is( $error->{USERBLOCKEDNOENDDATE},    '9999-12-31', 'USERBLOCKEDNOENDDATE should be 9999-12-31 for unlimited debarments' );
2600
    is( $error->{USERBLOCKEDNOENDDATE},    '9999-12-31', 'USERBLOCKEDNOENDDATE should be 9999-12-31 for unlimited debarments' );
2601
};
2601
};
2602
2602
2603
2604
subtest 'CanBookBeReturned + UseBranchTransfertLimits' => sub {
2605
    plan tests => 6;
2606
2607
    my $homebranch    = $builder->build( { source => 'Branch' } );
2608
    my $otherbranch   = $builder->build( { source => 'Branch' } );
2609
    my $patron        = $builder->build( { source => 'Borrower', value => { categorycode => $patron_category->{categorycode} } } );
2610
2611
    my $item = $builder->build_sample_item(
2612
        {
2613
            homebranch    => $homebranch->{branchcode},
2614
            holdingbranch => $homebranch->{branchcode},
2615
        }
2616
    );
2617
2618
    t::lib::Mocks::mock_preference( 'AllowReturnToBranch', 'anywhere' );
2619
    set_userenv($homebranch);
2620
    my $issue = AddIssue( $patron, $item->barcode );
2621
    my ($allowed, $message) = C4::Circulation::CanBookBeReturned($item, $otherbranch);
2622
    is ( 1 , $allowed , 'with AllowReturnToBranch = anywhere and no limits return to other is allowed');
2623
    is ( undef , $message , 'without limits provides no message');
2624
2625
    t::lib::Mocks::mock_preference( 'UseBranchTransferLimits', '1' );
2626
    t::lib::Mocks::mock_preference( 'BranchTransferLimitsType', 'itemtype' );
2627
2628
    # set limit
2629
    my $limit = Koha::Item::Transfer::Limit->new({
2630
        toBranch => $otherbranch->{branchcode},
2631
        fromBranch => $item->homebranch,
2632
        itemtype => $item->effective_itemtype,
2633
    })->store();
2634
2635
    ($allowed, $message) = C4::Circulation::CanBookBeReturned($item, $otherbranch);
2636
    is ( 0 , $allowed , 'With transfer limits cannot return to otherbranch');
2637
    is ( $homebranch->{branchcode} , $message , 'With transfer limits asks return to homebranch');
2638
2639
    ($allowed, $message) = C4::Circulation::CanBookBeReturned($item, $homebranch);
2640
    is ( 1 , $allowed , 'With transfer limits can return to homebranch');
2641
    is ( undef , $message , 'With transfer limits and homebranch provides no message');
2642
};
2643
2644
2603
subtest 'Statistic patrons "X"' => sub {
2645
subtest 'Statistic patrons "X"' => sub {
2604
    plan tests => 15;
2646
    plan tests => 15;
2605
2647
2606
- 

Return to bug 7376