From c56bc38e58356284b343db4d1acccdc6121a1137 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 Signed-off-by: Martin Renvoize --- 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 5df382edf50..b7152c4e71b 100755 --- a/t/db_dependent/Koha/Item.t +++ b/t/db_dependent/Koha/Item.t @@ -762,7 +762,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' } ); @@ -822,6 +822,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.39.2