Lines 9-15
use C4::Items;
Link Here
|
9 |
use C4::Members; |
9 |
use C4::Members; |
10 |
use C4::Reserves; |
10 |
use C4::Reserves; |
11 |
|
11 |
|
12 |
use Test::More tests => 38; |
12 |
use Test::More tests => 44; |
13 |
|
13 |
|
14 |
BEGIN { |
14 |
BEGIN { |
15 |
use_ok('C4::Circulation'); |
15 |
use_ok('C4::Circulation'); |
Lines 336-343
C4::Context->dbh->do("DELETE FROM accountlines");
Link Here
|
336 |
# GetUpcomingDueIssues tests |
336 |
# GetUpcomingDueIssues tests |
337 |
my $barcode = 'R00000342'; |
337 |
my $barcode = 'R00000342'; |
338 |
my $barcode2 = 'R00000343'; |
338 |
my $barcode2 = 'R00000343'; |
|
|
339 |
my $barcode3 = 'R00000344'; |
339 |
my $branch = 'MPL'; |
340 |
my $branch = 'MPL'; |
340 |
|
341 |
|
|
|
342 |
#Create another record |
343 |
my $biblio2 = MARC::Record->new(); |
344 |
my $title2 = 'Something is worng here'; |
345 |
$biblio2->append_fields( |
346 |
MARC::Field->new('100', ' ', ' ', a => 'Anonymous'), |
347 |
MARC::Field->new('245', ' ', ' ', a => $title2), |
348 |
); |
349 |
my ($biblionumber2, $biblioitemnumber2) = AddBiblio($biblio2, ''); |
350 |
|
351 |
#Create third item |
352 |
AddItem( |
353 |
{ |
354 |
homebranch => $branch, |
355 |
holdingbranch => $branch, |
356 |
barcode => $barcode3 |
357 |
}, |
358 |
$biblionumber2 |
359 |
); |
360 |
|
341 |
# Create a borrower |
361 |
# Create a borrower |
342 |
my %a_borrower_data = ( |
362 |
my %a_borrower_data = ( |
343 |
firstname => 'Fridolyn', |
363 |
firstname => 'Fridolyn', |
Lines 351-373
C4::Context->dbh->do("DELETE FROM accountlines");
Link Here
|
351 |
|
371 |
|
352 |
my $yesterday = DateTime->today(time_zone => C4::Context->tz())->add( days => -1 ); |
372 |
my $yesterday = DateTime->today(time_zone => C4::Context->tz())->add( days => -1 ); |
353 |
my $two_days_ahead = DateTime->today(time_zone => C4::Context->tz())->add( days => 2 ); |
373 |
my $two_days_ahead = DateTime->today(time_zone => C4::Context->tz())->add( days => 2 ); |
|
|
374 |
my $today = DateTime->today(time_zone => C4::Context->tz()); |
354 |
|
375 |
|
355 |
my $datedue = AddIssue( $a_borrower, $barcode, $yesterday ); |
376 |
my $datedue = AddIssue( $a_borrower, $barcode, $yesterday ); |
356 |
my $datedue2 = AddIssue( $a_borrower, $barcode2, $two_days_ahead ); |
377 |
my $datedue2 = AddIssue( $a_borrower, $barcode2, $two_days_ahead ); |
357 |
|
378 |
|
|
|
379 |
my $upcoming_dues; |
380 |
|
358 |
diag( "GetUpcomingDueIssues tests" ); |
381 |
diag( "GetUpcomingDueIssues tests" ); |
359 |
|
382 |
|
360 |
for my $i(0..2) { |
383 |
for my $i(0..1) { |
361 |
my $upcoming_dues = C4::Circulation::GetUpcomingDueIssues( { days_in_advance => $i } ); |
384 |
$upcoming_dues = C4::Circulation::GetUpcomingDueIssues( { days_in_advance => $i } ); |
362 |
is ( scalar( @$upcoming_dues ), 0, "No items due in less than two days ($i days in advance)" ); |
385 |
is ( scalar( @$upcoming_dues ), 0, "No items due in less than one day ($i days in advance)" ); |
363 |
} |
386 |
} |
364 |
|
387 |
|
|
|
388 |
#days_in_advance needs to be inclusive, so 1 matches items due tomorrow, 0 items due today etc. |
389 |
$upcoming_dues = C4::Circulation::GetUpcomingDueIssues( { days_in_advance => 2 } ); |
390 |
is ( scalar ( @$upcoming_dues), 1, "Only one item due in 2 days or less" ); |
391 |
|
365 |
for my $i(3..5) { |
392 |
for my $i(3..5) { |
366 |
my $upcoming_dues = C4::Circulation::GetUpcomingDueIssues( { days_in_advance => $i } ); |
393 |
$upcoming_dues = C4::Circulation::GetUpcomingDueIssues( { days_in_advance => $i } ); |
367 |
is ( scalar( @$upcoming_dues ), 1, |
394 |
is ( scalar( @$upcoming_dues ), 1, |
368 |
"Bug 9362: Only one item due in more than 2 days ($i days in advance)" ); |
395 |
"Bug 9362: Only one item due in more than 2 days ($i days in advance)" ); |
369 |
} |
396 |
} |
370 |
|
397 |
|
|
|
398 |
# Bug 11218 - Due notices not generated - GetUpcomingDueIssues needs to select due today items as well |
399 |
|
400 |
my $datedue2 = AddIssue( $a_borrower, $barcode3, $today ); |
401 |
|
402 |
$upcoming_dues = C4::Circulation::GetUpcomingDueIssues( { days_in_advance => -1 } ); |
403 |
is ( scalar ( @$upcoming_dues), 0, "Overdues can not be selected" ); |
404 |
|
405 |
$upcoming_dues = C4::Circulation::GetUpcomingDueIssues( { days_in_advance => 0 } ); |
406 |
is ( scalar ( @$upcoming_dues), 1, "1 item is due today" ); |
407 |
|
408 |
$upcoming_dues = C4::Circulation::GetUpcomingDueIssues( { days_in_advance => 1 } ); |
409 |
is ( scalar ( @$upcoming_dues), 1, "1 item is due today, none tomorrow" ); |
410 |
|
411 |
$upcoming_dues = C4::Circulation::GetUpcomingDueIssues( { days_in_advance => 2 } ); |
412 |
is ( scalar ( @$upcoming_dues), 2, "2 items are due withing 2 days" ); |
413 |
|
414 |
$upcoming_dues = C4::Circulation::GetUpcomingDueIssues( { days_in_advance => 3 } ); |
415 |
is ( scalar ( @$upcoming_dues), 2, "2 items are due withing 2 days" ); |
416 |
|
417 |
$upcoming_dues = C4::Circulation::GetUpcomingDueIssues(); |
418 |
is ( scalar ( @$upcoming_dues), 2, "days_in_advance is 7 in GetUpcomingDueIssues if not provided" ); |
419 |
|
371 |
} |
420 |
} |
372 |
|
421 |
|
373 |
$dbh->rollback; |
422 |
$dbh->rollback; |
374 |
- |
|
|