Can now also test event code.

This commit is contained in:
James Cole
2017-04-27 08:26:58 +02:00
parent b26f3c0cc6
commit bbe40518e4
5 changed files with 151 additions and 17 deletions

View File

@@ -16,8 +16,8 @@ namespace FireflyIII\Handlers\Events;
use FireflyIII\Events\RegisteredUser;
use FireflyIII\Events\RequestedNewPassword;
use FireflyIII\Mail\RegisteredUser as RegisteredUserMail;
use FireflyIII\Mail\RequestedNewPassword as RequestedNewPasswordMail;
use FireflyIII\Repositories\User\UserRepositoryInterface;
use Illuminate\Mail\Message;
use Log;
use Mail;
use Swift_TransportException;
@@ -69,14 +69,12 @@ class UserEventHandler
// send email.
try {
Mail::send(
['emails.password-html', 'emails.password-text'], ['url' => $url, 'ip' => $ipAddress], function (Message $message) use ($email) {
$message->to($email, $email)->subject('Your password reset request');
}
);
Mail::to($email)->send(new RequestedNewPasswordMail($url, $ipAddress));
// @codeCoverageIgnoreStart
} catch (Swift_TransportException $e) {
Log::error($e->getMessage());
}
// @codeCoverageIgnoreEnd
return true;
}
@@ -94,7 +92,7 @@ class UserEventHandler
$sendMail = env('SEND_REGISTRATION_MAIL', true);
if (!$sendMail) {
return true;
return true; // @codeCoverageIgnore
}
// get the email address
$email = $event->user->email;
@@ -103,12 +101,12 @@ class UserEventHandler
// send email.
try {
Mail::to($email)
->send(new RegisteredUserMail($address, $ipAddress));
Mail::to($email)->send(new RegisteredUserMail($address, $ipAddress));
// @codeCoverageIgnoreStart
} catch (Swift_TransportException $e) {
Log::error($e->getMessage());
}
// @codeCoverageIgnoreEnd
return true;
}