Bug 40385: Remove warning from Reserves/CancelExpiredReserves.t

t/db_dependent/Reserves/CancelExpiredReserves.t .. 3/4 No reserves HOLD_CANCELLATION letter transported by email at /kohadevbox/koha/C4/Letters.pm line 602.

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 10b673ee1c)
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
This commit is contained in:
Jonathan Druart 2025-07-15 14:35:40 +02:00 committed by Paul Derscheid
parent 37341f2994
commit 305d081a4e
No known key found for this signature in database
GPG Key ID: C25F9FD44CED595B
1 changed files with 10 additions and 2 deletions

View File

@ -1,7 +1,9 @@
#!/usr/bin/perl
use Modern::Perl;
use Test::More tests => 4;
use Test::More tests => 5;
use Test::NoWarnings;
use Test::MockModule;
use t::lib::Mocks;
use t::lib::TestBuilder;
@ -240,7 +242,13 @@ subtest 'Test handling of cancellation reason if passed' => sub {
);
my $reserve_id = $reserve->{reserve_id};
my $count = Koha::Holds->search->count;
CancelExpiredReserves("EXPIRED");
{
# Prevent warning 'No reserves HOLD_CANCELLATION letter transported by email'
my $mock_letters = Test::MockModule->new('C4::Letters');
$mock_letters->mock( 'GetPreparedLetter', sub { return } );
CancelExpiredReserves("EXPIRED");
}
is( Koha::Holds->search->count, $count - 1, "Hold is cancelled when reason is passed" );
my $old_reserve = Koha::Old::Holds->find($reserve_id);
is( $old_reserve->cancellation_reason, 'EXPIRED', "Hold cancellation_reason was set correctly" );