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-1020
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( |
1011 |
my ( $self, $args ) = @_; |
1007 |
'enqueue', |
1012 |
is_deeply( |
1008 |
sub { |
1013 |
$args->{biblio_ids}, |
1009 |
my ( $self, $args ) = @_; |
1014 |
[ $hold->biblionumber ], |
1010 |
is_deeply( |
1015 |
"AlterPriority triggers a holds queue update for the related biblio" |
1011 |
$args->{biblio_ids}, |
1016 |
); |
1012 |
[ $hold->biblionumber ], |
1017 |
} ); |
1013 |
"AlterPriority triggers a holds queue update for the related biblio" |
|
|
1014 |
); |
1015 |
} |
1016 |
); |
1018 |
|
1017 |
|
1019 |
t::lib::Mocks::mock_preference( 'RealTimeHoldsQueue', 1 ); |
1018 |
t::lib::Mocks::mock_preference( 'RealTimeHoldsQueue', 1 ); |
1020 |
t::lib::Mocks::mock_preference( 'HoldsLog', 1 ); |
1019 |
t::lib::Mocks::mock_preference( 'HoldsLog', 1 ); |
Lines 1064-1070
subtest 'reserves.item_level_hold' => sub {
Link Here
|
1064 |
); |
1063 |
); |
1065 |
|
1064 |
|
1066 |
my $hold = Koha::Holds->find($reserve_id); |
1065 |
my $hold = Koha::Holds->find($reserve_id); |
1067 |
is( $hold->item_level_hold, 0, 'item_level_hold should not be set when AddReserve is called without a specific item' ); |
1066 |
is( |
|
|
1067 |
$hold->item_level_hold, 0, |
1068 |
'item_level_hold should not be set when AddReserve is called without a specific item' |
1069 |
); |
1068 |
|
1070 |
|
1069 |
# Mark it waiting |
1071 |
# Mark it waiting |
1070 |
ModReserveAffect( $item->itemnumber, $patron->borrowernumber, 1 ); |
1072 |
ModReserveAffect( $item->itemnumber, $patron->borrowernumber, 1 ); |
Lines 1081-1086
subtest 'reserves.item_level_hold' => sub {
Link Here
|
1081 |
$hold->delete; |
1083 |
$hold->delete; |
1082 |
}; |
1084 |
}; |
1083 |
|
1085 |
|
|
|
1086 |
subtest 'test opacitemholds rules' => sub { |
1087 |
plan tests => 6; |
1088 |
|
1089 |
Koha::CirculationRules->set_rules( |
1090 |
{ |
1091 |
branchcode => undef, |
1092 |
categorycode => undef, |
1093 |
itemtype => undef, |
1094 |
rules => { |
1095 |
reservesallowed => 25, |
1096 |
opacitemholds => 'F', |
1097 |
} |
1098 |
} |
1099 |
); |
1100 |
|
1101 |
my $canreserve = C4::Reserves::CanBookBeReserved( $patron->id, $item->biblionumber ); |
1102 |
|
1103 |
is( |
1104 |
$canreserve->{status}, |
1105 |
'recordHoldNotAllowed', |
1106 |
'record-level holds should not be possible with opacitemholds set to "Force"' |
1107 |
); |
1108 |
|
1109 |
$canreserve = C4::Reserves::CanItemBeReserved( $patron, $item ); |
1110 |
|
1111 |
is( |
1112 |
$canreserve->{status}, 'OK', |
1113 |
'item-level holds should be possible with opacitemholds set to "Force"' |
1114 |
); |
1115 |
|
1116 |
Koha::CirculationRules->set_rules( |
1117 |
{ |
1118 |
branchcode => undef, |
1119 |
categorycode => undef, |
1120 |
itemtype => undef, |
1121 |
rules => { |
1122 |
reservesallowed => 25, |
1123 |
opacitemholds => 'N', |
1124 |
} |
1125 |
} |
1126 |
); |
1127 |
|
1128 |
$canreserve = C4::Reserves::CanBookBeReserved( $patron->id, $item->biblionumber ); |
1129 |
|
1130 |
is( |
1131 |
$canreserve->{status}, 'OK', |
1132 |
'record-level holds should be possible with opacitemholds set to "No"' |
1133 |
); |
1134 |
|
1135 |
$canreserve = C4::Reserves::CanItemBeReserved( $patron, $item ); |
1136 |
|
1137 |
is( |
1138 |
$canreserve->{status}, 'recordHoldsOnly', |
1139 |
'item-level holds should not be possible with opacitemholds set to "No"' |
1140 |
); |
1141 |
|
1142 |
Koha::CirculationRules->set_rules( |
1143 |
{ |
1144 |
branchcode => undef, |
1145 |
categorycode => undef, |
1146 |
itemtype => undef, |
1147 |
rules => { |
1148 |
reservesallowed => 25, |
1149 |
opacitemholds => 'Y', |
1150 |
} |
1151 |
} |
1152 |
); |
1153 |
|
1154 |
$canreserve = C4::Reserves::CanBookBeReserved( $patron->id, $item->biblionumber ); |
1155 |
|
1156 |
is( |
1157 |
$canreserve->{status}, 'OK', |
1158 |
'record-level holds should be possible with opacitemholds set to "Yes"' |
1159 |
); |
1160 |
|
1161 |
$canreserve = C4::Reserves::CanItemBeReserved( $patron, $item ); |
1162 |
|
1163 |
is( |
1164 |
$canreserve->{status}, 'OK', |
1165 |
'item-level holds should be possible with opacitemholds set to "Yes"' |
1166 |
); |
1167 |
}; |
1168 |
|
1169 |
subtest 'test opacitemholds rules in staff context' => sub { |
1170 |
plan tests => 2; |
1171 |
|
1172 |
C4::Context->interface('intranet'); |
1173 |
Koha::CirculationRules->set_rules( |
1174 |
{ |
1175 |
branchcode => undef, |
1176 |
categorycode => undef, |
1177 |
itemtype => undef, |
1178 |
rules => { |
1179 |
reservesallowed => 25, |
1180 |
opacitemholds => 'N', |
1181 |
} |
1182 |
} |
1183 |
); |
1184 |
|
1185 |
my $canreserve = C4::Reserves::CanBookBeReserved( $patron->id, $item->biblionumber ); |
1186 |
|
1187 |
is( |
1188 |
$canreserve->{status}, 'OK', |
1189 |
'record-level holds should be possible with opacitemholds set to "No"' |
1190 |
); |
1191 |
|
1192 |
$canreserve = C4::Reserves::CanItemBeReserved( $patron, $item ); |
1193 |
|
1194 |
is( |
1195 |
$canreserve->{status}, 'OK', |
1196 |
'item-level holds should still be possible in staff context, even with opacitemholds set to "No"' |
1197 |
); |
1198 |
}; |
1199 |
|
1200 |
Koha::CirculationRules->set_rules( |
1201 |
{ |
1202 |
branchcode => undef, |
1203 |
categorycode => undef, |
1204 |
itemtype => undef, |
1205 |
rules => { |
1206 |
opacitemholds => undef, |
1207 |
} |
1208 |
} |
1209 |
); |
1084 |
}; |
1210 |
}; |
1085 |
|
1211 |
|
1086 |
subtest 'MoveReserve additional test' => sub { |
1212 |
subtest 'MoveReserve additional test' => sub { |
1087 |
- |
|
|