|
Lines 18-29
Link Here
|
| 18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
| 19 |
|
19 |
|
| 20 |
use C4::Context; |
20 |
use C4::Context; |
|
|
21 |
use Mail::Sendmail; |
| 21 |
use C4::Letters; |
22 |
use C4::Letters; |
| 22 |
use Koha::Database; |
23 |
use Koha::Database; |
| 23 |
use Koha::Patrons; |
24 |
use Koha::Patrons; |
| 24 |
use t::lib::TestBuilder; |
25 |
use t::lib::TestBuilder; |
| 25 |
|
26 |
|
| 26 |
use Test::More tests => 20; |
27 |
use Test::More tests => 22; |
|
|
28 |
use Test::MockModule; |
| 29 |
use Test::Warn; |
| 30 |
use Carp; |
| 31 |
|
| 32 |
my %mail; |
| 33 |
my $module = Test::MockModule->new('Mail::Sendmail'); |
| 34 |
$module->mock( |
| 35 |
'sendmail', |
| 36 |
sub { |
| 37 |
carp 'Fake sendmail!'; |
| 38 |
%mail = @_; |
| 39 |
} |
| 40 |
); |
| 27 |
|
41 |
|
| 28 |
use_ok('Koha::Patron::Password::Recovery'); |
42 |
use_ok('Koha::Patron::Password::Recovery'); |
| 29 |
|
43 |
|
|
Lines 180-193
ok( Koha::Patron::Password::Recovery::DeleteExpiredPasswordRecovery($borrowernum
Link Here
|
| 180 |
############################################################### |
194 |
############################################################### |
| 181 |
|
195 |
|
| 182 |
my $borrower = Koha::Patrons->search( { userid => $userid1 } )->next; |
196 |
my $borrower = Koha::Patrons->search( { userid => $userid1 } )->next; |
| 183 |
ok( Koha::Patron::Password::Recovery::SendPasswordRecoveryEmail($borrower, $email1, 0) == 1, "[SendPasswordRecoveryEmail] Returns 1 on success" ); |
197 |
my $success; |
|
|
198 |
warning_like { |
| 199 |
$success = Koha::Patron::Password::Recovery::SendPasswordRecoveryEmail($borrower, $email1, 0); } |
| 200 |
qr/Fake sendmail!/, |
| 201 |
'[SendPasswordRecoveryEmail] expecting fake sendmail'; |
| 202 |
ok( $success == 1, '[SendPasswordRecoveryEmail] Returns 1 on success'); |
| 203 |
|
| 184 |
my $letters = C4::Letters::GetQueuedMessages( { borrowernumber => $borrowernumber1, limit => 99 } ); |
204 |
my $letters = C4::Letters::GetQueuedMessages( { borrowernumber => $borrowernumber1, limit => 99 } ); |
| 185 |
ok( scalar @$letters == 1, "[SendPasswordRecoveryEmail] There is a letter in the queue for our borrower"); |
205 |
ok( scalar @$letters == 1, "[SendPasswordRecoveryEmail] There is a letter in the queue for our borrower"); |
| 186 |
|
206 |
|
| 187 |
my $bpr = $schema->resultset('BorrowerPasswordRecovery')->search( { borrowernumber => $borrowernumber1 } ); |
207 |
my $bpr = $schema->resultset('BorrowerPasswordRecovery')->search( { borrowernumber => $borrowernumber1 } ); |
| 188 |
my $tempuuid1 = $bpr->next->uuid; |
208 |
my $tempuuid1 = $bpr->next->uuid; |
| 189 |
|
209 |
|
| 190 |
Koha::Patron::Password::Recovery::SendPasswordRecoveryEmail($borrower, $email1, 1); |
210 |
warning_like { |
|
|
211 |
Koha::Patron::Password::Recovery::SendPasswordRecoveryEmail($borrower, $email1, 1); } |
| 212 |
qr/Fake sendmail!/, |
| 213 |
'[SendPasswordRecoveryEmail] expecting fake sendmail'; |
| 191 |
|
214 |
|
| 192 |
$bpr = $schema->resultset('BorrowerPasswordRecovery')->search( { borrowernumber => $borrowernumber1 } ); |
215 |
$bpr = $schema->resultset('BorrowerPasswordRecovery')->search( { borrowernumber => $borrowernumber1 } ); |
| 193 |
my $tempuuid2 = $bpr->next->uuid; |
216 |
my $tempuuid2 = $bpr->next->uuid; |
| 194 |
- |
|
|