From e8f72565a8b6b95dcbd91371df0217c4ca2b85b5 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Thu, 4 Jan 2024 12:09:47 +0000 Subject: [PATCH] Bug 35100: Unit tests This patch adds a unit test to ensure StockrotationAdvance transfers are not cancelled from request_transfer when called with 'replace'. Signed-off-by: Nick Clemens --- t/db_dependent/Koha/Item.t | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Koha/Item.t b/t/db_dependent/Koha/Item.t index 7a21db18f55..05d19ad1165 100755 --- a/t/db_dependent/Koha/Item.t +++ b/t/db_dependent/Koha/Item.t @@ -757,7 +757,7 @@ subtest 'pickup_locations() tests' => sub { }; subtest 'request_transfer' => sub { - plan tests => 13; + plan tests => 17; $schema->storage->txn_begin; my $library1 = $builder->build_object( { class => 'Koha::Libraries' } ); @@ -817,6 +817,24 @@ subtest 'request_transfer' => sub { is($transfers->count, 1, "There is only 1 live transfer in the queue"); $replaced_transfer->datearrived(dt_from_string)->store(); + # Replace StockrotationAdvance transfer + my $stock_transfer = $item->request_transfer( { to => $library1, reason => 'StockrotationAdvance' } ); + is( + ref($stock_transfer), 'Koha::Item::Transfer', + 'Koha::Item->request_transfer added StockrotationAdvance transfer' + ); + $replaced_transfer = $item->request_transfer( { to => $library2, reason => 'Manual', replace => 1 } ); + is( + ref($replaced_transfer), 'Koha::Item::Transfer', + 'Koha::Item->request_transfer allowed when replace is set' + ); + $stock_transfer->discard_changes; + is( $stock_transfer->datecancelled, undef, "StockrotationAdvance transfer left intact" ); + $transfers = $item->get_transfers; + is( $transfers->count, 2, "There are now 2 live transfers in the queue" ); + $replaced_transfer->datearrived(dt_from_string)->store(); + $stock_transfer->datearrived(dt_from_string)->store(); + # BranchTransferLimits t::lib::Mocks::mock_preference('UseBranchTransferLimits', 1); t::lib::Mocks::mock_preference('BranchTransferLimitsType', 'itemtype'); -- 2.30.2