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 <nick@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
Martin Renvoize 2024-01-04 12:09:47 +00:00
parent 5b8cb21fb9
commit 08cecd6c6f
Signed by: martin.renvoize
GPG key ID: 422B469130441A0F

View file

@ -846,7 +846,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' } );
@ -906,6 +906,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');