Bugzilla – Attachment 49999 Details for
Bug 8000
Test mode for notices
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 8000 - Missing test to trigger code change
Bug-8000---Missing-test-to-trigger-code-change.patch (text/plain), 4.58 KB, created by
Nick Clemens (kidclamp)
on 2016-04-06 16:20:55 UTC
(
hide
)
Description:
Bug 8000 - Missing test to trigger code change
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2016-04-06 16:20:55 UTC
Size:
4.58 KB
patch
obsolete
>From 6c65a1e26b134ab9c484d9cdd1ed93ce7260407c Mon Sep 17 00:00:00 2001 >From: charles <charles.farmer@inlibro.com> >Date: Wed, 6 Apr 2016 11:29:05 -0400 >Subject: [PATCH] Bug 8000 - Missing test to trigger code change > >This adds a test case which will trigger _send_message_by_email >and thus provide a way to run the changes made. > >Signed-off-by: Nick Clemens <nick@bywatersolutions.com> >--- > t/db_dependent/Letters.t | 56 +++++++++++++++++++++++++++++++++++++++++++++--- > 1 file changed, 53 insertions(+), 3 deletions(-) > >diff --git a/t/db_dependent/Letters.t b/t/db_dependent/Letters.t >index ed5c972..9953252 100644 >--- a/t/db_dependent/Letters.t >+++ b/t/db_dependent/Letters.t >@@ -87,6 +87,7 @@ is_deeply( $mtts, ['email', 'phone', 'print', 'sms'], 'GetMessageTransportTypes > # EnqueueLetter > is( C4::Letters::EnqueueLetter(), undef, 'EnqueueLetter without argument returns undef' ); > >+# used to trigger _send_message_by_sms in C4::Letter > my $my_message = { > borrowernumber => $borrowernumber, > message_transport_type => 'sms', >@@ -111,13 +112,35 @@ $my_message->{message_transport_type} = 'sms'; > $message_id = C4::Letters::EnqueueLetter($my_message); > ok(defined $message_id && $message_id > 0, 'new message successfully queued'); > >+# This is will force C4::Context->preference() to read the DB. >+C4::Context->disable_syspref_cache(); >+ >+# used to trigger _send_message_by_email in C4::Letter >+# first override. >+$dbh->do("UPDATE systempreferences SET value='override\@example.com' WHERE variable='SendAllEmailsTo';"); >+my $message_id2 = C4::Letters::EnqueueLetter({ >+ borrowernumber => $borrowernumber, >+ message_transport_type => 'email', >+ to_address => 'to@example.com', >+ from_address => 'from@example.com', >+ letter => { >+ content => 'a message', >+ title => 'message title', >+ metadata => 'metadata', >+ code => 'TEST_MESSAGE', >+ content_type => 'text/plain', >+ }, >+}); >+ >+ok(defined $message_id2 && $message_id2 > 0, 'new message successfully queued'); >+ > > # GetQueuedMessages > my $messages = C4::Letters::GetQueuedMessages(); >-is( @$messages, 1, 'GetQueuedMessages without argument returns all the entries' ); >+is( @$messages, 2, 'GetQueuedMessages without argument returns all the entries' ); > > $messages = C4::Letters::GetQueuedMessages({ borrowernumber => $borrowernumber }); >-is( @$messages, 1, 'one message stored for the borrower' ); >+is( @$messages, 2, 'two messages stored for the borrower' ); > is( $messages->[0]->{message_id}, $message_id, 'EnqueueLetter returns the message id correctly' ); > is( $messages->[0]->{borrowernumber}, $borrowernumber, 'EnqueueLetter stores the borrower number correctly' ); > is( $messages->[0]->{subject}, $my_message->{letter}->{title}, 'EnqueueLetter stores the subject correctly' ); >@@ -128,14 +151,41 @@ is( $messages->[0]->{status}, 'pending', 'EnqueueLetter stores the status pendin > > # SendQueuedMessages > my $messages_processed = C4::Letters::SendQueuedMessages(); >-is($messages_processed, 1, 'all queued messages processed'); >+is($messages_processed, 2, 'all queued messages processed'); >+ >+$messages = C4::Letters::GetQueuedMessages({ borrowernumber => $borrowernumber }); >+is(scalar(@$messages), 2, 'two messages stored for the borrower'); >+ >+# used to trigger _send_message_by_email in C4::Letter >+# second no override. >+$dbh->do("UPDATE systempreferences SET value='' WHERE variable='SendAllEmailsTo';"); >+my $message_id3 = C4::Letters::EnqueueLetter({ >+ borrowernumber => $borrowernumber, >+ message_transport_type => 'email', >+ to_address => 'to@example.com', >+ from_address => 'from@example.com', >+ letter => { >+ content => 'a message', >+ title => 'message title', >+ metadata => 'metadata', >+ code => 'TEST_MESSAGE', >+ content_type => 'text/plain', >+ }, >+}); >+ >+$messages_processed = C4::Letters::SendQueuedMessages(); >+is($messages_processed, 1, 'third queued message processed'); > > $messages = C4::Letters::GetQueuedMessages({ borrowernumber => $borrowernumber }); >+is(scalar(@$messages), 3, 'three messages stored for the borrower'); >+ > is( > $messages->[0]->{status}, > 'failed', > 'message marked failed if tried to send SMS message for borrower with no smsalertnumber set (bug 11208)' > ); >+is ( $messages->[1]->{sentto_address},'override@example.com','Second message sent to override.'); >+is ( $messages->[2]->{sentto_address},'to@example.com','Third message sent to default.'); > > # ResendMessage > my $resent = C4::Letters::ResendMessage($messages->[0]->{message_id}); >-- >2.1.4
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 8000
:
21976
|
22315
|
24784
|
25917
|
25919
|
25920
|
25923
|
25924
|
25925
|
25926
|
25927
|
25928
|
25939
|
25950
|
25951
|
26446
|
37463
|
37464
|
37465
|
37466
|
37467
|
37468
|
37469
|
37472
|
37473
|
37474
|
37475
|
37476
|
37477
|
37478
|
37481
|
37482
|
37483
|
37484
|
37485
|
37486
|
37487
|
39985
|
39986
|
39987
|
39988
|
39989
|
39990
|
39991
|
39992
|
40215
|
40216
|
40217
|
40218
|
40219
|
40220
|
40221
|
40222
|
40223
|
40224
|
40225
|
40226
|
40227
|
40228
|
40229
|
40230
|
46354
|
46355
|
46356
|
46357
|
46358
|
46359
|
46360
|
46361
|
46362
|
49991
|
49992
|
49993
|
49998
|
49999
|
50000
|
55940
|
58434
|
62863
|
67155
|
70086
|
70087
|
70484
|
74110
|
74111
|
74848
|
80370
|
81487
|
81488
|
81589
|
81590
|
81591
|
84801
|
84802
|
84803
|
84804
|
84805
|
86861
|
86862
|
86863
|
86864
|
86865
|
88874
|
88875
|
88876
|
88877
|
88878
|
88879