Lines 17-23
Link Here
|
17 |
|
17 |
|
18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
19 |
|
19 |
|
20 |
use Test::More tests => 52; |
20 |
use Test::More tests => 62; |
21 |
use DateTime::Duration; |
21 |
use DateTime::Duration; |
22 |
|
22 |
|
23 |
use t::lib::Mocks; |
23 |
use t::lib::Mocks; |
Lines 586-619
AddRenewal(
Link Here
|
586 |
my ( $unseen_reset ) = ( C4::Circulation::GetRenewCount( $unseen_patron->borrowernumber, $unseen_item->itemnumber ) )[3]; |
586 |
my ( $unseen_reset ) = ( C4::Circulation::GetRenewCount( $unseen_patron->borrowernumber, $unseen_item->itemnumber ) )[3]; |
587 |
is( $unseen_reset, 0, 'seen renewal resets the unseen count' ); |
587 |
is( $unseen_reset, 0, 'seen renewal resets the unseen count' ); |
588 |
|
588 |
|
|
|
589 |
# Bug 21159 - Update item shelving location on checkout |
589 |
my $itemnumber4 = Koha::Item->new( |
590 |
my $itemnumber4 = Koha::Item->new( |
590 |
{ |
591 |
{ |
591 |
biblionumber => $biblionumber, |
592 |
biblionumber => $biblionumber, |
592 |
barcode => 'barcode_6', |
593 |
barcode => 'barcode_6', |
593 |
itemcallnumber => 'callnumber6', |
594 |
itemcallnumber => 'callnumber3', |
594 |
homebranch => $branchcode_1, |
595 |
homebranch => $branchcode_1, |
595 |
holdingbranch => $branchcode_1, |
596 |
holdingbranch => $branchcode_1, |
596 |
notforloan => -1, |
597 |
location => 'FIC', |
597 |
itype => $itemtype, |
598 |
itype => $itemtype |
598 |
location => 'loc1' |
|
|
599 |
}, |
599 |
}, |
600 |
)->store->itemnumber; |
600 |
)->store->itemnumber; |
|
|
601 |
t::lib::Mocks::mock_preference( 'UpdateItemLocationOnCheckout', q{} ); |
602 |
t::lib::Mocks::mock_preference( 'UpdateItemLocationOnCheckin', q{} ); |
603 |
AddIssue( $borrower_1, 'barcode_6'); |
604 |
my $item4 = Koha::Items->find( $itemnumber4 ); |
605 |
ok( $item4->location eq 'FIC', 'UpdateItemLocationOnCheckout does not modify value when not enabled' ); |
601 |
|
606 |
|
602 |
t::lib::Mocks::mock_preference( 'UpdateNotForLoanStatusOnCheckout', q{} ); |
607 |
#--- |
603 |
AddIssue( $borrower_2, 'barcode_6', dt_from_string ); |
608 |
AddReturn( 'barcode_6', $branchcode_1 ); |
604 |
$item = Koha::Items->find( $itemnumber4 ); |
609 |
t::lib::Mocks::mock_preference( 'UpdateItemLocationOnCheckout', 'FIC: GEN' ); |
605 |
ok( $item->notforloan eq -1, 'UpdateNotForLoanStatusOnCheckout does not modify value when not enabled' ); |
610 |
$log_count_before = $schema->resultset('ActionLog')->search({module => 'CATALOGUING'})->count(); |
|
|
611 |
AddIssue( $borrower_1, 'barcode_6' ); |
612 |
$item4 = Koha::Items->find( $itemnumber4 ); |
613 |
is( $item4->location, 'GEN', q{UpdateItemLocationOnCheckout updates location value from 'FIC' to 'GEN' with setting "FIC: GEN"} ); |
614 |
is( $item4->permanent_location, 'GEN', q{UpdateItemLocationOnCheckout updates permanent_location value from 'FIC' to 'GEN' with setting "FIC: GEN"} ); |
615 |
$log_count_after = $schema->resultset('ActionLog')->search({module => 'CATALOGUING'})->count(); |
616 |
is($log_count_before, $log_count_after, "Change from UpdateNotForLoanStatusOnCheckout is not logged"); |
617 |
AddReturn( 'barcode_6', $branchcode_1 ); |
618 |
AddIssue( $borrower_1, 'barcode_6' ); |
619 |
$item4 = Koha::Items->find( $itemnumber4 ); |
620 |
ok( $item4->location eq 'GEN', q{UpdateItemLocationOnCheckout does not update location value from 'GEN' with setting "FIC: GEN"} ); |
606 |
|
621 |
|
607 |
t::lib::Mocks::mock_preference( 'UpdateNotForLoanStatusOnCheckout', '-1: 0' ); |
622 |
t::lib::Mocks::mock_preference( 'UpdateItemLocationOnCheckout', '_ALL_: CART' ); |
608 |
AddReturn( 'barcode_6', $branchcode_1 ); |
623 |
AddReturn( 'barcode_6', $branchcode_1 ); |
609 |
my $test = AddIssue( $borrower_2, 'barcode_6', dt_from_string ); |
624 |
AddIssue( $borrower_1, 'barcode_6' ); |
610 |
$item = Koha::Items->find( $itemnumber4 ); |
625 |
$item4 = Koha::Items->find( $itemnumber4 ); |
611 |
ok( $item->notforloan eq 0, q{UpdateNotForLoanStatusOnCheckout updates notforloan value from -1 to 0 with setting "-1: 0"} ); |
626 |
ok( $item4->location eq 'CART', q{UpdateItemLocationOnCheckout updates location value from 'GEN' with setting "_ALL_: CART"} ); |
|
|
627 |
ok( $item4->permanent_location eq 'GEN', q{UpdateItemLocationOnCheckout does not update permanent_location value from 'GEN' with setting "_ALL_: CART"} ); |
612 |
|
628 |
|
613 |
AddIssue( $borrower_2, 'barcode_6', dt_from_string ); |
629 |
$item4->location('GEN')->store; |
|
|
630 |
t::lib::Mocks::mock_preference( 'UpdateItemLocationOnCheckout', "GEN: _BLANK_\n_BLANK_: PROC\nPROC: _PERM_" ); |
631 |
AddReturn( 'barcode_6', $branchcode_1 ); |
632 |
AddIssue( $borrower_1, 'barcode_6' ); |
633 |
$item4 = Koha::Items->find( $itemnumber4 ); |
634 |
ok( $item4->location eq '', q{UpdateItemLocationOnCheckout updates location value from 'GEN' to '' with setting "GEN: _BLANK_"} ); |
614 |
AddReturn( 'barcode_6', $branchcode_1 ); |
635 |
AddReturn( 'barcode_6', $branchcode_1 ); |
615 |
$item = Koha::Items->find( $itemnumber4 ); |
636 |
AddIssue( $borrower_1, 'barcode_6' ); |
616 |
ok( $item->notforloan eq 0, q{UpdateNotForLoanStatusOnCheckout does not update notforloan value from 0 with setting "-1: 0"} ); |
637 |
$item4 = Koha::Items->find( $itemnumber4 ); |
|
|
638 |
ok( $item4->location eq 'PROC' , q{UpdateItemLocationOnCheckout updates location value from '' to 'PROC' with setting "_BLANK_: PROC"} ); |
639 |
ok( $item4->permanent_location eq '' , q{UpdateItemLocationOnCheckout does not update permanent_location value from '' to 'PROC' with setting "_BLANK_: PROC"} ); |
640 |
AddReturn( 'barcode_6', $branchcode_1 ); |
641 |
AddIssue( $borrower_1, 'barcode_6' ); |
642 |
$item4 = Koha::Items->find( $itemnumber4 ); |
643 |
ok( $item4->location eq '' , q{UpdateItemLocationOnCheckout updates location value from 'PROC' to '' with setting "PROC: _PERM_" } ); |
644 |
ok( $item4->permanent_location eq '' , q{UpdateItemLocationOnCheckout does not update permanent_location from '' with setting "PROC: _PERM_" } ); |
645 |
|
646 |
# Bug 28472 |
647 |
my $itemnumber5 = Koha::Item->new( |
648 |
{ |
649 |
biblionumber => $biblionumber, |
650 |
barcode => 'barcode_7', |
651 |
itemcallnumber => 'callnumber5', |
652 |
homebranch => $branchcode_1, |
653 |
holdingbranch => $branchcode_1, |
654 |
location => undef, |
655 |
itype => $itemtype |
656 |
} |
657 |
)->store->itemnumber; |
658 |
|
659 |
t::lib::Mocks::mock_preference( 'UpdateItemLocationOnCheckout', '_ALL_: CART' ); |
660 |
AddIssue( $borrower_1, 'barcode_7' ); |
661 |
my $item5 = Koha::Items->find( $itemnumber5 ); |
662 |
is( $item5->location, 'CART', q{UpdateItemLocationOnCheckout updates location value from NULL (i.e. the item has no shelving location set) to 'CART' with setting "_ALL_: CART"} ); |
663 |
|
617 |
|
664 |
|
618 |
#End transaction |
665 |
#End transaction |
619 |
$schema->storage->txn_rollback; |
666 |
$schema->storage->txn_rollback; |
620 |
- |
|
|