Bug 22343: (follow-up) Make sure no invalid address is used in tests
authorTomas Cohen Arazi <tomascohen@theke.io>
Fri, 2 Oct 2020 19:17:40 +0000 (16:17 -0300)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Mon, 5 Oct 2020 09:15:51 +0000 (11:15 +0200)
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
t/db_dependent/Passwordrecovery.t

index 53abb13..0eabc80 100755 (executable)
@@ -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,
     },
 });