Bugzilla – Attachment 170256 Details for
Bug 37598
Ability to use the BCC field for sending notices to multiple addresses, rather than the To field
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 37598: Tests for t/db_dependent/Letters.t
Bug-37598-Tests-for-tdbdependentLetterst.patch (text/plain), 4.54 KB, created by
Aleisha Amohia
on 2024-08-13 05:13:54 UTC
(
hide
)
Description:
Bug 37598: Tests for t/db_dependent/Letters.t
Filename:
MIME Type:
Creator:
Aleisha Amohia
Created:
2024-08-13 05:13:54 UTC
Size:
4.54 KB
patch
obsolete
>From 32feb3351c16caef848b0c2b8a01448ef21f3c00 Mon Sep 17 00:00:00 2001 >From: Aleisha Amohia <aleishaamohia@hotmail.com> >Date: Tue, 13 Aug 2024 05:13:23 +0000 >Subject: [PATCH] Bug 37598: Tests for t/db_dependent/Letters.t > >WIP >--- > t/db_dependent/Letters.t | 94 +++++++++++++++++++++++++++++++++++++++- > 1 file changed, 93 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Letters.t b/t/db_dependent/Letters.t >index d607fa7d04a..14d1f5c3f70 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 => 103; >+use Test::More tests => 104; > > use Test::MockModule; > use Test::Warn; >@@ -75,6 +75,7 @@ $dbh->do(q|DELETE FROM letter|); > $dbh->do(q|DELETE FROM message_queue|); > $dbh->do(q|DELETE FROM message_transport_types|); > t::lib::Mocks::mock_preference( 'EmailFieldPrimary', 'OFF' ); >+t::lib::Mocks::mock_preference( 'EmailRecipientField', 'to' ); > > my $library = $builder->build({ > source => 'Branch', >@@ -1582,3 +1583,94 @@ subtest 'Quote user params in GetPreparedLetter' => sub { > $exec_time > ); > }; >+ >+subtest 'Tests for EmailRecipientField' => sub { >+ plan tests => 9; >+ >+ Koha::Notice::Messages->delete; >+ >+ t::lib::Mocks::mock_preference( 'EmailRecipientField', 'to' ); >+ t::lib::Mocks::mock_preference( 'EmailFieldPrimary', 'OFF' ); >+ >+ my $library = $builder->build_object( >+ { >+ class => 'Koha::Libraries', >+ value => { >+ branchemail => 'email@library.com', branchreplyto => 'reply@library.com', >+ branchreturnpath => 'return@library.com' >+ } >+ } >+ ); >+ my $patron = $builder->build_object( >+ { >+ class => 'Koha::Patrons', >+ value => { >+ email => 'primary@test.com', emailpro => 'secondary@test.com', B_email => 'alternate@test.com', >+ branchcode => $library->id >+ } >+ } >+ ); >+ >+ my $my_message = { >+ 'letter' => { >+ 'content' => '<p>a message</p>', >+ 'metadata' => 'metadata', >+ 'code' => 'TEST_MESSAGE', >+ 'content_type' => 'text/html; charset="UTF-8"', >+ 'title' => 'message title' >+ }, >+ 'borrowernumber' => $patron->id, >+ 'to_address' => undef, >+ 'message_transport_type' => 'email', >+ 'from_address' => 'from@example.com' >+ }; >+ >+ my $message_1_id = C4::Letters::EnqueueLetter($my_message); >+ >+ warning_like { C4::Letters::SendQueuedMessages({ message_id => $message_1_id }); } >+ qr|Fake send_or_die|, >+ "SendQueuedMessages is using the mocked send_or_die routine"; >+ >+ my $message_1 = C4::Letters::GetMessage($message_1_id); >+ is( $message_1->{status}, 'sent', 'Message sent' ); >+ is( >+ $message_1->{to_address}, $patron->notice_email_address, >+ 'A to_address was generated in the sending of the message' >+ ); >+ >+ t::lib::Mocks::mock_preference( 'EmailFieldPrimary', 'MULTI' ); >+ t::lib::Mocks::mock_preference( 'EmailFieldSelection', 'B_email,email,emailpro' ); >+ >+ my $message_2_id = C4::Letters::EnqueueLetter($my_message); >+ >+ warning_like { C4::Letters::SendQueuedMessages({ message_id => $message_2_id }); } >+ qr|Fake send_or_die|, >+ "SendQueuedMessages is using the mocked send_or_die routine"; >+ >+ my $message_2 = C4::Letters::GetMessage($message_2_id); >+ is( $message_2->{status}, 'sent', 'Message sent' ); >+ is( >+ $message_2->{to_address}, $patron->notice_email_address, >+ 'A to_address was generated in the sending of the message and uses the multiple selected addresses' >+ ); >+ >+ t::lib::Mocks::mock_preference( 'EmailRecipientField', 'cc' ); >+ >+ my $message_3_id = C4::Letters::EnqueueLetter($my_message); >+ >+ warning_like { C4::Letters::SendQueuedMessages({ message_id => $message_3_id }); } >+ qr|Fake send_or_die|, >+ "SendQueuedMessages is using the mocked send_or_die routine"; >+ >+ my $message_3 = C4::Letters::GetMessage($message_3_id); >+ is( $message_3->{status}, 'sent', 'Message sent' ); >+ is( >+ $message_3->{cc_address}, $patron->notice_email_address, >+ 'A cc_address was generated in the sending of the message and uses the multiple selected addresses' >+ ); >+ >+ >+#is( $email_object->email->header('To'), $guarantor1->email, "mailto correctly uses first guarantor" ); >+#is( $email_object->email->header('Cc'), $guarantor2->email, "cc correctly uses second guarantor" ); >+ >+}; >-- >2.39.2
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 37598
:
170249
|
170250
|
170254
|
170255
|
170256
|
171112
|
171113
|
171114