Bugzilla – Attachment 73289 Details for
Bug 20474
Passwordrecovery.t should mock Mail::Sendmail::sendmail
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 20474: Mock sendmail instead of actually emailing
Bug-20474-Mock-sendmail-instead-of-actually-emaili.patch (text/plain), 2.59 KB, created by
Mark Tompsett
on 2018-03-26 16:52:52 UTC
(
hide
)
Description:
Bug 20474: Mock sendmail instead of actually emailing
Filename:
MIME Type:
Creator:
Mark Tompsett
Created:
2018-03-26 16:52:52 UTC
Size:
2.59 KB
patch
obsolete
>From 1a2bab6a2c2fe25fd826b5075ec87bb9a2ef6b10 Mon Sep 17 00:00:00 2001 >From: Mark Tompsett <mtompset@hotmail.com> >Date: Mon, 26 Mar 2018 15:39:28 +0000 >Subject: [PATCH] Bug 20474: Mock sendmail instead of actually emailing > >Copy mocking sendmail code from t/db_dependent/Letters.t >into the Passwordrecovery.t test file. > >prove t/db_dependent/Passwordrecovery.t >--- > t/db_dependent/Passwordrecovery.t | 29 ++++++++++++++++++++++++++--- > 1 file changed, 26 insertions(+), 3 deletions(-) > >diff --git a/t/db_dependent/Passwordrecovery.t b/t/db_dependent/Passwordrecovery.t >index 47de46f..75760f4 100755 >--- a/t/db_dependent/Passwordrecovery.t >+++ b/t/db_dependent/Passwordrecovery.t >@@ -18,12 +18,26 @@ > use Modern::Perl; > > use C4::Context; >+use Mail::Sendmail; > use C4::Letters; > use Koha::Database; > use Koha::Patrons; > use t::lib::TestBuilder; > >-use Test::More tests => 20; >+use Test::More tests => 22; >+use Test::MockModule; >+use Test::Warn; >+use Carp; >+ >+my %mail; >+my $module = Test::MockModule->new('Mail::Sendmail'); >+$module->mock( >+ 'sendmail', >+ sub { >+ carp 'Fake sendmail!'; >+ %mail = @_; >+ } >+); > > use_ok('Koha::Patron::Password::Recovery'); > >@@ -180,14 +194,23 @@ ok( Koha::Patron::Password::Recovery::DeleteExpiredPasswordRecovery($borrowernum > ############################################################### > > my $borrower = Koha::Patrons->search( { userid => $userid1 } )->next; >-ok( Koha::Patron::Password::Recovery::SendPasswordRecoveryEmail($borrower, $email1, 0) == 1, "[SendPasswordRecoveryEmail] Returns 1 on success" ); >+my $success; >+warning_like { >+ $success = Koha::Patron::Password::Recovery::SendPasswordRecoveryEmail($borrower, $email1, 0); } >+ qr/Fake sendmail!/, >+ '[SendPasswordRecoveryEmail] expecting fake sendmail'; >+ok( $success == 1, '[SendPasswordRecoveryEmail] Returns 1 on success'); >+ > my $letters = C4::Letters::GetQueuedMessages( { borrowernumber => $borrowernumber1, limit => 99 } ); > ok( scalar @$letters == 1, "[SendPasswordRecoveryEmail] There is a letter in the queue for our borrower"); > > my $bpr = $schema->resultset('BorrowerPasswordRecovery')->search( { borrowernumber => $borrowernumber1 } ); > my $tempuuid1 = $bpr->next->uuid; > >-Koha::Patron::Password::Recovery::SendPasswordRecoveryEmail($borrower, $email1, 1); >+warning_like { >+ Koha::Patron::Password::Recovery::SendPasswordRecoveryEmail($borrower, $email1, 1); } >+ qr/Fake sendmail!/, >+ '[SendPasswordRecoveryEmail] expecting fake sendmail'; > > $bpr = $schema->resultset('BorrowerPasswordRecovery')->search( { borrowernumber => $borrowernumber1 } ); > my $tempuuid2 = $bpr->next->uuid; >-- >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 20474
:
73288
|
73289
|
73322
|
73323
|
73324