From f36ee62251a24fbd52372c23c6691da772fabfdd Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Fri, 8 Jan 2016 20:43:31 +0000 Subject: [PATCH] Bug 14576 - Unit tests --- t/db_dependent/Circulation/issue.t | 53 +++++++++++++++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Circulation/issue.t b/t/db_dependent/Circulation/issue.t index a28b1c5..2698ae4 100644 --- a/t/db_dependent/Circulation/issue.t +++ b/t/db_dependent/Circulation/issue.t @@ -28,7 +28,7 @@ use C4::Context; use C4::Reserves; use Koha::Library; -use Test::More tests => 32; +use Test::More tests => 44; BEGIN { use_ok('C4::Circulation'); @@ -388,6 +388,57 @@ AddReturn( 'barcode_3', $samplebranch1->{branchcode} ); $item = GetItem( $itemnumber ); ok( $item->{notforloan} eq 9, q{UpdateNotForLoanStatusOnCheckin does not update notforloan value from 9 with setting "1: 9"} ); +my $itemnumber2; +($biblionumber, $biblioitemnumber, $itemnumber2) = C4::Items::AddItem( + { + barcode => 'barcode_4', + itemcallnumber => 'callnumber4', + homebranch => $samplebranch1->{branchcode}, + holdingbranch => $samplebranch1->{branchcode}, + location => 'FIC', + }, + $biblionumber +); + +C4::Context->set_preference( 'UpdateItemLocationOnCheckin', q{} ); +AddReturn( 'barcode_4', $samplebranch1->{branchcode} ); +my $item2 = GetItem( $itemnumber2 ); +ok( $item2->{location} eq 'FIC', 'UpdateItemLocationOnCheckin does not modify value when not enabled' ); + +C4::Context->set_preference( 'UpdateItemLocationOnCheckin', 'FIC: GEN' ); +AddReturn( 'barcode_4', $samplebranch1->{branchcode} ); +$item2 = GetItem( $itemnumber2 ); +ok( $item2->{location} eq 'GEN', q{UpdateItemLocationOnCheckin updates location value from 'FIC' to 'GEN' with setting "FIC: GEN"} ); +ok( $item2->{permanent_location} eq 'GEN', q{UpdateItemLocationOnCheckin updates permanent_location value from 'FIC' to 'GEN' with setting "FIC: GEN"} ); +AddReturn( 'barcode_4', $samplebranch1->{branchcode} ); +$item2 = GetItem( $itemnumber2 ); +ok( $item2->{location} eq 'GEN', q{UpdateItemLocationOnCheckin does not update location value from 'GEN' with setting "FIC: GEN"} ); + +C4::Context->set_preference( 'UpdateItemLocationOnCheckin', '_ALL_: CART' ); +AddReturn( 'barcode_4', $samplebranch1->{branchcode} ); +$item2 = GetItem( $itemnumber2 ); +ok( $item2->{location} eq 'CART', q{UpdateItemLocationOnCheckin updates location value from 'GEN' with setting "_ALL_: CART"} ); +ok( $item2->{permanent_location} eq 'GEN', q{UpdateItemLocationOnCheckin does not update permanent_location value from 'GEN' with setting "_ALL_: CART"} ); +AddIssue( $borrower_1, 'barcode_4', $daysago10,0, $today, '' ); +$item2 = GetItem( $itemnumber2 ); +ok( $item2->{location} eq 'GEN', q{Location updates from 'CART' to permanent location on issue} ); + +C4::Context->set_preference( 'UpdateItemLocationOnCheckin', "GEN: _BLANK_\n_BLANK_: PROC\nPROC: _PERM_" ); +AddReturn( 'barcode_4', $samplebranch1->{branchcode} ); +$item2 = GetItem( $itemnumber2 ); +ok( $item2->{location} eq '', q{UpdateItemLocationOnCheckin updates location value from 'GEN' to '' with setting "GEN: _BLANK_"} ); +AddReturn( 'barcode_4', $samplebranch1->{branchcode} ); +$item2 = GetItem( $itemnumber2 ); +ok( $item2->{location} eq 'PROC' , q{UpdateItemLocationOnCheckin updates location value from '' to 'PROC' with setting "_BLANK_: PROC"} ); +ok( $item2->{permanent_location} eq '' , q{UpdateItemLocationOnCheckin does not update permanent_location value from '' to 'PROC' with setting "_BLANK_: PROC"} ); +AddReturn( 'barcode_4', $samplebranch1->{branchcode} ); +$item2 = GetItem( $itemnumber2 ); +ok( $item2->{location} eq '' , q{UpdateItemLocationOnCheckin updates location value from 'PROC' to '' with setting "PROC: _PERM_" } ); +ok( $item2->{permanent_location} eq '' , q{UpdateItemLocationOnCheckin does not update permanent_location from '' with setting "PROC: _PERM_" } ); + + + + # Bug 14640 - Cancel the hold on checking out if asked my $reserve_id = AddReserve('CPL', $borrower_id1, $biblionumber, undef, 1, undef, undef, "a note", "a title", undef, ''); -- 2.1.4