From 969d7c7f9d05e00be48a7836839f8759494c1308 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 19 Sep 2023 11:14:42 +0200 Subject: [PATCH] Bug 12532: Fix test The mock was working. The problem was that the to_address of the notice was set from the previous send. A fix would be to update the message, but it seems better to simply re-enqueue it. This patch also use Koha::Notice::Messages. --- t/db_dependent/Letters.t | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/t/db_dependent/Letters.t b/t/db_dependent/Letters.t index 88af0b0b580..66d51acdc5e 100755 --- a/t/db_dependent/Letters.t +++ b/t/db_dependent/Letters.t @@ -957,7 +957,7 @@ subtest 'Test SMS handling in SendQueuedMessages' => sub { subtest 'Test guarantor handling in SendQueuedMessages' => sub { - plan tests => 8; + plan tests => 7; t::lib::Mocks::mock_preference( 'borrowerRelationship', 'test' ); @@ -1012,18 +1012,18 @@ subtest 'Test guarantor handling in SendQueuedMessages' => sub { is( $email_object->email->header('Cc'), $guarantor2->email, "cc correctly uses second guarantor" ); # feature disabled - t::lib::Mocks::mock_preference( 'RedirectGuaranteeEmail', '0' ); #FIXME: This mock is failing!? + t::lib::Mocks::mock_preference( 'RedirectGuaranteeEmail', '0' ); # reset message - $schema->resultset('MessageQueue')->search( { borrowernumber => $borrowernumber, status => 'sent' } ) - ->update( { status => 'pending', failure_code => undef } ); + Koha::Notice::Messages->find($message_id)->delete; + $message_id = C4::Letters::EnqueueLetter($my_message); warning_like { C4::Letters::SendQueuedMessages(); } qr|No 'to_address', email address or guarantors email address for borrowernumber|, "SendQueuedMessages fails when no to_address, patron notice email and RedirectGuaranteeEmail is not set"; # clear borrower queue - $schema->resultset('MessageQueue')->search( { borrowernumber => $borrowernumber, status => 'sent' } )->delete(); + Koha::Notice::Messages->find($message_id)->delete; }; subtest 'get_item_content' => sub { -- 2.25.1