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

(-)a/t/db_dependent/Reserves.t (-2 / +136 lines)
Lines 920-926 subtest 'ChargeReserveFee tests' => sub { Link Here
920
};
920
};
921
921
922
subtest 'reserves.item_level_hold' => sub {
922
subtest 'reserves.item_level_hold' => sub {
923
    plan tests => 2;
923
    plan tests => 4;
924
924
925
    my $item   = $builder->build_sample_item;
925
    my $item   = $builder->build_sample_item;
926
    my $patron = $builder->build_object(
926
    my $patron = $builder->build_object(
Lines 988-993 subtest 'reserves.item_level_hold' => sub { Link Here
988
        $hold->delete;
988
        $hold->delete;
989
    };
989
    };
990
990
991
    subtest 'test opacitemholds rules' => sub {
992
        plan tests => 6;
993
994
        Koha::CirculationRules->set_rules(
995
            {
996
                branchcode   => undef,
997
                categorycode => undef,
998
                itemtype     => undef,
999
                rules        => {
1000
                    reservesallowed => 25,
1001
                    opacitemholds => 'F',
1002
                }
1003
            }
1004
        );
1005
1006
        my $canreserve = C4::Reserves::CanBookBeReserved(
1007
            $patron->borrowernumber,
1008
            $item->biblionumber,
1009
           );
1010
1011
        is( $canreserve->{status},
1012
            'recordHoldNotAllowed',
1013
            'record-level holds should not be possible with opacitemholds set to "Force"' );
1014
1015
        $canreserve = C4::Reserves::CanItemBeReserved(
1016
           $patron->borrowernumber,
1017
            $item->itemnumber,
1018
          );
1019
1020
        is( $canreserve->{status}, 'OK',
1021
            'item-level holds should be possible with opacitemholds set to "Force"' );
1022
1023
        Koha::CirculationRules->set_rules(
1024
            {
1025
                branchcode   => undef,
1026
                categorycode => undef,
1027
                itemtype     => undef,
1028
                rules        => {
1029
                    reservesallowed => 25,
1030
                    opacitemholds => 'N',
1031
                }
1032
            }
1033
            );
1034
1035
        $canreserve = C4::Reserves::CanBookBeReserved(
1036
            $patron->borrowernumber,
1037
            $item->biblionumber,
1038
            );
1039
1040
        is( $canreserve->{status}, 'OK',
1041
            'record-level holds should be possible with opacitemholds set to "No"' );
1042
1043
       $canreserve = C4::Reserves::CanItemBeReserved(
1044
            $patron->borrowernumber,
1045
            $item->itemnumber,
1046
            );
1047
1048
        is( $canreserve->{status}, 'recordHoldsOnly',
1049
            'item-level holds should not be possible with opacitemholds set to "No"' );
1050
1051
        Koha::CirculationRules->set_rules(
1052
            {
1053
                branchcode   => undef,
1054
                categorycode => undef,
1055
                itemtype     => undef,
1056
                rules        => {
1057
                    reservesallowed => 25,
1058
                    opacitemholds => 'Y',
1059
                }
1060
            }
1061
            );
1062
1063
            $canreserve = C4::Reserves::CanBookBeReserved(
1064
            $patron->borrowernumber,
1065
            $item->biblionumber,
1066
            );
1067
1068
        is( $canreserve->{status}, 'OK',
1069
            'record-level holds should be possible with opacitemholds set to "Yes"' );
1070
1071
        $canreserve = C4::Reserves::CanItemBeReserved(
1072
            $patron->borrowernumber,
1073
            $item->itemnumber,
1074
            );
1075
1076
        is( $canreserve->{status}, 'OK',
1077
            'item-level holds should be possible with opacitemholds set to "Yes"' );
1078
    };
1079
1080
    subtest 'test opacitemholds rules in staff context' => sub {
1081
        plan tests => 2;
1082
1083
        Koha::CirculationRules->set_rules(
1084
            {
1085
                branchcode   => undef,
1086
                categorycode => undef,
1087
                itemtype     => undef,
1088
                rules        => {
1089
                    reservesallowed => 25,
1090
                    opacitemholds => 'N',
1091
                }
1092
            }
1093
        );
1094
1095
        my $canreserve = C4::Reserves::CanBookBeReserved(
1096
            $patron->borrowernumber,
1097
            $item->biblionumber,
1098
            undef,
1099
            { context => 'staff' }
1100
        );
1101
1102
        is( $canreserve->{status}, 'OK',
1103
            'record-level holds should be possible with opacitemholds set to "No"' );
1104
1105
        $canreserve = C4::Reserves::CanItemBeReserved(
1106
            $patron->borrowernumber,
1107
            $item->itemnumber,
1108
            undef,
1109
            { context => 'staff' }
1110
        );
1111
1112
       is( $canreserve->{status}, 'OK',
1113
            'item-level holds should still be possible in staff context, even with opacitemholds set to "No"' );
1114
    };
1115
1116
    Koha::CirculationRules->set_rules(
1117
        {
1118
             branchcode   => undef,
1119
             categorycode => undef,
1120
             itemtype     => undef,
1121
             rules        => {
1122
                 opacitemholds => undef,
1123
             }
1124
        }
1125
    );
991
};
1126
};
992
1127
993
subtest 'MoveReserve additional test' => sub {
1128
subtest 'MoveReserve additional test' => sub {
994
- 

Return to bug 25408