Lines 17-23
Link Here
|
17 |
|
17 |
|
18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
19 |
|
19 |
|
20 |
use Test::More tests => 66; |
20 |
use Test::More tests => 60; |
21 |
use DateTime::Duration; |
21 |
use DateTime::Duration; |
22 |
|
22 |
|
23 |
use t::lib::Mocks; |
23 |
use t::lib::Mocks; |
Lines 417-494
C4::Circulation::AddIssue( $patron_1, $barcode_1, $daysago10, 0, $today );
Link Here
|
417 |
AddReturn($barcode_1, undef, undef, dt_from_string('2014-04-01 23:42')); |
417 |
AddReturn($barcode_1, undef, undef, dt_from_string('2014-04-01 23:42')); |
418 |
$return = $dbh->selectrow_hashref("SELECT * FROM old_issues LIMIT 1" ); |
418 |
$return = $dbh->selectrow_hashref("SELECT * FROM old_issues LIMIT 1" ); |
419 |
ok( $return->{returndate} eq '2014-04-01 23:42:00', "Item returned with a return date of '2014-04-01 23:42' has that return date" ); |
419 |
ok( $return->{returndate} eq '2014-04-01 23:42:00', "Item returned with a return date of '2014-04-01 23:42' has that return date" ); |
|
|
420 |
subtest 'AddIssue Update notforloanstatus according to UpdateNotForLoanStatusOnCheckin' => sub { |
421 |
plan tests => 7; |
422 |
my $itemnumber = Koha::Item->new( |
423 |
{ |
424 |
biblionumber => $biblionumber, |
425 |
barcode => 'barcode_3', |
426 |
itemcallnumber => 'callnumber3', |
427 |
homebranch => $branchcode_1, |
428 |
holdingbranch => $branchcode_1, |
429 |
notforloan => 1, |
430 |
itype => $itemtype, |
431 |
biblioitemnumber => $biblioitemnumber |
432 |
}, |
433 |
)->store->itemnumber; |
420 |
|
434 |
|
421 |
my $itemnumber = Koha::Item->new( |
435 |
t::lib::Mocks::mock_preference( 'UpdateNotForLoanStatusOnCheckin', q{} ); |
422 |
{ |
436 |
t::lib::Mocks::mock_preference( 'CataloguingLog', 1 ); |
423 |
biblionumber => $biblionumber, |
437 |
my $log_count_before = $schema->resultset('ActionLog')->search( { module => 'CATALOGUING' } )->count(); |
424 |
barcode => 'barcode_3', |
438 |
|
425 |
itemcallnumber => 'callnumber3', |
439 |
AddReturn( 'barcode_3', $branchcode_1 ); |
426 |
homebranch => $branchcode_1, |
440 |
my $item = Koha::Items->find($itemnumber); |
427 |
holdingbranch => $branchcode_1, |
441 |
ok( $item->notforloan eq 1, 'UpdateNotForLoanStatusOnCheckin does not modify value when not enabled' ); |
428 |
notforloan => 1, |
442 |
|
429 |
itype => $itemtype, |
443 |
my $updatenotforloanstatusoncheckin = " |
430 |
biblioitemnumber => $biblioitemnumber |
444 |
_ALL_:\n |
431 |
}, |
445 |
1: 0\n |
432 |
)->store->itemnumber; |
446 |
9: 1\n\n |
433 |
|
447 |
$itemtype:\n |
434 |
t::lib::Mocks::mock_preference( 'UpdateNotForLoanStatusOnCheckin', q{} ); |
448 |
1: 9 |
435 |
t::lib::Mocks::mock_preference( 'CataloguingLog', 1 ); |
449 |
"; |
436 |
my $log_count_before = $schema->resultset('ActionLog')->search({module => 'CATALOGUING'})->count(); |
450 |
t::lib::Mocks::mock_preference( 'UpdateNotForLoanStatusOnCheckin', $updatenotforloanstatusoncheckin ); |
437 |
|
451 |
AddReturn( 'barcode_3', $branchcode_1 ); |
438 |
AddReturn( 'barcode_3', $branchcode_1 ); |
452 |
$item = Koha::Items->find($itemnumber); |
439 |
my $item = Koha::Items->find( $itemnumber ); |
453 |
ok( |
440 |
ok( $item->notforloan eq 1, 'UpdateNotForLoanStatusOnCheckin does not modify value when not enabled' ); |
454 |
$item->notforloan eq 9, |
441 |
|
455 |
q{UpdateNotForLoanStatusOnCheckin prioritises item type specific rule over _ALL_ rules} |
442 |
my $updatenotforloanstatusoncheckin = " |
456 |
); |
443 |
_ALL_:\n |
457 |
my $log_count_after = $schema->resultset('ActionLog')->search( { module => 'CATALOGUING' } )->count(); |
444 |
1: 0\n |
458 |
is( $log_count_before, $log_count_after, "Change from UpdateNotForLoanStatusOnCheckin is not logged" ); |
445 |
9: 1\n\n |
|
|
446 |
$itemtype:\n |
447 |
1: 9 |
448 |
"; |
449 |
t::lib::Mocks::mock_preference( 'UpdateNotForLoanStatusOnCheckin', $updatenotforloanstatusoncheckin ); |
450 |
AddReturn( 'barcode_3', $branchcode_1 ); |
451 |
$item = Koha::Items->find( $itemnumber ); |
452 |
ok( $item->notforloan eq 9, q{UpdateNotForLoanStatusOnCheckin prioritises item type specific rule over _ALL_ rules} ); |
453 |
my $log_count_after = $schema->resultset('ActionLog')->search({module => 'CATALOGUING'})->count(); |
454 |
is($log_count_before, $log_count_after, "Change from UpdateNotForLoanStatusOnCheckin is not logged"); |
455 |
|
456 |
AddReturn( 'barcode_3', $branchcode_1 ); |
457 |
$item = Koha::Items->find( $itemnumber ); |
458 |
ok( $item->notforloan eq 9, q{UpdateNotForLoanStatusOnCheckin uses item type specific rules even if they do not target the returned items' notforloan value} ); |
459 |
|
459 |
|
460 |
# Change the returning item to an item type without a rule |
460 |
AddReturn( 'barcode_3', $branchcode_1 ); |
461 |
Koha::Items->find( $itemnumber )->itype( $itemtype2 )->store; |
461 |
$item = Koha::Items->find($itemnumber); |
462 |
Koha::Items->find( $itemnumber )->notforloan( 1 )->store; |
462 |
ok( |
463 |
AddReturn( 'barcode_3', $branchcode_1 ); |
463 |
$item->notforloan eq 9, |
464 |
$item = Koha::Items->find( $itemnumber ); |
464 |
q{UpdateNotForLoanStatusOnCheckin uses item type specific rules even if they do not target the returned items' notforloan value} |
465 |
ok( $item->notforloan eq 0, q{UpdateNotForLoanStatusOnCheckin _ALL_ rules are applied if there are no specific item type rule matching the returned item} ); |
465 |
); |
466 |
|
466 |
|
467 |
t::lib::Mocks::mock_preference( |
467 |
# Change the returning item to an item type without a rule |
468 |
'UpdateNotForLoanStatusOnCheckin', q{_ALL_: |
468 |
Koha::Items->find($itemnumber)->itype($itemtype2)->store; |
469 |
1: ONLYMESSAGE |
469 |
Koha::Items->find($itemnumber)->notforloan(1)->store; |
470 |
} |
470 |
AddReturn( 'barcode_3', $branchcode_1 ); |
471 |
); |
471 |
$item = Koha::Items->find($itemnumber); |
472 |
$item->notforloan(1)->store; |
472 |
ok( |
473 |
AddReturn( 'barcode_3', $branchcode_1 ); |
473 |
$item->notforloan eq 0, |
474 |
$item->discard_changes; |
474 |
q{UpdateNotForLoanStatusOnCheckin _ALL_ rules are applied if there are no specific item type rule matching the returned item} |
475 |
is( |
475 |
); |
476 |
$item->notforloan, 1, |
|
|
477 |
q{UpdateNotForLoanStatusOnCheckin does not update notforloan value from 1 for _ALL_ with setting "1: ONLYMESSAGE"} |
478 |
); |
479 |
|
476 |
|
|
|
477 |
t::lib::Mocks::mock_preference( |
478 |
'UpdateNotForLoanStatusOnCheckin', q{_ALL_: |
479 |
1: ONLYMESSAGE |
480 |
} |
481 |
); |
482 |
$item->notforloan(1)->store; |
483 |
AddReturn( 'barcode_3', $branchcode_1 ); |
484 |
$item->discard_changes; |
485 |
is( |
486 |
$item->notforloan, 1, |
487 |
q{UpdateNotForLoanStatusOnCheckin does not update notforloan value from 1 for _ALL_ with setting "1: ONLYMESSAGE"} |
488 |
); |
480 |
|
489 |
|
481 |
t::lib::Mocks::mock_preference( |
490 |
t::lib::Mocks::mock_preference( |
482 |
'UpdateNotForLoanStatusOnCheckin', "$itemtype:\n |
491 |
'UpdateNotForLoanStatusOnCheckin', "$itemtype:\n |
483 |
1: ONLYMESSAGE |
492 |
1: ONLYMESSAGE |
484 |
" |
493 |
" |
485 |
); |
494 |
); |
486 |
AddReturn( 'barcode_3', $branchcode_1 ); |
495 |
AddReturn( 'barcode_3', $branchcode_1 ); |
487 |
$item->discard_changes; |
496 |
$item->discard_changes; |
488 |
is( |
497 |
is( |
489 |
$item->notforloan, 1, |
498 |
$item->notforloan, 1, |
490 |
q{UpdateNotForLoanStatusOnCheckin does not update notforloan value for specific itemtype from 1 with setting "1: ONLYMESSAGE"} |
499 |
q{UpdateNotForLoanStatusOnCheckin does not update notforloan value for specific itemtype from 1 with setting "1: ONLYMESSAGE"} |
491 |
); |
500 |
); |
|
|
501 |
}; |
492 |
|
502 |
|
493 |
############################################## |
503 |
############################################## |
494 |
# |
504 |
# |
Lines 514-520
subtest 'AddReturn: Update notforloanstatus according to UpdateNotForLoanStatusO
Link Here
|
514 |
|
524 |
|
515 |
t::lib::Mocks::mock_preference( 'UpdateNotForLoanStatusOnCheckout', q{} ); |
525 |
t::lib::Mocks::mock_preference( 'UpdateNotForLoanStatusOnCheckout', q{} ); |
516 |
AddIssue( $patron_2, 'barcode_6', dt_from_string ); |
526 |
AddIssue( $patron_2, 'barcode_6', dt_from_string ); |
517 |
$item = Koha::Items->find($itemnumber4); |
527 |
my $item = Koha::Items->find($itemnumber4); |
518 |
ok( $item->notforloan eq -1, 'UpdateNotForLoanStatusOnCheckout does not modify value when not enabled' ); |
528 |
ok( $item->notforloan eq -1, 'UpdateNotForLoanStatusOnCheckout does not modify value when not enabled' ); |
519 |
AddReturn( 'barcode_6', $branchcode_1 ); |
529 |
AddReturn( 'barcode_6', $branchcode_1 ); |
520 |
|
530 |
|
Lines 606-612
subtest '_updateNotForLoanFromYaml' => sub {
Link Here
|
606 |
|
616 |
|
607 |
t::lib::Mocks::mock_preference( 'UpdateNotForLoanStatusOnCheckout', q{} ); |
617 |
t::lib::Mocks::mock_preference( 'UpdateNotForLoanStatusOnCheckout', q{} ); |
608 |
t::lib::Mocks::mock_preference( 'UpdateNotForLoanStatusOnCheckin', q{} ); |
618 |
t::lib::Mocks::mock_preference( 'UpdateNotForLoanStatusOnCheckin', q{} ); |
609 |
$item = Koha::Items->find($itemnumber4); |
619 |
my $item = Koha::Items->find($itemnumber4); |
610 |
$item->notforloan(-1)->store; |
620 |
$item->notforloan(-1)->store; |
611 |
C4::Circulation::_updateNotForLoanFromYaml( $item, 'UpdateNotForLoanStatusOnCheckout' ); |
621 |
C4::Circulation::_updateNotForLoanFromYaml( $item, 'UpdateNotForLoanStatusOnCheckout' ); |
612 |
ok( |
622 |
ok( |
Lines 749-760
my $item2 = Koha::Items->find( $itemnumber2 );
Link Here
|
749 |
ok( $item2->location eq 'FIC', 'UpdateItemLocationOnCheckin does not modify value when not enabled' ); |
759 |
ok( $item2->location eq 'FIC', 'UpdateItemLocationOnCheckin does not modify value when not enabled' ); |
750 |
|
760 |
|
751 |
t::lib::Mocks::mock_preference( 'UpdateItemLocationOnCheckin', 'FIC: GEN' ); |
761 |
t::lib::Mocks::mock_preference( 'UpdateItemLocationOnCheckin', 'FIC: GEN' ); |
752 |
$log_count_before = $schema->resultset('ActionLog')->search({module => 'CATALOGUING'})->count(); |
762 |
my $log_count_before = $schema->resultset('ActionLog')->search({module => 'CATALOGUING'})->count(); |
753 |
AddReturn( 'barcode_4', $branchcode_1 ); |
763 |
AddReturn( 'barcode_4', $branchcode_1 ); |
754 |
$item2 = Koha::Items->find( $itemnumber2 ); |
764 |
$item2 = Koha::Items->find( $itemnumber2 ); |
755 |
is( $item2->location, 'GEN', q{UpdateItemLocationOnCheckin updates location value from 'FIC' to 'GEN' with setting "FIC: GEN"} ); |
765 |
is( $item2->location, 'GEN', q{UpdateItemLocationOnCheckin updates location value from 'FIC' to 'GEN' with setting "FIC: GEN"} ); |
756 |
is( $item2->permanent_location, 'GEN', q{UpdateItemLocationOnCheckin updates permanent_location value from 'FIC' to 'GEN' with setting "FIC: GEN"} ); |
766 |
is( $item2->permanent_location, 'GEN', q{UpdateItemLocationOnCheckin updates permanent_location value from 'FIC' to 'GEN' with setting "FIC: GEN"} ); |
757 |
$log_count_after = $schema->resultset('ActionLog')->search({module => 'CATALOGUING'})->count(); |
767 |
my $log_count_after = $schema->resultset('ActionLog')->search({module => 'CATALOGUING'})->count(); |
758 |
is($log_count_before, $log_count_after, "Change from UpdateNotForLoanStatusOnCheckin is not logged"); |
768 |
is($log_count_before, $log_count_after, "Change from UpdateNotForLoanStatusOnCheckin is not logged"); |
759 |
AddReturn( 'barcode_4', $branchcode_1 ); |
769 |
AddReturn( 'barcode_4', $branchcode_1 ); |
760 |
$item2 = Koha::Items->find( $itemnumber2 ); |
770 |
$item2 = Koha::Items->find( $itemnumber2 ); |
761 |
- |
|
|