From 04f2ecb56c1aa91ca2292c375fcd7cdb22a168d5 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Fri, 2 Oct 2020 16:17:40 -0300 Subject: [PATCH] Bug 22343: (follow-up) Make sure no invalid address is used in tests Signed-off-by: Tomas Cohen Arazi Signed-off-by: Jonathan Druart --- t/db_dependent/Passwordrecovery.t | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/t/db_dependent/Passwordrecovery.t b/t/db_dependent/Passwordrecovery.t index 53abb13d43..0eabc80a49 100755 --- a/t/db_dependent/Passwordrecovery.t +++ b/t/db_dependent/Passwordrecovery.t @@ -23,25 +23,30 @@ use C4::Letters; use Koha::Database; use Koha::DateUtils; use Koha::Patrons; + use t::lib::TestBuilder; +use t::lib::Mocks; 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', +my ( $email_object, $sendmail_params ); + +my $email_sender_module = Test::MockModule->new('Email::Stuffer'); +$email_sender_module->mock( + 'send_or_die', sub { - carp 'Fake sendmail'; - %mail = @_; + ( $email_object, $sendmail_params ) = @_; + warn 'Fake sendmail'; } ); use_ok('Koha::Patron::Password::Recovery'); +t::lib::Mocks::mock_preference('KohaAdminEmailAddress', 'test@koha-community.org'); + my $schema = Koha::Database->new()->schema(); $schema->storage->txn_begin(); @@ -66,6 +71,8 @@ my $patron_category = $builder->build({ source => 'Category' }); my $branch = $builder->build({ source => 'Branch', value => { + branchemail => undef, + branchreplyto => undef, branchreturnpath => $email1, }, }); -- 2.39.5