Lines 1077-1085
subtest 'RevertWaitingStatus' => sub {
Link Here
|
1077 |
); |
1077 |
); |
1078 |
}; |
1078 |
}; |
1079 |
|
1079 |
|
1080 |
subtest 'CheckReserves additional test' => sub { |
1080 |
subtest 'CheckReserves additional tests' => sub { |
1081 |
|
1081 |
|
1082 |
plan tests => 3; |
1082 |
plan tests => 8; |
1083 |
|
1083 |
|
1084 |
my $item = $builder->build_sample_item; |
1084 |
my $item = $builder->build_sample_item; |
1085 |
my $reserve1 = $builder->build_object( |
1085 |
my $reserve1 = $builder->build_object( |
Lines 1152-1157
subtest 'CheckReserves additional test' => sub {
Link Here
|
1152 |
is( $matched_reserve->{reserve_id}, |
1152 |
is( $matched_reserve->{reserve_id}, |
1153 |
$reserve1->reserve_id, "We got the Transit reserve" ); |
1153 |
$reserve1->reserve_id, "We got the Transit reserve" ); |
1154 |
is( scalar @$possible_reserves, 2, 'We do get both reserves' ); |
1154 |
is( scalar @$possible_reserves, 2, 'We do get both reserves' ); |
|
|
1155 |
|
1156 |
my $patron_B = $builder->build_object({ class => "Koha::Patrons" }); |
1157 |
my $item_A = $builder->build_sample_item; |
1158 |
my $item_B = $builder->build_sample_item({ |
1159 |
homebranch => $patron_B->branchcode, |
1160 |
biblionumber => $item_A->biblionumber, |
1161 |
itype => $item_A->itype |
1162 |
}); |
1163 |
Koha::CirculationRules->set_rules( |
1164 |
{ |
1165 |
branchcode => undef, |
1166 |
categorycode => undef, |
1167 |
itemtype => $item_A->itype, |
1168 |
rules => { |
1169 |
reservesallowed => 25, |
1170 |
holds_per_record => 1, |
1171 |
} |
1172 |
} |
1173 |
); |
1174 |
Koha::CirculationRules->set_rule({ |
1175 |
branchcode => undef, |
1176 |
itemtype => $item_A->itype, |
1177 |
rule_name => 'holdallowed', |
1178 |
rule_value => 'from_home_library' |
1179 |
}); |
1180 |
my $reserve_id = AddReserve( |
1181 |
{ |
1182 |
branchcode => $patron_B->branchcode, |
1183 |
borrowernumber => $patron_B->borrowernumber, |
1184 |
biblionumber => $item_A->biblionumber, |
1185 |
priority => 1, |
1186 |
itemnumber => undef, |
1187 |
} |
1188 |
); |
1189 |
|
1190 |
ok( $reserve_id, "We can place a record level hold because one item is owned by patron's home library"); |
1191 |
t::lib::Mocks::mock_preference('ReservesControlBranch', 'ItemHomeLibrary'); |
1192 |
( $status, $matched_reserve, $possible_reserves ) = CheckReserves( $item_A->itemnumber ); |
1193 |
is( $status, "", "We do not fill the hold with item A because it is not from the patron's homebranch"); |
1194 |
Koha::CirculationRules->set_rule({ |
1195 |
branchcode => $item_A->homebranch, |
1196 |
itemtype => $item_A->itype, |
1197 |
rule_name => 'holdallowed', |
1198 |
rule_value => 'from_any_library' |
1199 |
}); |
1200 |
( $status, $matched_reserve, $possible_reserves ) = CheckReserves( $item_A->itemnumber ); |
1201 |
is( $status, "Reserved", "We fill the hold with item A because item's branch rule says allow any"); |
1202 |
|
1203 |
|
1204 |
# Changing the control branch should change only the rule we get |
1205 |
t::lib::Mocks::mock_preference('ReservesControlBranch', 'PatronLibrary'); |
1206 |
( $status, $matched_reserve, $possible_reserves ) = CheckReserves( $item_A->itemnumber ); |
1207 |
is( $status, "", "We do not fill the hold with item A because it is not from the patron's homebranch"); |
1208 |
Koha::CirculationRules->set_rule({ |
1209 |
branchcode => $patron_B->branchcode, |
1210 |
itemtype => $item_A->itype, |
1211 |
rule_name => 'holdallowed', |
1212 |
rule_value => 'from_any_library' |
1213 |
}); |
1214 |
( $status, $matched_reserve, $possible_reserves ) = CheckReserves( $item_A->itemnumber ); |
1215 |
is( $status, "Reserved", "We fill the hold with item A because patron's branch rule says allow any"); |
1216 |
|
1155 |
}; |
1217 |
}; |
1156 |
|
1218 |
|
1157 |
subtest 'AllowHoldOnPatronPossession test' => sub { |
1219 |
subtest 'AllowHoldOnPatronPossession test' => sub { |
1158 |
- |
|
|