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 => 45; |
21 |
use Test::More tests => 47; |
22 |
use Test::MockModule; |
22 |
use Test::MockModule; |
23 |
|
23 |
|
24 |
use Data::Dumper; |
24 |
use Data::Dumper; |
Lines 382-387
subtest "CanBookBeRenewed tests" => sub {
Link Here
|
382 |
my $borrowing_borrowernumber = Koha::Checkouts->find( { itemnumber => $item_1->itemnumber } )->borrowernumber; |
382 |
my $borrowing_borrowernumber = Koha::Checkouts->find( { itemnumber => $item_1->itemnumber } )->borrowernumber; |
383 |
is ($borrowing_borrowernumber, $renewing_borrowernumber, "Item checked out to $renewing_borrower->{firstname} $renewing_borrower->{surname}"); |
383 |
is ($borrowing_borrowernumber, $renewing_borrowernumber, "Item checked out to $renewing_borrower->{firstname} $renewing_borrower->{surname}"); |
384 |
|
384 |
|
|
|
385 |
t::lib::Mocks::mock_preference('CircControl', 'PatronLibrary'); |
385 |
my ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_1->itemnumber, 1); |
386 |
my ( $renewokay, $error ) = CanBookBeRenewed($renewing_borrowernumber, $item_1->itemnumber, 1); |
386 |
is( $renewokay, 1, 'Can renew, no holds for this title or item'); |
387 |
is( $renewokay, 1, 'Can renew, no holds for this title or item'); |
387 |
|
388 |
|
Lines 1250-1255
subtest "AllowRenewalIfOtherItemsAvailable tests" => sub {
Link Here
|
1250 |
is( $error, 'onsite_checkout', 'A correct error code should be returned by CanBookBeRenewed for on-site checkout' ); |
1251 |
is( $error, 'onsite_checkout', 'A correct error code should be returned by CanBookBeRenewed for on-site checkout' ); |
1251 |
} |
1252 |
} |
1252 |
|
1253 |
|
|
|
1254 |
{ |
1255 |
# Don't allow renewing on reserve period with PreventCheckoutOnSameReservePeriod enabled |
1256 |
t::lib::Mocks::mock_preference( 'PreventCheckoutOnSameReservePeriod', 1 ); |
1257 |
|
1258 |
my $start_issue_dt = DateTime->now(); |
1259 |
$start_issue_dt->subtract( days => 15); |
1260 |
my $due_date = $start_issue_dt->clone; |
1261 |
$due_date->add( days => 17 ); |
1262 |
|
1263 |
my $biblio = $builder->build({ |
1264 |
source => 'Biblio', |
1265 |
}); |
1266 |
my $biblionumber = $biblio->{biblionumber}; |
1267 |
|
1268 |
my $item = $builder->build({ |
1269 |
source => 'Item', |
1270 |
value => { |
1271 |
biblionumber => $biblionumber |
1272 |
} |
1273 |
}); |
1274 |
my $itemnumber = $item->{itemnumber}; |
1275 |
|
1276 |
my $issue = $builder->build({ |
1277 |
source => 'Issue', |
1278 |
value => { |
1279 |
itemnumber => $itemnumber, |
1280 |
biblionumber => $biblionumber, |
1281 |
issuedate => $start_issue_dt->ymd, |
1282 |
date_due => $due_date->ymd, |
1283 |
onsite_checkout => 0 |
1284 |
} |
1285 |
}); |
1286 |
|
1287 |
my $reservedate = $due_date->clone; |
1288 |
$reservedate->add( days => 5 ); |
1289 |
my $expirationdate = $reservedate->clone; |
1290 |
$expirationdate->add( days => 15 ); |
1291 |
$builder->build({ |
1292 |
source => 'Reserve', |
1293 |
value => { |
1294 |
biblionumber => $biblionumber, |
1295 |
itemnumber => $itemnumber, |
1296 |
reservedate => $reservedate->ymd, |
1297 |
expirationdate => $expirationdate->ymd |
1298 |
} |
1299 |
}); |
1300 |
|
1301 |
my $requested_date_due = $due_date->clone; |
1302 |
$requested_date_due->add( days => 4 ); |
1303 |
my ( $renewed, $error ) = CanBookBeRenewed( $issue->{borrowernumber}, $itemnumber, 1, $requested_date_due ); |
1304 |
is( $renewed, 1, 'CanBookBeRenewed should allow to renew if no reserve date overlap' ); |
1305 |
|
1306 |
$requested_date_due->add( days => 2 ); |
1307 |
( $renewed, $error ) = CanBookBeRenewed( $issue->{borrowernumber}, $itemnumber, 1, $requested_date_due ); |
1308 |
is( $renewed, 0, 'CanBookBeRenewed should not allow to renew if reserve date overlap' ); |
1309 |
|
1310 |
t::lib::Mocks::mock_preference( 'PreventCheckoutOnSameReservePeriod', 0 ); |
1311 |
} |
1312 |
|
1253 |
{ |
1313 |
{ |
1254 |
my $library = $builder->build({ source => 'Branch' }); |
1314 |
my $library = $builder->build({ source => 'Branch' }); |
1255 |
|
1315 |
|
1256 |
- |
|
|