Bugzilla – Attachment 155946 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: (follow-up) Catch more cases in tests
Bug-12532-follow-up-Catch-more-cases-in-tests.patch (text/plain), 4.84 KB, created by
Martin Renvoize (ashimema)
on 2023-09-20 14:12:38 UTC
(
hide
)
Description:
Bug 12532: (follow-up) Catch more cases in tests
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2023-09-20 14:12:38 UTC
Size:
4.84 KB
patch
obsolete
>From 0b0012c8ac92a8e5ba8623c89719328ba68a4034 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Wed, 20 Sep 2023 15:09:26 +0100 >Subject: [PATCH] Bug 12532: (follow-up) Catch more cases in tests > >This patch added lots more cases to the unit tests to try and catch all >the new functionality. > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > t/db_dependent/Letters.t | 78 ++++++++++++++++++++++++++++++++++++---- > 1 file changed, 71 insertions(+), 7 deletions(-) > >diff --git a/t/db_dependent/Letters.t b/t/db_dependent/Letters.t >index 66d51acdc5e..9cec7b49a7c 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 => 7; >+ plan tests => 19; > > t::lib::Mocks::mock_preference( 'borrowerRelationship', 'test' ); > >@@ -982,9 +982,20 @@ subtest 'Test guarantor handling in SendQueuedMessages' => sub { > }; > $message_id = C4::Letters::EnqueueLetter($my_message); > >+ # feature disabled >+ t::lib::Mocks::mock_preference( 'RedirectGuaranteeEmail', '0' ); >+ >+ 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"; >+ > # feature enabled > t::lib::Mocks::mock_preference( 'RedirectGuaranteeEmail', '1' ); > >+ # reset message - testing without to or borrower valid email >+ Koha::Notice::Messages->find($message_id)->delete; >+ $message_id = C4::Letters::EnqueueLetter($my_message); >+ > warning_like { C4::Letters::SendQueuedMessages(); } > qr|Fake send_or_die|, > "SendQueuedMessages is using the mocked send_or_die routine"; >@@ -1011,16 +1022,69 @@ subtest 'Test guarantor handling in SendQueuedMessages' => sub { > 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' ); >- >- # reset message >+ # reset message - testing borrower with valid email > Koha::Notice::Messages->find($message_id)->delete; >+ $message_id = C4::Letters::EnqueueLetter($my_message); >+ >+ $patron->email('patron@example.com')->store(); >+ >+ 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(), >+ $patron->email, >+ 'SendQueuedMessages uses patron email when defined' >+ ); >+ >+ is( >+ $message->cc_address(), >+ $guarantor1->email.",".$guarantor2->email, >+ 'SendQueuedMessages sets cc address to both guarantor emails when patron has email defined' >+ ); >+ >+ is( $email_object->email->header('To'), $patron->email, "mailto correctly uses patrons email address" ); >+ is( $email_object->email->header('Cc'), $guarantor1->email.", ".$guarantor2->email, "cc correctly uses both guarantors" ); > >+ >+ # reset message - testing explicit to passed to enqueue >+ Koha::Notice::Messages->find($message_id)->delete; >+ $my_message->{'to_address'} = 'to@example.com'; > $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"; >+ 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(), >+ 'to@example.com', >+ 'SendQueuedMessages uses to_address if it was specified at enqueue time' >+ ); >+ >+ is( >+ $message->cc_address(), >+ $guarantor1->email.",".$guarantor2->email, >+ 'SendQueuedMessages sets cc address to both guarantor emails when "to" is already specified' >+ ); >+ >+ is( $email_object->email->header('To'), 'to@example.com', "mailto correctly uses passed email" ); >+ is( $email_object->email->header('Cc'), $guarantor1->email.", ".$guarantor2->email, "cc correctly uses both guarantors" ); > > # clear borrower queue > Koha::Notice::Messages->find($message_id)->delete; >-- >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