|
Lines 17-24
Link Here
|
| 17 |
|
17 |
|
| 18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
| 19 |
|
19 |
|
| 20 |
use Test::NoWarnings; |
20 |
use Test::More tests => 60; |
| 21 |
use Test::More tests => 67; |
|
|
| 22 |
use DateTime::Duration; |
21 |
use DateTime::Duration; |
| 23 |
|
22 |
|
| 24 |
use t::lib::Mocks; |
23 |
use t::lib::Mocks; |
|
Lines 435-517
ok(
Link Here
|
| 435 |
$return->{returndate} eq '2014-04-01 23:42:00', |
434 |
$return->{returndate} eq '2014-04-01 23:42:00', |
| 436 |
"Item returned with a return date of '2014-04-01 23:42' has that return date" |
435 |
"Item returned with a return date of '2014-04-01 23:42' has that return date" |
| 437 |
); |
436 |
); |
|
|
437 |
subtest 'AddIssue Update notforloanstatus according to UpdateNotForLoanStatusOnCheckin' => sub { |
| 438 |
plan tests => 7; |
| 439 |
my $itemnumber = Koha::Item->new( |
| 440 |
{ |
| 441 |
biblionumber => $biblionumber, |
| 442 |
barcode => 'barcode_3', |
| 443 |
itemcallnumber => 'callnumber3', |
| 444 |
homebranch => $branchcode_1, |
| 445 |
holdingbranch => $branchcode_1, |
| 446 |
notforloan => 1, |
| 447 |
itype => $itemtype, |
| 448 |
biblioitemnumber => $biblioitemnumber |
| 449 |
}, |
| 450 |
)->store->itemnumber; |
| 438 |
|
451 |
|
| 439 |
my $itemnumber = Koha::Item->new( |
452 |
t::lib::Mocks::mock_preference( 'UpdateNotForLoanStatusOnCheckin', q{} ); |
| 440 |
{ |
453 |
t::lib::Mocks::mock_preference( 'CataloguingLog', 1 ); |
| 441 |
biblionumber => $biblionumber, |
454 |
my $log_count_before = $schema->resultset('ActionLog')->search( { module => 'CATALOGUING' } )->count(); |
| 442 |
barcode => 'barcode_3', |
455 |
|
| 443 |
itemcallnumber => 'callnumber3', |
456 |
AddReturn( 'barcode_3', $branchcode_1 ); |
| 444 |
homebranch => $branchcode_1, |
457 |
my $item = Koha::Items->find($itemnumber); |
| 445 |
holdingbranch => $branchcode_1, |
458 |
ok( $item->notforloan eq 1, 'UpdateNotForLoanStatusOnCheckin does not modify value when not enabled' ); |
| 446 |
notforloan => 1, |
459 |
|
| 447 |
itype => $itemtype, |
460 |
my $updatenotforloanstatusoncheckin = " |
| 448 |
biblioitemnumber => $biblioitemnumber |
461 |
_ALL_:\n |
| 449 |
}, |
462 |
1: 0\n |
| 450 |
)->store->itemnumber; |
463 |
9: 1\n\n |
| 451 |
|
464 |
$itemtype:\n |
| 452 |
t::lib::Mocks::mock_preference( 'UpdateNotForLoanStatusOnCheckin', q{} ); |
465 |
1: 9 |
| 453 |
t::lib::Mocks::mock_preference( 'CataloguingLog', 1 ); |
466 |
"; |
| 454 |
my $log_count_before = $schema->resultset('ActionLog')->search( { module => 'CATALOGUING' } )->count(); |
467 |
t::lib::Mocks::mock_preference( 'UpdateNotForLoanStatusOnCheckin', $updatenotforloanstatusoncheckin ); |
| 455 |
|
468 |
AddReturn( 'barcode_3', $branchcode_1 ); |
| 456 |
AddReturn( 'barcode_3', $branchcode_1 ); |
469 |
$item = Koha::Items->find($itemnumber); |
| 457 |
my $item = Koha::Items->find($itemnumber); |
470 |
ok( |
| 458 |
ok( $item->notforloan eq 1, 'UpdateNotForLoanStatusOnCheckin does not modify value when not enabled' ); |
471 |
$item->notforloan eq 9, |
| 459 |
|
472 |
q{UpdateNotForLoanStatusOnCheckin prioritises item type specific rule over _ALL_ rules} |
| 460 |
my $updatenotforloanstatusoncheckin = " |
473 |
); |
| 461 |
_ALL_:\n |
474 |
my $log_count_after = $schema->resultset('ActionLog')->search( { module => 'CATALOGUING' } )->count(); |
| 462 |
1: 0\n |
475 |
is( $log_count_before, $log_count_after, "Change from UpdateNotForLoanStatusOnCheckin is not logged" ); |
| 463 |
9: 1\n\n |
|
|
| 464 |
$itemtype:\n |
| 465 |
1: 9 |
| 466 |
"; |
| 467 |
t::lib::Mocks::mock_preference( 'UpdateNotForLoanStatusOnCheckin', $updatenotforloanstatusoncheckin ); |
| 468 |
AddReturn( 'barcode_3', $branchcode_1 ); |
| 469 |
$item = Koha::Items->find($itemnumber); |
| 470 |
ok( $item->notforloan eq 9, q{UpdateNotForLoanStatusOnCheckin prioritises item type specific rule over _ALL_ rules} ); |
| 471 |
my $log_count_after = $schema->resultset('ActionLog')->search( { module => 'CATALOGUING' } )->count(); |
| 472 |
is( $log_count_before, $log_count_after, "Change from UpdateNotForLoanStatusOnCheckin is not logged" ); |
| 473 |
|
476 |
|
| 474 |
AddReturn( 'barcode_3', $branchcode_1 ); |
477 |
AddReturn( 'barcode_3', $branchcode_1 ); |
| 475 |
$item = Koha::Items->find($itemnumber); |
478 |
$item = Koha::Items->find($itemnumber); |
| 476 |
ok( |
479 |
ok( |
| 477 |
$item->notforloan eq 9, |
480 |
$item->notforloan eq 9, |
| 478 |
q{UpdateNotForLoanStatusOnCheckin uses item type specific rules even if they do not target the returned items' notforloan value} |
481 |
q{UpdateNotForLoanStatusOnCheckin uses item type specific rules even if they do not target the returned items' notforloan value} |
| 479 |
); |
482 |
); |
| 480 |
|
483 |
|
| 481 |
# Change the returning item to an item type without a rule |
484 |
# Change the returning item to an item type without a rule |
| 482 |
Koha::Items->find($itemnumber)->itype($itemtype2)->store; |
485 |
Koha::Items->find($itemnumber)->itype($itemtype2)->store; |
| 483 |
Koha::Items->find($itemnumber)->notforloan(1)->store; |
486 |
Koha::Items->find($itemnumber)->notforloan(1)->store; |
| 484 |
AddReturn( 'barcode_3', $branchcode_1 ); |
487 |
AddReturn( 'barcode_3', $branchcode_1 ); |
| 485 |
$item = Koha::Items->find($itemnumber); |
488 |
$item = Koha::Items->find($itemnumber); |
| 486 |
ok( |
489 |
ok( |
| 487 |
$item->notforloan eq 0, |
490 |
$item->notforloan eq 0, |
| 488 |
q{UpdateNotForLoanStatusOnCheckin _ALL_ rules are applied if there are no specific item type rule matching the returned item} |
491 |
q{UpdateNotForLoanStatusOnCheckin _ALL_ rules are applied if there are no specific item type rule matching the returned item} |
| 489 |
); |
492 |
); |
| 490 |
|
493 |
|
| 491 |
t::lib::Mocks::mock_preference( |
494 |
t::lib::Mocks::mock_preference( |
| 492 |
'UpdateNotForLoanStatusOnCheckin', q{_ALL_: |
495 |
'UpdateNotForLoanStatusOnCheckin', q{_ALL_: |
| 493 |
1: ONLYMESSAGE |
496 |
1: ONLYMESSAGE |
| 494 |
} |
497 |
} |
| 495 |
); |
498 |
); |
| 496 |
$item->notforloan(1)->store; |
499 |
$item->notforloan(1)->store; |
| 497 |
AddReturn( 'barcode_3', $branchcode_1 ); |
500 |
AddReturn( 'barcode_3', $branchcode_1 ); |
| 498 |
$item->discard_changes; |
501 |
$item->discard_changes; |
| 499 |
is( |
502 |
is( |
| 500 |
$item->notforloan, 1, |
503 |
$item->notforloan, 1, |
| 501 |
q{UpdateNotForLoanStatusOnCheckin does not update notforloan value from 1 for _ALL_ with setting "1: ONLYMESSAGE"} |
504 |
q{UpdateNotForLoanStatusOnCheckin does not update notforloan value from 1 for _ALL_ with setting "1: ONLYMESSAGE"} |
| 502 |
); |
505 |
); |
| 503 |
|
506 |
|
| 504 |
t::lib::Mocks::mock_preference( |
507 |
t::lib::Mocks::mock_preference( |
| 505 |
'UpdateNotForLoanStatusOnCheckin', "$itemtype:\n |
508 |
'UpdateNotForLoanStatusOnCheckin', "$itemtype:\n |
| 506 |
1: ONLYMESSAGE |
509 |
1: ONLYMESSAGE |
| 507 |
" |
510 |
" |
| 508 |
); |
511 |
); |
| 509 |
AddReturn( 'barcode_3', $branchcode_1 ); |
512 |
AddReturn( 'barcode_3', $branchcode_1 ); |
| 510 |
$item->discard_changes; |
513 |
$item->discard_changes; |
| 511 |
is( |
514 |
is( |
| 512 |
$item->notforloan, 1, |
515 |
$item->notforloan, 1, |
| 513 |
q{UpdateNotForLoanStatusOnCheckin does not update notforloan value for specific itemtype from 1 with setting "1: ONLYMESSAGE"} |
516 |
q{UpdateNotForLoanStatusOnCheckin does not update notforloan value for specific itemtype from 1 with setting "1: ONLYMESSAGE"} |
| 514 |
); |
517 |
); |
|
|
518 |
}; |
| 515 |
|
519 |
|
| 516 |
############################################## |
520 |
############################################## |
| 517 |
# |
521 |
# |
|
Lines 537-543
subtest 'AddReturn: Update notforloanstatus according to UpdateNotForLoanStatusO
Link Here
|
| 537 |
|
541 |
|
| 538 |
t::lib::Mocks::mock_preference( 'UpdateNotForLoanStatusOnCheckout', q{} ); |
542 |
t::lib::Mocks::mock_preference( 'UpdateNotForLoanStatusOnCheckout', q{} ); |
| 539 |
AddIssue( $patron_2, 'barcode_6', dt_from_string ); |
543 |
AddIssue( $patron_2, 'barcode_6', dt_from_string ); |
| 540 |
$item = Koha::Items->find($itemnumber4); |
544 |
my $item = Koha::Items->find($itemnumber4); |
| 541 |
ok( $item->notforloan eq -1, 'UpdateNotForLoanStatusOnCheckout does not modify value when not enabled' ); |
545 |
ok( $item->notforloan eq -1, 'UpdateNotForLoanStatusOnCheckout does not modify value when not enabled' ); |
| 542 |
AddReturn( 'barcode_6', $branchcode_1 ); |
546 |
AddReturn( 'barcode_6', $branchcode_1 ); |
| 543 |
|
547 |
|
|
Lines 629-635
subtest '_updateNotForLoanFromYaml' => sub {
Link Here
|
| 629 |
|
633 |
|
| 630 |
t::lib::Mocks::mock_preference( 'UpdateNotForLoanStatusOnCheckout', q{} ); |
634 |
t::lib::Mocks::mock_preference( 'UpdateNotForLoanStatusOnCheckout', q{} ); |
| 631 |
t::lib::Mocks::mock_preference( 'UpdateNotForLoanStatusOnCheckin', q{} ); |
635 |
t::lib::Mocks::mock_preference( 'UpdateNotForLoanStatusOnCheckin', q{} ); |
| 632 |
$item = Koha::Items->find($itemnumber4); |
636 |
my $item = Koha::Items->find($itemnumber4); |
| 633 |
$item->notforloan(-1)->store; |
637 |
$item->notforloan(-1)->store; |
| 634 |
C4::Circulation::_updateNotForLoanFromYaml( $item, 'UpdateNotForLoanStatusOnCheckout' ); |
638 |
C4::Circulation::_updateNotForLoanFromYaml( $item, 'UpdateNotForLoanStatusOnCheckout' ); |
| 635 |
ok( |
639 |
ok( |
|
Lines 772-778
my $item2 = Koha::Items->find($itemnumber2);
Link Here
|
| 772 |
ok( $item2->location eq 'FIC', 'UpdateItemLocationOnCheckin does not modify value when not enabled' ); |
776 |
ok( $item2->location eq 'FIC', 'UpdateItemLocationOnCheckin does not modify value when not enabled' ); |
| 773 |
|
777 |
|
| 774 |
t::lib::Mocks::mock_preference( 'UpdateItemLocationOnCheckin', 'FIC: GEN' ); |
778 |
t::lib::Mocks::mock_preference( 'UpdateItemLocationOnCheckin', 'FIC: GEN' ); |
| 775 |
$log_count_before = $schema->resultset('ActionLog')->search( { module => 'CATALOGUING' } )->count(); |
779 |
my $log_count_before = $schema->resultset('ActionLog')->search( { module => 'CATALOGUING' } )->count(); |
| 776 |
AddReturn( 'barcode_4', $branchcode_1 ); |
780 |
AddReturn( 'barcode_4', $branchcode_1 ); |
| 777 |
$item2 = Koha::Items->find($itemnumber2); |
781 |
$item2 = Koha::Items->find($itemnumber2); |
| 778 |
is( |
782 |
is( |
|
Lines 783-789
is(
Link Here
|
| 783 |
$item2->permanent_location, 'GEN', |
787 |
$item2->permanent_location, 'GEN', |
| 784 |
q{UpdateItemLocationOnCheckin updates permanent_location value from 'FIC' to 'GEN' with setting "FIC: GEN"} |
788 |
q{UpdateItemLocationOnCheckin updates permanent_location value from 'FIC' to 'GEN' with setting "FIC: GEN"} |
| 785 |
); |
789 |
); |
| 786 |
$log_count_after = $schema->resultset('ActionLog')->search( { module => 'CATALOGUING' } )->count(); |
790 |
my $log_count_after = $schema->resultset('ActionLog')->search( { module => 'CATALOGUING' } )->count(); |
| 787 |
is( $log_count_before, $log_count_after, "Change from UpdateNotForLoanStatusOnCheckin is not logged" ); |
791 |
is( $log_count_before, $log_count_after, "Change from UpdateNotForLoanStatusOnCheckin is not logged" ); |
| 788 |
AddReturn( 'barcode_4', $branchcode_1 ); |
792 |
AddReturn( 'barcode_4', $branchcode_1 ); |
| 789 |
$item2 = Koha::Items->find($itemnumber2); |
793 |
$item2 = Koha::Items->find($itemnumber2); |
| 790 |
- |
|
|