check failed recipients, fixes #8
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
This commit is contained in:
parent
d10183c76c
commit
373974a40d
|
@ -117,9 +117,12 @@ class Request {
|
|||
$message->setFrom([$senderAddress => $senderName]);
|
||||
|
||||
try {
|
||||
$this->mailer->send($message);
|
||||
$failedRecipients = $this->mailer->send($message);
|
||||
if(count($failedRecipients) > 0) {
|
||||
return false;
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
return $e;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -212,7 +212,27 @@ class RequestTest extends \Test\TestCase {
|
|||
$this->assertSame($adminsWithEmail, count($result));
|
||||
}
|
||||
|
||||
public function testSendMail() {
|
||||
public function mailerSendProvider() {
|
||||
return [
|
||||
[
|
||||
false, [], true
|
||||
],
|
||||
[
|
||||
false, ['elu-thingol@sindar.gov'], false
|
||||
],
|
||||
[
|
||||
true, [], false
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider mailerSendProvider
|
||||
* @param $sendThrowsException
|
||||
* @param $sendResult
|
||||
* @param $expectedResult
|
||||
*/
|
||||
public function testSendMail($sendThrowsException, $sendResult, $expectedResult) {
|
||||
$adminName = 'Elu Thingol';
|
||||
$adminMail = 'elu-thingol@sindar.gov';
|
||||
$admin = $this->createMock(IUser::class);
|
||||
|
@ -247,15 +267,21 @@ class RequestTest extends \Test\TestCase {
|
|||
$this->mailer->expects($this->once())
|
||||
->method('createMessage')
|
||||
->willReturn($message);
|
||||
$this->mailer->expects($this->once())
|
||||
|
||||
$sendMocker = $this->mailer->expects($this->once())
|
||||
->method('send')
|
||||
->with($message);
|
||||
if($sendThrowsException) {
|
||||
$sendMocker->willThrowException(new \Exception('Expected Exception'));
|
||||
} else {
|
||||
$sendMocker->willReturn($sendResult);
|
||||
}
|
||||
|
||||
$this->defaults->expects($this->atLeastOnce())
|
||||
->method('getName')
|
||||
->willReturn('Cloud of Sindar');
|
||||
|
||||
$result = $this->invokePrivate($this->service, 'craftEmailTo', [$admin, $template]);
|
||||
$this->assertTrue($result);
|
||||
$this->assertSame($expectedResult, $result);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue