Bugzilla – Attachment 68013 Details for
Bug 12802
Send notices using several email addresses
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 12802: Make tests pass
Bug-12802-Make-tests-pass.patch (text/plain), 4.48 KB, created by
Julian Maurice
on 2017-10-12 14:01:44 UTC
(
hide
)
Description:
Bug 12802: Make tests pass
Filename:
MIME Type:
Creator:
Julian Maurice
Created:
2017-10-12 14:01:44 UTC
Size:
4.48 KB
patch
obsolete
>From ceacd8a0c4afff9f23ec99101cabba8577036707 Mon Sep 17 00:00:00 2001 >From: Julian Maurice <julian.maurice@biblibre.com> >Date: Thu, 12 Oct 2017 13:39:24 +0000 >Subject: [PATCH] Bug 12802: Make tests pass > >--- > C4/Letters.pm | 16 ++++++++++++---- > t/db_dependent/Letters.t | 17 +++++++++++++++-- > t/db_dependent/Members.t | 4 ++-- > 3 files changed, 29 insertions(+), 8 deletions(-) > >diff --git a/C4/Letters.pm b/C4/Letters.pm >index d5340ed6f8..247c27351d 100644 >--- a/C4/Letters.pm >+++ b/C4/Letters.pm >@@ -962,14 +962,17 @@ sub _parseletter { > > =head2 EnqueueLetter > >- my $success = EnqueueLetter( { letter => $letter, >- borrowernumber => '12', message_transport_type => 'email' } ) >+ my $queued_count = EnqueueLetter({ >+ letter => $letter, >+ borrowernumber => '12', >+ message_transport_type => 'email' >+ }); > > places a letter in the message_queue database table, which will > eventually get processed (sent) by the process_message_queue.pl > cronjob when it calls SendQueuedMessages. > >-return message_id on success >+return the number of queued messages > > =cut > >@@ -1015,6 +1018,8 @@ sub EnqueueLetter { > $from_address ||= C4::Context->preference('KohaAdminEmailAddress'); > } > >+ my $queued = 0; >+ > my $rs = Koha::Database->new->schema->resultset('MessageQueue'); > if ($params->{message_transport_type} eq 'email') { > for my $to_address ( @to_addresses ) { >@@ -1030,6 +1035,7 @@ sub EnqueueLetter { > from_address => $from_address, > content_type => $params->{letter}{'content-type'}, > }); >+ ++$queued; > } > } else { > $rs->create({ >@@ -1043,8 +1049,10 @@ sub EnqueueLetter { > from_address => $from_address, > content_type => $params->{letter}{'content-type'}, > }); >+ ++$queued; > } >- return scalar( @to_addresses ); >+ >+ return $queued; > } > > =head2 SendQueuedMessages ([$hashref]) >diff --git a/t/db_dependent/Letters.t b/t/db_dependent/Letters.t >index 8231e557b5..77ed1c0f37 100644 >--- 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 => 82; >+use Test::More tests => 94; > use Test::MockModule; > use Test::Warn; > >@@ -702,10 +702,23 @@ subtest 'SendQueuedMessages' => sub { > > my $sms_pro = $builder->build_object({ class => 'Koha::SMS::Providers', value => { domain => 'kidclamp.rocks' } }); > ModMember( borrowernumber => $borrowernumber, smsalertnumber => '5555555555', sms_provider_id => $sms_pro->id() ); >- C4::Letters::EnqueueLetter($my_message); #using datas set around line 95 and forward >+ my $message = { >+ borrowernumber => $borrowernumber, >+ message_transport_type => 'sms', >+ letter => { >+ content => 'a message', >+ title => 'message title', >+ metadata => 'metadata', >+ code => 'TEST_MESSAGE', >+ content_type => 'text/plain', >+ }, >+ }; >+ C4::Letters::EnqueueLetter($message); > C4::Letters::SendQueuedMessages(); >+ > my $sms_message_address = $schema->resultset('MessageQueue')->search({ > borrowernumber => $borrowernumber, >+ message_transport_type => 'sms', > status => 'sent' > })->next()->to_address(); > is( $sms_message_address, '5555555555@kidclamp.rocks', 'SendQueuedMessages populates the to address correctly for SMS by email' ); >diff --git a/t/db_dependent/Members.t b/t/db_dependent/Members.t >index 57d27f864d..578fb0406a 100755 >--- a/t/db_dependent/Members.t >+++ b/t/db_dependent/Members.t >@@ -17,7 +17,7 @@ > > use Modern::Perl; > >-use Test::More tests => 63; >+use Test::More tests => 65; > use Test::MockModule; > use Data::Dumper qw/Dumper/; > use C4::Context; >@@ -153,7 +153,7 @@ C4::Context->clear_syspref_cache(); > $notice_emails = GetNoticeEmailAddresses($member->{'borrowernumber'}); > is_deeply ($notice_emails, [ $EMAILPRO ], "GetNoticeEmailAddresses returns correct value when AutoEmailPrimaryAddress is emailpro"); > >-C4::Context->set_preference( 'AutoEmailPrimaryAddress', 'emailpro,email' ); >+t::lib::Mocks::mock_preference( 'AutoEmailPrimaryAddress', 'emailpro,email' ); > C4::Context->clear_syspref_cache(); > $notice_emails = GetNoticeEmailAddresses($member->{'borrowernumber'}); > is_deeply ($notice_emails, [ $EMAILPRO, $EMAIL ], "GetNoticeEmailAddresses returns correct value when AutoEmailPrimaryAddress is emailpro|email"); >-- >2.11.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 12802
:
31058
|
31059
|
31132
|
31382
|
31383
|
31384
|
31833
|
33864
|
33865
|
33866
|
33867
|
35890
|
35891
|
35892
|
35893
|
35926
|
35927
|
35928
|
35929
|
35930
|
36055
|
36056
|
36057
|
36058
|
36059
|
39762
|
39770
|
40167
|
45476
|
45477
|
45478
|
45479
|
45480
|
45481
|
45482
|
57296
|
61878
|
61879
|
61880
|
61881
|
61882
|
61883
|
61884
|
66934
|
66935
|
66936
|
66937
|
66938
|
66939
|
66940
|
68002
|
68003
|
68004
|
68005
|
68006
|
68007
|
68008
|
68009
|
68010
|
68011
|
68012
|
68013
|
68375
|
68376
|
68377
|
68378
|
68379
|
68380
|
119016
|
149232
|
153540
|
154076
|
159780
|
159857
|
160051
|
160052
|
160090
|
160091
|
160092
|
160103
|
160104
|
160105
|
160106