|
Lines 8-14
use Koha::DateUtils qw( dt_from_string );
Link Here
|
| 8 |
use Koha::Patrons; |
8 |
use Koha::Patrons; |
| 9 |
|
9 |
|
| 10 |
use Test::NoWarnings; |
10 |
use Test::NoWarnings; |
| 11 |
use Test::More tests => 62; |
11 |
use Test::More tests => 64; |
| 12 |
|
12 |
|
| 13 |
use_ok('Koha::Patron'); |
13 |
use_ok('Koha::Patron'); |
| 14 |
|
14 |
|
|
Lines 315-327
my $cpvPmappings = [
Link Here
|
| 315 |
msg => "Same item, same patron [1]", |
315 |
msg => "Same item, same patron [1]", |
| 316 |
item => $item_1, |
316 |
item => $item_1, |
| 317 |
patron => $patron, |
317 |
patron => $patron, |
| 318 |
result => 1, |
318 |
result => "currentlycheckedout", |
| 319 |
}, |
319 |
}, |
| 320 |
{ |
320 |
{ |
| 321 |
msg => "Diff item, same bib, same patron [1]", |
321 |
msg => "Diff item, same bib, same patron [1]", |
| 322 |
item => $item_2, |
322 |
item => $item_2, |
| 323 |
patron => $patron, |
323 |
patron => $patron, |
| 324 |
result => 1, |
324 |
result => "currentlycheckedout", |
| 325 |
}, |
325 |
}, |
| 326 |
{ |
326 |
{ |
| 327 |
msg => "Diff item, diff bib, same patron [0]", |
327 |
msg => "Diff item, diff bib, same patron [0]", |
|
Lines 354-359
test_it( $cpvPmappings, "PostIssue" );
Link Here
|
| 354 |
# Return item_1 from patron: |
354 |
# Return item_1 from patron: |
| 355 |
BAIL_OUT("Return Failed") unless AddReturn( $item_1->{barcode}, $patron->{branchcode} ); |
355 |
BAIL_OUT("Return Failed") unless AddReturn( $item_1->{barcode}, $patron->{branchcode} ); |
| 356 |
|
356 |
|
|
|
357 |
#Since currently checked in item now return status "currentlycheckedout" we need use |
| 358 |
#same test scenarions for returned item as above but without "currentlycheckedout" |
| 359 |
$cpvPmappings = [ |
| 360 |
{ |
| 361 |
msg => "Same item, same patron [1]", |
| 362 |
item => $item_1, |
| 363 |
patron => $patron, |
| 364 |
result => 1, |
| 365 |
}, |
| 366 |
{ |
| 367 |
msg => "Diff item, same bib, same patron [1]", |
| 368 |
item => $item_2, |
| 369 |
patron => $patron, |
| 370 |
result => 1, |
| 371 |
}, |
| 372 |
{ |
| 373 |
msg => "Diff item, diff bib, same patron [0]", |
| 374 |
item => $item_d, |
| 375 |
patron => $patron, |
| 376 |
result => 0, |
| 377 |
}, |
| 378 |
{ |
| 379 |
msg => "Same item, diff patron [0]", |
| 380 |
item => $item_1, |
| 381 |
patron => $patron_d, |
| 382 |
result => 0, |
| 383 |
}, |
| 384 |
{ |
| 385 |
msg => "Diff item, same bib, diff patron [0]", |
| 386 |
item => $item_2, |
| 387 |
patron => $patron_d, |
| 388 |
result => 0, |
| 389 |
}, |
| 390 |
{ |
| 391 |
msg => "Diff item, diff bib, diff patron [0]", |
| 392 |
item => $item_d, |
| 393 |
patron => $patron_d, |
| 394 |
result => 0, |
| 395 |
}, |
| 396 |
]; |
| 397 |
|
| 357 |
# Then: |
398 |
# Then: |
| 358 |
test_it( $cpvPmappings, "PostReturn" ); |
399 |
test_it( $cpvPmappings, "PostReturn" ); |
| 359 |
|
400 |
|
|
Lines 364-370
test_it( $cpvPmappings, "PostReturn" );
Link Here
|
| 364 |
# whetherthe different combinational outcomes of the above return values in |
405 |
# whetherthe different combinational outcomes of the above return values in |
| 365 |
# CanBookBeIssued result in the approriate $needsconfirmation. |
406 |
# CanBookBeIssued result in the approriate $needsconfirmation. |
| 366 |
|
407 |
|
| 367 |
# We want to test: |
408 |
# We want to test when item is currently issued to the patron: |
|
|
409 |
# - DESCRIPTION [RETURNVALUE (0/1)] |
| 410 |
# - patron, !wants_check_for_previous_checkout, !do_check_for_previous_checkout |
| 411 |
# [!$issuingimpossible,!$needsconfirmation->{CURRENTISSUE}] |
| 412 |
# - patron, wants_check_for_previous_checkout, !do_check_for_previous_checkout |
| 413 |
# [!$issuingimpossible,!$needsconfirmation->{CURRENTISSUE}] |
| 414 |
# - patron, !wants_check_for_previous_checkout, do_check_for_previous_checkout |
| 415 |
# [!$issuingimpossible,!$needsconfirmation->{CURRENTISSUE}] |
| 416 |
# - patron, wants_check_for_previous_checkout, do_check_for_previous_checkout |
| 417 |
# [!$issuingimpossible,$needsconfirmation->{CURRENTISSUE}] |
| 418 |
|
| 419 |
# And we also need to test when item has been previously issued to the patron: |
| 368 |
# - DESCRIPTION [RETURNVALUE (0/1)] |
420 |
# - DESCRIPTION [RETURNVALUE (0/1)] |
| 369 |
# - patron, !wants_check_for_previous_checkout, !do_check_for_previous_checkout |
421 |
# - patron, !wants_check_for_previous_checkout, !do_check_for_previous_checkout |
| 370 |
# [!$issuingimpossible,!$needsconfirmation->{PREVISSUE}] |
422 |
# [!$issuingimpossible,!$needsconfirmation->{PREVISSUE}] |
|
Lines 424-429
my $CBBI_mappings = [
Link Here
|
| 424 |
}, |
476 |
}, |
| 425 |
]; |
477 |
]; |
| 426 |
|
478 |
|
|
|
479 |
# Tests |
| 480 |
map { |
| 481 |
t::lib::Mocks::mock_preference( 'checkprevcheckout', $_->{syspref} ); |
| 482 |
my ( $issuingimpossible, $needsconfirmation ) = C4::Circulation::CanBookBeIssued( $patron, $_->{item}->{barcode} ); |
| 483 |
is( $needsconfirmation->{CURRENTISSUE}, $_->{result}, $_->{msg} ); |
| 484 |
} @{$CBBI_mappings}; |
| 485 |
|
| 486 |
# Return $prev_item from patron: |
| 487 |
BAIL_OUT("Return Failed") unless AddReturn( $prev_item->{barcode}, $patron->{branchcode} ); |
| 488 |
|
| 489 |
# Mappings |
| 490 |
$CBBI_mappings = [ |
| 491 |
{ |
| 492 |
syspref => 'hardno', |
| 493 |
item => $prev_item, |
| 494 |
result => undef, |
| 495 |
msg => "patron, !wants_check_for_previous_checkout, do_check_for_previous_checkout" |
| 496 |
}, |
| 497 |
{ |
| 498 |
syspref => 'hardyes', |
| 499 |
item => $prev_item, |
| 500 |
result => 1, |
| 501 |
msg => "patron, wants_check_for_previous_checkout, do_check_for_previous_checkout" |
| 502 |
}, |
| 503 |
]; |
| 504 |
|
| 427 |
# Tests |
505 |
# Tests |
| 428 |
map { |
506 |
map { |
| 429 |
t::lib::Mocks::mock_preference( 'checkprevcheckout', $_->{syspref} ); |
507 |
t::lib::Mocks::mock_preference( 'checkprevcheckout', $_->{syspref} ); |
|
Lines 456-462
subtest 'Check previous checkouts for serial' => sub {
Link Here
|
| 456 |
AddIssue( $patron, $item1->barcode ); |
534 |
AddIssue( $patron, $item1->barcode ); |
| 457 |
|
535 |
|
| 458 |
is( |
536 |
is( |
| 459 |
$patron->do_check_for_previous_checkout( $item1->unblessed ), 1, |
537 |
$patron->do_check_for_previous_checkout( $item1->unblessed ), "currentlycheckedout", |
| 460 |
'Check only one item if bibliographic record is serial' |
538 |
'Check only one item if bibliographic record is serial' |
| 461 |
); |
539 |
); |
| 462 |
is( |
540 |
is( |
| 463 |
- |
|
|