Bugzilla – Attachment 191304 Details for
Bug 40934
process_message_queue.pl add ability to exclude some letter code
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 40934: Add tests for exclude_letter_code in process_message_queue.pl
2ff6a8f.patch (text/plain), 6.20 KB, created by
Martin Renvoize (ashimema)
on 2026-01-12 17:26:18 UTC
(
hide
)
Description:
Bug 40934: Add tests for exclude_letter_code in process_message_queue.pl
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2026-01-12 17:26:18 UTC
Size:
6.20 KB
patch
obsolete
>From 2ff6a8f2982e3a7590e1d1d1716d1d3817ae45ec Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@openfifth.co.uk> >Date: Wed, 7 Jan 2026 15:48:56 +0000 >Subject: [PATCH] Bug 40934: Add tests for exclude_letter_code in > process_message_queue.pl > >This patch adds unit tests for the new exclude_letter_code functionality >in SendQueuedMessages, which will allow excluding specific letter codes >when processing the message queue. > >Test coverage includes: >- Excluding a single letter code (array format) >- Excluding multiple letter codes >- Excluding with scalar parameter format >--- > t/db_dependent/Letters.t | 128 ++++++++++++++++++++++++++++++++++++++- > 1 file changed, 127 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Letters.t b/t/db_dependent/Letters.t >index f248a07f7f5..67a2c69b38a 100755 >--- a/t/db_dependent/Letters.t >+++ b/t/db_dependent/Letters.t >@@ -19,7 +19,7 @@ > > use Modern::Perl; > use File::Basename qw(dirname); >-use Test::More tests => 105; >+use Test::More tests => 106; > use Test::NoWarnings; > > use Test::MockModule; >@@ -1825,4 +1825,130 @@ subtest 'Virtual method ->strftime in notices' => sub { > is( $get_letter->()->{content}, $expected_output, 'Check generated content for us dateformat' ); > }; > >+subtest 'Test exclude_letter_code parameter for SendQueuedMessages' => sub { >+ plan tests => 10; >+ >+ my $dbh = C4::Context->dbh; >+ >+ my $borrowernumber = Koha::Patron->new( >+ { >+ firstname => 'Jane', >+ surname => 'Smith', >+ categorycode => $patron_category, >+ branchcode => $library->{branchcode}, >+ dateofbirth => $date, >+ smsalertnumber => '5555555555', >+ } >+ )->store->borrowernumber; >+ >+ $dbh->do(q|DELETE FROM message_queue|); >+ >+ # Create messages with different letter codes >+ my $message_digest1 = { >+ 'letter' => { >+ 'content' => 'digest message 1', >+ 'metadata' => 'metadata', >+ 'code' => 'DUEDGST', >+ 'content_type' => 'text/plain', >+ 'title' => 'digest title' >+ }, >+ 'borrowernumber' => $borrowernumber, >+ 'to_address' => undef, >+ 'message_transport_type' => 'sms', >+ 'from_address' => 'from@example.com' >+ }; >+ my $message_digest2 = { >+ 'letter' => { >+ 'content' => 'digest message 2', >+ 'metadata' => 'metadata', >+ 'code' => 'PREDUEDGST', >+ 'content_type' => 'text/plain', >+ 'title' => 'predigest title' >+ }, >+ 'borrowernumber' => $borrowernumber, >+ 'to_address' => undef, >+ 'message_transport_type' => 'sms', >+ 'from_address' => 'from@example.com' >+ }; >+ my $message_regular = { >+ 'letter' => { >+ 'content' => 'regular message', >+ 'metadata' => 'metadata', >+ 'code' => 'ACQ_NOTIF', >+ 'content_type' => 'text/plain', >+ 'title' => 'regular title' >+ }, >+ 'borrowernumber' => $borrowernumber, >+ 'to_address' => undef, >+ 'message_transport_type' => 'sms', >+ 'from_address' => 'from@example.com' >+ }; >+ my $message_regular2 = { >+ 'letter' => { >+ 'content' => 'another regular message', >+ 'metadata' => 'metadata', >+ 'code' => 'TEST_MESSAGE', >+ 'content_type' => 'text/plain', >+ 'title' => 'regular title 2' >+ }, >+ 'borrowernumber' => $borrowernumber, >+ 'to_address' => undef, >+ 'message_transport_type' => 'sms', >+ 'from_address' => 'from@example.com' >+ }; >+ >+ my @id = ( >+ C4::Letters::EnqueueLetter($message_digest1), >+ C4::Letters::EnqueueLetter($message_digest2), >+ C4::Letters::EnqueueLetter($message_regular), >+ C4::Letters::EnqueueLetter($message_regular2), >+ ); >+ >+ # Test excluding single letter code (array) >+ C4::Letters::SendQueuedMessages( >+ { >+ exclude_letter_code => ['DUEDGST'], >+ type => 'sms', >+ } >+ ); >+ >+ is( Koha::Notice::Messages->find( $id[0] )->status, 'pending', 'DUEDGST message excluded, still pending' ); >+ is( Koha::Notice::Messages->find( $id[1] )->status, 'sent', 'PREDUEDGST message processed' ); >+ is( Koha::Notice::Messages->find( $id[2] )->status, 'sent', 'ACQ_NOTIF message processed' ); >+ is( Koha::Notice::Messages->find( $id[3] )->status, 'sent', 'TEST_MESSAGE message processed' ); >+ >+ # Reset messages to pending >+ Koha::Notice::Messages->find( $id[1] )->update( { status => 'pending' } ); >+ Koha::Notice::Messages->find( $id[2] )->update( { status => 'pending' } ); >+ Koha::Notice::Messages->find( $id[3] )->update( { status => 'pending' } ); >+ >+ # Test excluding multiple letter codes >+ C4::Letters::SendQueuedMessages( >+ { >+ exclude_letter_code => [ 'DUEDGST', 'PREDUEDGST' ], >+ type => 'sms', >+ } >+ ); >+ >+ is( Koha::Notice::Messages->find( $id[0] )->status, 'pending', 'DUEDGST message excluded, still pending' ); >+ is( Koha::Notice::Messages->find( $id[1] )->status, 'pending', 'PREDUEDGST message excluded, still pending' ); >+ is( Koha::Notice::Messages->find( $id[2] )->status, 'sent', 'ACQ_NOTIF message processed' ); >+ is( Koha::Notice::Messages->find( $id[3] )->status, 'sent', 'TEST_MESSAGE message processed' ); >+ >+ # Reset messages to pending >+ Koha::Notice::Messages->find( $id[2] )->update( { status => 'pending' } ); >+ Koha::Notice::Messages->find( $id[3] )->update( { status => 'pending' } ); >+ >+ # Test with scalar exclude_letter_code >+ C4::Letters::SendQueuedMessages( >+ { >+ exclude_letter_code => 'TEST_MESSAGE', >+ type => 'sms', >+ } >+ ); >+ >+ is( Koha::Notice::Messages->find( $id[2] )->status, 'sent', 'ACQ_NOTIF message processed' ); >+ is( Koha::Notice::Messages->find( $id[3] )->status, 'pending', 'TEST_MESSAGE message excluded, still pending' ); >+}; >+ > $schema->storage->txn_rollback; >-- >2.52.0 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 40934
:
190995
|
190996
|
191304
|
191305
|
191306
|
191307