From 6ad606073d3cc1e756b2cb59a5014e632427a20f 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 Signed-off-by: Cathi Wiggins Signed-off-by: Megan Wianecki Signed-off-by: Kyle M Hall --- t/db_dependent/Circulation/issue.t | 53 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/t/db_dependent/Circulation/issue.t b/t/db_dependent/Circulation/issue.t index 22f4d0a..e3d3207 100644 --- a/t/db_dependent/Circulation/issue.t +++ b/t/db_dependent/Circulation/issue.t @@ -33,6 +33,8 @@ use Koha::Database; use Koha::DateUtils; use Koha::Library; +use Test::More tests => 44; + BEGIN { require_ok('C4::Circulation'); } @@ -363,6 +365,57 @@ AddReturn( 'barcode_3', $branchcode_1 ); $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($branchcode_1, $borrower_id1, $biblionumber, undef, 1, undef, undef, "a note", "a title", undef, ''); -- 2.1.4