Bugzilla – Attachment 155940 Details for
Bug 12532
Copy guarantee email to guarantor (or redirect if guarantee has no email set)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 12532: (QA follow-up) Add tests for SendQueuedMessages
Bug-12532-QA-follow-up-Add-tests-for-SendQueuedMes.patch (text/plain), 4.74 KB, created by
Martin Renvoize (ashimema)
on 2023-09-20 14:12:14 UTC
(
hide
)
Description:
Bug 12532: (QA follow-up) Add tests for SendQueuedMessages
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2023-09-20 14:12:14 UTC
Size:
4.74 KB
patch
obsolete
>From 2cf229bc19f25277d6c08bbe936e417ca5431b70 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Mon, 18 Sep 2023 15:19:05 +0100 >Subject: [PATCH] Bug 12532: (QA follow-up) Add tests for SendQueuedMessages > >This patch adds unit tests for the changes made to >_send_message_by_email for Guarantor CC > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > t/db_dependent/Letters.t | 75 ++++++++++++++++++++++++++++++++++++++-- > 1 file changed, 73 insertions(+), 2 deletions(-) > >diff --git a/t/db_dependent/Letters.t b/t/db_dependent/Letters.t >index c1593f1806d..88af0b0b580 100755 >--- a/t/db_dependent/Letters.t >+++ b/t/db_dependent/Letters.t >@@ -18,7 +18,7 @@ > # along with Koha; if not, see <http://www.gnu.org/licenses>. > > use Modern::Perl; >-use Test::More tests => 90; >+use Test::More tests => 91; > use Test::MockModule; > use Test::Warn; > use Test::Exception; >@@ -869,7 +869,6 @@ subtest 'Test SMS handling in SendQueuedMessages' => sub { > t::lib::Mocks::mock_preference( 'SMSSendDriver', 'Email' ); > t::lib::Mocks::mock_preference('EmailSMSSendDriverFromAddress', ''); > >- t::lib::Mocks::mock_preference( 'RedirectGuaranteeEmail', '0' ); > my $patron = Koha::Patrons->find($borrowernumber); > $dbh->do(q| > INSERT INTO message_queue(borrowernumber, subject, content, message_transport_type, status, letter_code) >@@ -953,6 +952,78 @@ subtest 'Test SMS handling in SendQueuedMessages' => sub { > })->next()->to_address(); > is( $sms_message_address, '5555555555', 'SendQueuedMessages populates the to address correctly for SMS by SMS::Send driver to smsalertnumber when to_address is set incorrectly' ); > >+ $schema->resultset('MessageQueue')->search({borrowernumber => $borrowernumber, status => 'sent'})->delete(); #clear borrower queue >+}; >+ >+subtest 'Test guarantor handling in SendQueuedMessages' => sub { >+ >+ plan tests => 8; >+ >+ t::lib::Mocks::mock_preference( 'borrowerRelationship', 'test' ); >+ >+ my $patron = Koha::Patrons->find($borrowernumber); >+ my $guarantor1 = $builder->build_object( { class => 'Koha::Patrons', value => { email => 'g1@email.com' } } ); >+ my $guarantor2 = $builder->build_object( { class => 'Koha::Patrons', value => { email => 'g2@email.com' } } ); >+ $patron->add_guarantor( { guarantor_id => $guarantor1->borrowernumber, relationship => 'test' } ); >+ $patron->add_guarantor( { guarantor_id => $guarantor2->borrowernumber, relationship => 'test' } ); >+ >+ $my_message = { >+ 'letter' => { >+ 'content' => 'a message', >+ 'metadata' => 'metadata', >+ 'code' => 'TEST_MESSAGE', >+ 'content_type' => 'text/plain', >+ 'title' => 'message title' >+ }, >+ 'borrowernumber' => $borrowernumber, >+ 'to_address' => undef, >+ 'message_transport_type' => 'email', >+ 'from_address' => 'from@example.com' >+ }; >+ $message_id = C4::Letters::EnqueueLetter($my_message); >+ >+ # feature enabled >+ t::lib::Mocks::mock_preference( 'RedirectGuaranteeEmail', '1' ); >+ >+ warning_like { C4::Letters::SendQueuedMessages(); } >+ qr|Fake send_or_die|, >+ "SendQueuedMessages is using the mocked send_or_die routine"; >+ >+ $message = $schema->resultset('MessageQueue')->search( >+ { >+ borrowernumber => $borrowernumber, >+ status => 'sent' >+ } >+ )->next(); >+ >+ is( >+ $message->to_address(), >+ $guarantor1->email, >+ 'SendQueuedMessages uses first guarantor email for "to" when patron has no email' >+ ); >+ >+ is( >+ $message->cc_address(), >+ $guarantor2->email, >+ 'SendQueuedMessages sets cc address to second guarantor email when "to" takes first guarantor email' >+ ); >+ >+ 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" ); >+ >+ # feature disabled >+ t::lib::Mocks::mock_preference( 'RedirectGuaranteeEmail', '0' ); #FIXME: This mock is failing!? >+ >+ # reset message >+ $schema->resultset('MessageQueue')->search( { borrowernumber => $borrowernumber, status => 'sent' } ) >+ ->update( { status => 'pending', failure_code => undef } ); >+ >+ 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(); > }; > > subtest 'get_item_content' => sub { >-- >2.41.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 12532
:
29510
|
30747
|
35313
|
36752
|
39787
|
39925
|
48645
|
53649
|
53689
|
53690
|
53699
|
53700
|
55985
|
56052
|
56053
|
59445
|
59446
|
59447
|
63197
|
64802
|
64824
|
67115
|
68340
|
70865
|
72064
|
72617
|
75099
|
77606
|
80313
|
85134
|
85135
|
87815
|
87816
|
88208
|
88209
|
88210
|
88211
|
88212
|
88213
|
88295
|
88296
|
114455
|
114456
|
114457
|
114458
|
114459
|
114460
|
114461
|
131091
|
131092
|
131093
|
131094
|
149233
|
150071
|
150208
|
150217
|
150240
|
150256
|
151028
|
151029
|
154854
|
154855
|
154856
|
154857
|
155036
|
155037
|
155828
|
155829
|
155830
|
155831
|
155832
|
155833
|
155834
|
155835
|
155836
|
155837
|
155873
|
155874
|
155875
|
155876
|
155877
|
155878
|
155879
|
155880
|
155881
|
155882
|
155883
|
155886
|
155934
|
155935
|
155936
|
155937
|
155938
|
155939
| 155940 |
155941
|
155942
|
155943
|
155944
|
155945
|
155946