Lines 18-24
Link Here
|
18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
19 |
use utf8; |
19 |
use utf8; |
20 |
|
20 |
|
21 |
use Test::More tests => 127; |
21 |
use Test::More tests => 129; |
22 |
use Test::MockModule; |
22 |
use Test::MockModule; |
23 |
|
23 |
|
24 |
use Data::Dumper; |
24 |
use Data::Dumper; |
Lines 327-332
my ( $reused_itemnumber_1, $reused_itemnumber_2 );
Link Here
|
327 |
my $borrowing_borrowernumber = Koha::Checkouts->find( { itemnumber => $item_1->itemnumber } )->borrowernumber; |
327 |
my $borrowing_borrowernumber = Koha::Checkouts->find( { itemnumber => $item_1->itemnumber } )->borrowernumber; |
328 |
is ($borrowing_borrowernumber, $renewing_borrowernumber, "Item checked out to $renewing_borrower->{firstname} $renewing_borrower->{surname}"); |
328 |
is ($borrowing_borrowernumber, $renewing_borrowernumber, "Item checked out to $renewing_borrower->{firstname} $renewing_borrower->{surname}"); |
329 |
|
329 |
|
|
|
330 |
t::lib::Mocks::mock_preference('CircControl', 'PatronLibrary'); |
330 |
my ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_1->itemnumber, 1); |
331 |
my ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_1->itemnumber, 1); |
331 |
is( $renewokay, 1, 'Can renew, no holds for this title or item'); |
332 |
is( $renewokay, 1, 'Can renew, no holds for this title or item'); |
332 |
|
333 |
|
Lines 1192-1197
my ( $reused_itemnumber_1, $reused_itemnumber_2 );
Link Here
|
1192 |
is( $error, 'onsite_checkout', 'A correct error code should be returned by CanBookBeRenewed for on-site checkout' ); |
1193 |
is( $error, 'onsite_checkout', 'A correct error code should be returned by CanBookBeRenewed for on-site checkout' ); |
1193 |
} |
1194 |
} |
1194 |
|
1195 |
|
|
|
1196 |
{ |
1197 |
# Don't allow renewing on reserve period with PreventCheckoutOnSameReservePeriod enabled |
1198 |
t::lib::Mocks::mock_preference( 'PreventCheckoutOnSameReservePeriod', 1 ); |
1199 |
|
1200 |
my $start_issue_dt = DateTime->now(); |
1201 |
$start_issue_dt->subtract( days => 15); |
1202 |
my $due_date = $start_issue_dt->clone; |
1203 |
$due_date->add( days => 17 ); |
1204 |
|
1205 |
my $biblio = $builder->build({ |
1206 |
source => 'Biblio', |
1207 |
}); |
1208 |
my $biblionumber = $biblio->{biblionumber}; |
1209 |
|
1210 |
my $item = $builder->build({ |
1211 |
source => 'Item', |
1212 |
value => { |
1213 |
biblionumber => $biblionumber |
1214 |
} |
1215 |
}); |
1216 |
my $itemnumber = $item->{itemnumber}; |
1217 |
|
1218 |
my $issue = $builder->build({ |
1219 |
source => 'Issue', |
1220 |
value => { |
1221 |
itemnumber => $itemnumber, |
1222 |
biblionumber => $biblionumber, |
1223 |
issuedate => $start_issue_dt->ymd, |
1224 |
date_due => $due_date->ymd, |
1225 |
onsite_checkout => 0 |
1226 |
} |
1227 |
}); |
1228 |
|
1229 |
my $reservedate = $due_date->clone; |
1230 |
$reservedate->add( days => 5 ); |
1231 |
my $expirationdate = $reservedate->clone; |
1232 |
$expirationdate->add( days => 15 ); |
1233 |
$builder->build({ |
1234 |
source => 'Reserve', |
1235 |
value => { |
1236 |
biblionumber => $biblionumber, |
1237 |
itemnumber => $itemnumber, |
1238 |
reservedate => $reservedate->ymd, |
1239 |
expirationdate => $expirationdate->ymd |
1240 |
} |
1241 |
}); |
1242 |
|
1243 |
my $requested_date_due = $due_date->clone; |
1244 |
$requested_date_due->add( days => 4 ); |
1245 |
my ( $renewed, $error ) = CanBookBeRenewed( $issue->{borrowernumber}, $itemnumber, 1, $requested_date_due ); |
1246 |
is( $renewed, 1, 'CanBookBeRenewed should allow to renew if no reserve date overlap' ); |
1247 |
|
1248 |
$requested_date_due->add( days => 2 ); |
1249 |
( $renewed, $error ) = CanBookBeRenewed( $issue->{borrowernumber}, $itemnumber, 1, $requested_date_due ); |
1250 |
is( $renewed, 0, 'CanBookBeRenewed should not allow to renew if reserve date overlap' ); |
1251 |
|
1252 |
t::lib::Mocks::mock_preference( 'PreventCheckoutOnSameReservePeriod', 0 ); |
1253 |
} |
1254 |
|
1195 |
{ |
1255 |
{ |
1196 |
my $library = $builder->build({ source => 'Branch' }); |
1256 |
my $library = $builder->build({ source => 'Branch' }); |
1197 |
|
1257 |
|
1198 |
- |
|
|