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 <tomascohen@theke.io>
This commit is contained in:
Nick Clemens 2023-03-27 10:58:43 +00:00 committed by Tomas Cohen Arazi
parent 075ef09f48
commit 80f5b33511
Signed by: tomascohen
GPG key ID: 0A272EA1B2F3C15F
2 changed files with 38 additions and 1 deletions

View file

@ -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 );
@ -5818,6 +5818,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();

View file

@ -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,