|
Lines 17-23
Link Here
|
| 17 |
|
17 |
|
| 18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
| 19 |
|
19 |
|
| 20 |
use Test::More tests => 53; |
20 |
use Test::More tests => 66; |
| 21 |
use DateTime::Duration; |
21 |
use DateTime::Duration; |
| 22 |
|
22 |
|
| 23 |
use t::lib::Mocks; |
23 |
use t::lib::Mocks; |
|
Lines 641-645
AddReturn( 'barcode_6', $branchcode_1 );
Link Here
|
| 641 |
$item = Koha::Items->find( $itemnumber4 ); |
641 |
$item = Koha::Items->find( $itemnumber4 ); |
| 642 |
ok( $item->notforloan eq 0, q{UpdateNotForLoanStatusOnCheckout does not update notforloan value from 0 with setting "-1: 0"} ); |
642 |
ok( $item->notforloan eq 0, q{UpdateNotForLoanStatusOnCheckout does not update notforloan value from 0 with setting "-1: 0"} ); |
| 643 |
|
643 |
|
|
|
644 |
# Bug 21159 - Update item shelving location on checkout |
| 645 |
my $itemnumber5 = Koha::Item->new( |
| 646 |
{ |
| 647 |
biblionumber => $biblionumber, |
| 648 |
barcode => 'barcode_7', |
| 649 |
itemcallnumber => 'callnumber3', |
| 650 |
homebranch => $branchcode_1, |
| 651 |
holdingbranch => $branchcode_1, |
| 652 |
location => 'FIC', |
| 653 |
itype => $itemtype |
| 654 |
}, |
| 655 |
)->store->itemnumber; |
| 656 |
|
| 657 |
t::lib::Mocks::mock_preference( 'UpdateItemLocationOnCheckout', q{} ); |
| 658 |
t::lib::Mocks::mock_preference( 'UpdateItemLocationOnCheckin', q{} ); |
| 659 |
AddIssue( $patron_1, 'barcode_7'); |
| 660 |
my $item5 = Koha::Items->find( $itemnumber5 ); |
| 661 |
ok( $item5->location eq 'FIC', 'UpdateItemLocationOnCheckout does not modify value when not enabled' ); |
| 662 |
|
| 663 |
#--- |
| 664 |
AddReturn( 'barcode_7', $branchcode_1 ); |
| 665 |
t::lib::Mocks::mock_preference( 'UpdateItemLocationOnCheckout', 'FIC: GEN' ); |
| 666 |
$log_count_before = $schema->resultset('ActionLog')->search({module => 'CATALOGUING'})->count(); |
| 667 |
AddIssue( $patron_1, 'barcode_7' ); |
| 668 |
$item5 = Koha::Items->find( $itemnumber5 ); |
| 669 |
is( $item5->location, 'GEN', q{UpdateItemLocationOnCheckout updates location value from 'FIC' to 'GEN' with setting "FIC: GEN"} ); |
| 670 |
is( $item5->permanent_location, 'GEN', q{UpdateItemLocationOnCheckout updates permanent_location value from 'FIC' to 'GEN' with setting "FIC: GEN"} ); |
| 671 |
$log_count_after = $schema->resultset('ActionLog')->search({module => 'CATALOGUING'})->count(); |
| 672 |
is($log_count_before, $log_count_after, "Change from UpdateNotForLoanStatusOnCheckout is not logged"); |
| 673 |
AddReturn( 'barcode_7', $branchcode_1 ); |
| 674 |
AddIssue( $patron_1, 'barcode_7' ); |
| 675 |
$item5 = Koha::Items->find( $itemnumber5 ); |
| 676 |
ok( $item5->location eq 'GEN', q{UpdateItemLocationOnCheckout does not update location value from 'GEN' with setting "FIC: GEN"} ); |
| 677 |
|
| 678 |
t::lib::Mocks::mock_preference( 'UpdateItemLocationOnCheckout', '_ALL_: CART' ); |
| 679 |
AddReturn( 'barcode_7', $branchcode_1 ); |
| 680 |
AddIssue( $patron_1, 'barcode_7' ); |
| 681 |
$item5 = Koha::Items->find( $itemnumber5 ); |
| 682 |
ok( $item5->location eq 'CART', q{UpdateItemLocationOnCheckout updates location value from 'GEN' with setting "_ALL_: CART"} ); |
| 683 |
ok( $item5->permanent_location eq 'GEN', q{UpdateItemLocationOnCheckout does not update permanent_location value from 'GEN' with setting "_ALL_: CART"} ); |
| 684 |
|
| 685 |
$item5->location('GEN')->store; |
| 686 |
t::lib::Mocks::mock_preference( 'UpdateItemLocationOnCheckout', "GEN: _BLANK_\n_BLANK_: PROC\nPROC: _PERM_" ); |
| 687 |
AddReturn( 'barcode_7', $branchcode_1 ); |
| 688 |
AddIssue( $patron_1, 'barcode_7' ); |
| 689 |
$item5 = Koha::Items->find( $itemnumber5 ); |
| 690 |
ok( $item5->location eq '', q{UpdateItemLocationOnCheckout updates location value from 'GEN' to '' with setting "GEN: _BLANK_"} ); |
| 691 |
AddReturn( 'barcode_7', $branchcode_1 ); |
| 692 |
AddIssue( $patron_1, 'barcode_7' ); |
| 693 |
$item5 = Koha::Items->find( $itemnumber5 ); |
| 694 |
ok( $item5->location eq 'PROC' , q{UpdateItemLocationOnCheckout updates location value from '' to 'PROC' with setting "_BLANK_: PROC"} ); |
| 695 |
ok( $item5->permanent_location eq '' , q{UpdateItemLocationOnCheckout does not update permanent_location value from '' to 'PROC' with setting "_BLANK_: PROC"} ); |
| 696 |
AddReturn( 'barcode_7', $branchcode_1 ); |
| 697 |
AddIssue( $patron_1, 'barcode_7' ); |
| 698 |
$item5 = Koha::Items->find( $itemnumber5 ); |
| 699 |
ok( $item5->location eq '' , q{UpdateItemLocationOnCheckout updates location value from 'PROC' to '' with setting "PROC: _PERM_" } ); |
| 700 |
ok( $item5->permanent_location eq '' , q{UpdateItemLocationOnCheckout does not update permanent_location from '' with setting "PROC: _PERM_" } ); |
| 701 |
|
| 702 |
# Bug 28472 |
| 703 |
my $itemnumber6 = Koha::Item->new( |
| 704 |
{ |
| 705 |
biblionumber => $biblionumber, |
| 706 |
barcode => 'barcode_8', |
| 707 |
itemcallnumber => 'callnumber5', |
| 708 |
homebranch => $branchcode_1, |
| 709 |
holdingbranch => $branchcode_1, |
| 710 |
location => undef, |
| 711 |
itype => $itemtype |
| 712 |
} |
| 713 |
)->store->itemnumber; |
| 714 |
|
| 715 |
t::lib::Mocks::mock_preference( 'UpdateItemLocationOnCheckout', '_ALL_: CART' ); |
| 716 |
AddIssue( $patron_1, 'barcode_8' ); |
| 717 |
my $item6 = Koha::Items->find( $itemnumber6 ); |
| 718 |
is( $item6->location, 'CART', q{UpdateItemLocationOnCheckout updates location value from NULL (i.e. the item has no shelving location set) to 'CART' with setting "_ALL_: CART"} ); |
| 719 |
|
| 720 |
|
| 644 |
#End transaction |
721 |
#End transaction |
| 645 |
$schema->storage->txn_rollback; |
722 |
$schema->storage->txn_rollback; |
| 646 |
- |
|
|