From 559ac79c47701aef410624a9b0996b38ad8d73c8 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Mon, 27 Mar 2023 10:58:43 +0000 Subject: [PATCH] Bug 29234: Unit test This patch adds a test that a pending stock rotation transfer is initiated on checkin, as well as updating the defaults for creating transfer objects To test: prove -v t/db_dependent/Circulation.t Signed-off-by: Tomas Cohen Arazi (cherry picked from commit 80f5b3351123225b93ab9b85a30b0428790234bf) Signed-off-by: Matt Blenkinsop --- t/db_dependent/Circulation.t | 27 ++++++++++++++++++++++++++- t/lib/TestBuilder.pm | 12 ++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t index d998d83c85..56c476fd3a 100755 --- a/t/db_dependent/Circulation.t +++ b/t/db_dependent/Circulation.t @@ -18,7 +18,7 @@ use Modern::Perl; use utf8; -use Test::More tests => 65; +use Test::More tests => 66; use Test::Exception; use Test::MockModule; use Test::Deep qw( cmp_deeply ); @@ -5811,6 +5811,31 @@ subtest 'Tests for BlockReturnOfWithdrawnItems' => sub { [ 0, { NotIssued => $item->barcode, withdrawn => 1 }, undef, {} ], "Item returned as withdrawn, no other messages"); }; +subtest 'Tests for transfer not in transit' => sub { + + plan tests => 2; + + + # These tests are to ensure a 'pending' transfer, generated by + # stock rotation, will be advanced when checked in + + my $item = $builder->build_sample_item(); + my $transfer = $builder->build_object({ class => 'Koha::Item::Transfers', value => { + itemnumber => $item->id, + reason => 'StockrotationRepatriation', + datesent => undef, + frombranch => $item->homebranch, + }}); + my @return = AddReturn( $item->barcode, $item->homebranch, 0, undef ); + is_deeply( + \@return, + [ 0, { WasTransfered => $transfer->tobranch, TransferTrigger => 'StockrotationRepatriation', NotIssued => $item->barcode }, undef, {} ], "Item is reported to have been transferred"); + + $transfer->discard_changes; + ok( $transfer->datesent, 'The datesent field is populated, i.e. transfer is initiated'); + +}; + $schema->storage->txn_rollback; C4::Context->clear_syspref_cache(); $branches = Koha::Libraries->search(); diff --git a/t/lib/TestBuilder.pm b/t/lib/TestBuilder.pm index 8f8d79699a..59137b143e 100644 --- a/t/lib/TestBuilder.pm +++ b/t/lib/TestBuilder.pm @@ -590,6 +590,18 @@ sub _gen_default_values { materials => undef, more_subfields_xml => undef, }, + Branchtransfer => { + daterequested => dt_from_string(), + datesent => dt_from_string(), + datearrived => undef, + datecancelled => undef, + reason => undef, + withdrawn => 0, + restricted => 0, + damaged => 0, + materials => undef, + more_subfields_xml => undef, + }, Category => { enrolmentfee => 0, reservefee => 0, -- 2.39.5