|
Lines 978-999
subtest 'ChargeReserveFee tests' => sub {
Link Here
|
| 978 |
}; |
978 |
}; |
| 979 |
|
979 |
|
| 980 |
subtest 'reserves.item_level_hold' => sub { |
980 |
subtest 'reserves.item_level_hold' => sub { |
| 981 |
plan tests => 2; |
981 |
plan tests => 4; |
| 982 |
|
982 |
|
| 983 |
my $item = $builder->build_sample_item; |
983 |
my $item = $builder->build_sample_item; |
| 984 |
my $patron = $builder->build_object( |
984 |
my $patron = $builder->build_object({ class => "Koha::Patrons" }); |
| 985 |
{ |
985 |
$patron->branchcode( $item->homebranch ); |
| 986 |
class => 'Koha::Patrons', |
|
|
| 987 |
value => { branchcode => $item->homebranch } |
| 988 |
} |
| 989 |
); |
| 990 |
|
986 |
|
| 991 |
subtest 'item level hold' => sub { |
987 |
subtest 'item level hold' => sub { |
| 992 |
plan tests => 5; |
988 |
plan tests => 5; |
| 993 |
my $reserve_id = AddReserve( |
989 |
my $reserve_id = AddReserve( |
| 994 |
{ |
990 |
{ |
| 995 |
branchcode => $item->homebranch, |
991 |
branchcode => $item->homebranch, |
| 996 |
borrowernumber => $patron->borrowernumber, |
992 |
borrowernumber => $patron->id, |
| 997 |
biblionumber => $item->biblionumber, |
993 |
biblionumber => $item->biblionumber, |
| 998 |
priority => 1, |
994 |
priority => 1, |
| 999 |
itemnumber => $item->itemnumber, |
995 |
itemnumber => $item->itemnumber, |
|
Lines 1004-1010
subtest 'reserves.item_level_hold' => sub {
Link Here
|
| 1004 |
is( $hold->item_level_hold, 1, 'item_level_hold should be set when AddReserve is called with a specific item' ); |
1000 |
is( $hold->item_level_hold, 1, 'item_level_hold should be set when AddReserve is called with a specific item' ); |
| 1005 |
|
1001 |
|
| 1006 |
# Mark it waiting |
1002 |
# Mark it waiting |
| 1007 |
ModReserveAffect( $item->itemnumber, $patron->borrowernumber, 1 ); |
1003 |
ModReserveAffect( $item->itemnumber, $patron->id, 1 ); |
| 1008 |
|
1004 |
|
| 1009 |
my $mock = Test::MockModule->new('Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue'); |
1005 |
my $mock = Test::MockModule->new('Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue'); |
| 1010 |
$mock->mock( 'enqueue', sub { |
1006 |
$mock->mock( 'enqueue', sub { |
|
Lines 1081-1086
subtest 'reserves.item_level_hold' => sub {
Link Here
|
| 1081 |
$hold->delete; |
1077 |
$hold->delete; |
| 1082 |
}; |
1078 |
}; |
| 1083 |
|
1079 |
|
|
|
1080 |
subtest 'test opacitemholds rules' => sub { |
| 1081 |
plan tests => 6; |
| 1082 |
|
| 1083 |
Koha::CirculationRules->set_rules( |
| 1084 |
{ |
| 1085 |
branchcode => undef, |
| 1086 |
categorycode => undef, |
| 1087 |
itemtype => undef, |
| 1088 |
rules => { |
| 1089 |
reservesallowed => 25, |
| 1090 |
opacitemholds => 'F', |
| 1091 |
} |
| 1092 |
} |
| 1093 |
); |
| 1094 |
|
| 1095 |
my $canreserve = C4::Reserves::CanBookBeReserved( $patron->id, $item->biblionumber ); |
| 1096 |
|
| 1097 |
is( $canreserve->{status}, |
| 1098 |
'recordHoldNotAllowed', |
| 1099 |
'record-level holds should not be possible with opacitemholds set to "Force"' ); |
| 1100 |
|
| 1101 |
$canreserve = C4::Reserves::CanItemBeReserved( $patron, $item ); |
| 1102 |
|
| 1103 |
is( $canreserve->{status}, 'OK', |
| 1104 |
'item-level holds should be possible with opacitemholds set to "Force"' ); |
| 1105 |
|
| 1106 |
Koha::CirculationRules->set_rules( |
| 1107 |
{ |
| 1108 |
branchcode => undef, |
| 1109 |
categorycode => undef, |
| 1110 |
itemtype => undef, |
| 1111 |
rules => { |
| 1112 |
reservesallowed => 25, |
| 1113 |
opacitemholds => 'N', |
| 1114 |
} |
| 1115 |
} |
| 1116 |
); |
| 1117 |
|
| 1118 |
$canreserve = C4::Reserves::CanBookBeReserved( $patron->id, $item->biblionumber ); |
| 1119 |
|
| 1120 |
is( $canreserve->{status}, 'OK', |
| 1121 |
'record-level holds should be possible with opacitemholds set to "No"' ); |
| 1122 |
|
| 1123 |
$canreserve = C4::Reserves::CanItemBeReserved( $patron, $item ); |
| 1124 |
|
| 1125 |
is( $canreserve->{status}, 'recordHoldsOnly', |
| 1126 |
'item-level holds should not be possible with opacitemholds set to "No"' ); |
| 1127 |
|
| 1128 |
Koha::CirculationRules->set_rules( |
| 1129 |
{ |
| 1130 |
branchcode => undef, |
| 1131 |
categorycode => undef, |
| 1132 |
itemtype => undef, |
| 1133 |
rules => { |
| 1134 |
reservesallowed => 25, |
| 1135 |
opacitemholds => 'Y', |
| 1136 |
} |
| 1137 |
} |
| 1138 |
); |
| 1139 |
|
| 1140 |
$canreserve = C4::Reserves::CanBookBeReserved( $patron->id, $item->biblionumber ); |
| 1141 |
|
| 1142 |
is( $canreserve->{status}, 'OK', |
| 1143 |
'record-level holds should be possible with opacitemholds set to "Yes"' ); |
| 1144 |
|
| 1145 |
$canreserve = C4::Reserves::CanItemBeReserved( $patron, $item ); |
| 1146 |
|
| 1147 |
is( $canreserve->{status}, 'OK', |
| 1148 |
'item-level holds should be possible with opacitemholds set to "Yes"' ); |
| 1149 |
}; |
| 1150 |
|
| 1151 |
subtest 'test opacitemholds rules in staff context' => sub { |
| 1152 |
plan tests => 2; |
| 1153 |
|
| 1154 |
C4::Context->interface('intranet'); |
| 1155 |
Koha::CirculationRules->set_rules( |
| 1156 |
{ |
| 1157 |
branchcode => undef, |
| 1158 |
categorycode => undef, |
| 1159 |
itemtype => undef, |
| 1160 |
rules => { |
| 1161 |
reservesallowed => 25, |
| 1162 |
opacitemholds => 'N', |
| 1163 |
} |
| 1164 |
} |
| 1165 |
); |
| 1166 |
|
| 1167 |
my $canreserve = C4::Reserves::CanBookBeReserved( $patron->id, $item->biblionumber ); |
| 1168 |
|
| 1169 |
is( $canreserve->{status}, 'OK', |
| 1170 |
'record-level holds should be possible with opacitemholds set to "No"' ); |
| 1171 |
|
| 1172 |
$canreserve = C4::Reserves::CanItemBeReserved( $patron, $item ); |
| 1173 |
|
| 1174 |
is( $canreserve->{status}, 'OK', |
| 1175 |
'item-level holds should still be possible in staff context, even with opacitemholds set to "No"' ); |
| 1176 |
}; |
| 1177 |
|
| 1178 |
Koha::CirculationRules->set_rules( |
| 1179 |
{ |
| 1180 |
branchcode => undef, |
| 1181 |
categorycode => undef, |
| 1182 |
itemtype => undef, |
| 1183 |
rules => { |
| 1184 |
opacitemholds => undef, |
| 1185 |
} |
| 1186 |
} |
| 1187 |
); |
| 1084 |
}; |
1188 |
}; |
| 1085 |
|
1189 |
|
| 1086 |
subtest 'MoveReserve additional test' => sub { |
1190 |
subtest 'MoveReserve additional test' => sub { |
| 1087 |
- |
|
|