-
Notifications
You must be signed in to change notification settings - Fork 111
Fixes #73 : allow Message to not has "To" header #160
Conversation
LGTM |
+1 |
test/Transport/SendmailTest.php
Outdated
$this->transport->send($message); | ||
} | ||
|
||
public function testDonotAllowMessageDoesnotHasToAndCcAndBccHeader() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please fix test method name, I think it should be:
testDoNotAllowMessageWithoutToAndCcAndBccHeaders
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
test/Transport/SendmailTest.php
Outdated
|
||
public function testDonotAllowMessageDoesnotHasToAndCcAndBccHeader() | ||
{ | ||
$this->expectException('Zend\Mail\Exception\RuntimeException'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please move this before line which should thrown an exception. Like that it's confusing, and the exception could be thrown anywhere below. Can we also use ::class
notation, please?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/Transport/Sendmail.php
Outdated
@@ -148,8 +148,14 @@ protected function prepareRecipients(Mail\Message $message) | |||
{ | |||
$headers = $message->getHeaders(); | |||
|
|||
if (! $headers->has('to')) { | |||
throw new Exception\RuntimeException('Invalid email; contains no "To" header'); | |||
if (! ($hasTo = $headers->has('to')) && ! $headers->has('cc') && ! $headers->has('bcc')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I got a bit confused with this assignment in if
statement, in general I like them, but only when we have single condition, here it's more tricky so I would suggest to move assignment before the if
statement and then use the variable in the statement with other checks:
$hasTo = $headers->has('to');
if (! $hasTo && ! $headers->has('cc') && ! $headers->has('bcc')) {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
…d move expectException() before transport->send() call
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🚢
Manually merged via 8ca640a, thanks! |
Fixes #73
Check at least one of "To", "Cc", and "Bcc"