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

(-)a/t/db_dependent/Circulation/TooMany.t (-3 / +71 lines)
Lines 15-21 Link Here
15
# with Koha; if not, see <http://www.gnu.org/licenses>.
15
# with Koha; if not, see <http://www.gnu.org/licenses>.
16
16
17
use Modern::Perl;
17
use Modern::Perl;
18
use Test::More tests => 10;
18
use Test::More tests => 11;
19
use C4::Context;
19
use C4::Context;
20
20
21
use C4::Members;
21
use C4::Members;
Lines 52-57 my $branch = $builder->build({ Link Here
52
    source => 'Branch',
52
    source => 'Branch',
53
});
53
});
54
54
55
my $branch2 = $builder->build({
56
     source => 'Branch',
57
});
58
55
my $category = $builder->build({
59
my $category = $builder->build({
56
    source => 'Category',
60
    source => 'Category',
57
});
61
});
Lines 583-588 subtest 'General vs specific rules limit quantity correctly' => sub { Link Here
583
        }
587
        }
584
    );
588
    );
585
589
590
    t::lib::Mocks::mock_preference('HomeOrHoldingBranch', 'homebranch');
591
586
    is(
592
    is(
587
        C4::Circulation::TooMany( $patron, $branch_item ),
593
        C4::Circulation::TooMany( $patron, $branch_item ),
588
        undef,
594
        undef,
Lines 655-661 subtest 'General vs specific rules limit quantity correctly' => sub { Link Here
655
        'We are only allowed one for general rule, and have checked out two at this branch'
661
        'We are only allowed one for general rule, and have checked out two at this branch'
656
    );
662
    );
657
663
658
    my $branch2   = $builder->build({source => 'Branch',});
659
    t::lib::Mocks::mock_userenv({ branchcode => $branch2->{branchcode} });
664
    t::lib::Mocks::mock_userenv({ branchcode => $branch2->{branchcode} });
660
    is_deeply(
665
    is_deeply(
661
        C4::Circulation::TooMany( $patron, $item_2 ),
666
        C4::Circulation::TooMany( $patron, $item_2 ),
Lines 977-982 subtest 'itemtype group tests' => sub { Link Here
977
    teardown();
982
    teardown();
978
};
983
};
979
984
985
subtest 'HomeOrHoldingBranch is used' => sub {
986
    plan tests => 2;
987
988
    t::lib::Mocks::mock_preference( 'CircControl', 'ItemHomeLibrary' );
989
990
    my $item_1 = $builder->build_sample_item(
991
        {
992
            homebranch    => $branch->{branchcode},
993
            holdingbranch => $branch2->{branchcode},
994
        }
995
    );
996
997
    Koha::CirculationRules->set_rules(
998
        {
999
            branchcode   => $branch->{branchcode},
1000
            categorycode => undef,
1001
            itemtype     => undef,
1002
            rules        => {
1003
                maxissueqty       => 0,
1004
            }
1005
        }
1006
    );
1007
1008
    Koha::CirculationRules->set_rules(
1009
        {
1010
            branchcode   => $branch2->{branchcode},
1011
            categorycode => undef,
1012
            itemtype     => undef,
1013
            rules        => {
1014
                maxissueqty       => 1,
1015
            }
1016
        }
1017
    );
1018
1019
    t::lib::Mocks::mock_userenv({ branchcode => $branch2->{branchcode} });
1020
    my $issue = C4::Circulation::AddIssue( $patron, $item_1->barcode, dt_from_string() );
1021
1022
    t::lib::Mocks::mock_preference('HomeOrHoldingBranch', 'homebranch');
1023
1024
    is_deeply(
1025
        C4::Circulation::TooMany( $patron, $item_1 ),
1026
        {
1027
            reason      => 'TOO_MANY_CHECKOUTS',
1028
            max_allowed => 0,
1029
            count       => 1,
1030
        },
1031
        'We are allowed zero issues from the homebranch specifically'
1032
    );
1033
1034
    t::lib::Mocks::mock_preference('HomeOrHoldingBranch', 'holdingbranch');
1035
1036
    is_deeply(
1037
        C4::Circulation::TooMany( $patron, $item_1 ),
1038
        {
1039
            reason      => 'TOO_MANY_CHECKOUTS',
1040
            max_allowed => 1,
1041
            count       => 1,
1042
        },
1043
        'We are allowed one issue from the holdingbranch specifically'
1044
    );
1045
1046
    teardown();
1047
};
1048
980
$schema->storage->txn_rollback;
1049
$schema->storage->txn_rollback;
981
1050
982
sub teardown {
1051
sub teardown {
983
- 

Return to bug 27259