Lines 1076-1084
subtest 'RevertWaitingStatus' => sub {
Link Here
|
1076 |
); |
1076 |
); |
1077 |
}; |
1077 |
}; |
1078 |
|
1078 |
|
1079 |
subtest 'CheckReserves additional test' => sub { |
1079 |
subtest 'CheckReserves additional tests' => sub { |
1080 |
|
1080 |
|
1081 |
plan tests => 3; |
1081 |
plan tests => 8; |
1082 |
|
1082 |
|
1083 |
my $item = $builder->build_sample_item; |
1083 |
my $item = $builder->build_sample_item; |
1084 |
my $reserve1 = $builder->build_object( |
1084 |
my $reserve1 = $builder->build_object( |
Lines 1151-1156
subtest 'CheckReserves additional test' => sub {
Link Here
|
1151 |
is( $matched_reserve->{reserve_id}, |
1151 |
is( $matched_reserve->{reserve_id}, |
1152 |
$reserve1->reserve_id, "We got the Transit reserve" ); |
1152 |
$reserve1->reserve_id, "We got the Transit reserve" ); |
1153 |
is( scalar @$possible_reserves, 2, 'We do get both reserves' ); |
1153 |
is( scalar @$possible_reserves, 2, 'We do get both reserves' ); |
|
|
1154 |
|
1155 |
my $patron_B = $builder->build_object({ class => "Koha::Patrons" }); |
1156 |
my $item_A = $builder->build_sample_item; |
1157 |
my $item_B = $builder->build_sample_item({ |
1158 |
homebranch => $patron_B->branchcode, |
1159 |
biblionumber => $item_A->biblionumber, |
1160 |
itype => $item_A->itype |
1161 |
}); |
1162 |
Koha::CirculationRules->set_rules( |
1163 |
{ |
1164 |
branchcode => undef, |
1165 |
categorycode => undef, |
1166 |
itemtype => $item_A->itype, |
1167 |
rules => { |
1168 |
reservesallowed => 25, |
1169 |
holds_per_record => 1, |
1170 |
} |
1171 |
} |
1172 |
); |
1173 |
Koha::CirculationRules->set_rule({ |
1174 |
branchcode => undef, |
1175 |
itemtype => $item_A->itype, |
1176 |
rule_name => 'holdallowed', |
1177 |
rule_value => 1 |
1178 |
}); |
1179 |
my $reserve_id = AddReserve( |
1180 |
{ |
1181 |
branchcode => $patron_B->branchcode, |
1182 |
borrowernumber => $patron_B->borrowernumber, |
1183 |
biblionumber => $item_A->biblionumber, |
1184 |
priority => 1, |
1185 |
itemnumber => undef, |
1186 |
} |
1187 |
); |
1188 |
|
1189 |
ok( $reserve_id, "We can place a record level hold because one item is owned by patron's home library"); |
1190 |
t::lib::Mocks::mock_preference('ReservesControlBranch', 'ItemHomeLibrary'); |
1191 |
( $status, $matched_reserve, $possible_reserves ) = CheckReserves( $item_A->itemnumber ); |
1192 |
is( $status, "", "We do not fill the hold with item A because it is not from the patron's homebranch"); |
1193 |
Koha::CirculationRules->set_rule({ |
1194 |
branchcode => $item_A->homebranch, |
1195 |
itemtype => $item_A->itype, |
1196 |
rule_name => 'holdallowed', |
1197 |
rule_value => 2 |
1198 |
}); |
1199 |
( $status, $matched_reserve, $possible_reserves ) = CheckReserves( $item_A->itemnumber ); |
1200 |
is( $status, "Reserved", "We fill the hold with item A because item's branch rule says allow any"); |
1201 |
|
1202 |
|
1203 |
# Changing the control branch should change only the rule we get |
1204 |
t::lib::Mocks::mock_preference('ReservesControlBranch', 'PatronLibrary'); |
1205 |
( $status, $matched_reserve, $possible_reserves ) = CheckReserves( $item_A->itemnumber ); |
1206 |
is( $status, "", "We do not fill the hold with item A because it is not from the patron's homebranch"); |
1207 |
Koha::CirculationRules->set_rule({ |
1208 |
branchcode => $patron_B->branchcode, |
1209 |
itemtype => $item_A->itype, |
1210 |
rule_name => 'holdallowed', |
1211 |
rule_value => 2 |
1212 |
}); |
1213 |
( $status, $matched_reserve, $possible_reserves ) = CheckReserves( $item_A->itemnumber ); |
1214 |
is( $status, "Reserved", "We fill the hold with item A because patron's branch rule says allow any"); |
1215 |
|
1154 |
}; |
1216 |
}; |
1155 |
|
1217 |
|
1156 |
subtest 'AllowHoldOnPatronPossession test' => sub { |
1218 |
subtest 'AllowHoldOnPatronPossession test' => sub { |
Lines 1250-1260
subtest 'ModReserveAffect logging' => sub {
Link Here
|
1250 |
$hold = Koha::Holds->find($reserve_id); |
1312 |
$hold = Koha::Holds->find($reserve_id); |
1251 |
is( $hold->timestamp, $previous_timestamp, 'Make sure the previous timestamp has been used' ); |
1313 |
is( $hold->timestamp, $previous_timestamp, 'Make sure the previous timestamp has been used' ); |
1252 |
|
1314 |
|
|
|
1315 |
# Avoid warnings |
1316 |
my $reserve_mock = Test::MockModule->new('C4::Reserves'); |
1317 |
$reserve_mock->mock( '_koha_notify_reserve', undef ); |
1318 |
|
1253 |
# Mark it waiting |
1319 |
# Mark it waiting |
1254 |
ModReserveAffect( $item->itemnumber, $patron->borrowernumber ); |
1320 |
ModReserveAffect( $item->itemnumber, $patron->borrowernumber ); |
1255 |
|
1321 |
|
1256 |
$hold = Koha::Holds->find($reserve_id); |
1322 |
$hold->discard_changes; |
1257 |
is( $hold->found, 'W', 'Hold has been set waiting' ); |
1323 |
ok( $hold->is_waiting, 'Hold has been set waiting' ); |
1258 |
isnt( $hold->timestamp, $previous_timestamp, 'The timestamp has been modified' ); |
1324 |
isnt( $hold->timestamp, $previous_timestamp, 'The timestamp has been modified' ); |
1259 |
|
1325 |
|
1260 |
my $log = Koha::ActionLogs->search({ module => 'HOLDS', action => 'MODIFY', object => $hold->reserve_id })->next; |
1326 |
my $log = Koha::ActionLogs->search({ module => 'HOLDS', action => 'MODIFY', object => $hold->reserve_id })->next; |
1261 |
- |
|
|