-
Notifications
You must be signed in to change notification settings - Fork 55
Add Messages Accessors #56
Conversation
|
Can this be merged in please? It's something I've ended up doing myself too |
|
Looking like this pull isn't wanted. I'll delete my fork and close the pull if it continues to be inactive to stop cluttering up this repo and my own account. |
|
Guys, we're really busy. This is an insane season, and my wife just had a baby, and some times open source has to be the first thing to get pushed down the road. Your pull is not unwanted. If it is, we would say it's unwanted. Sorry, but some times things just take time. Thanks for your PR, and I hope someone will be able to find time to look at it soon. |
|
Appreciate that. I'm just getting unfortunately used to having pulls to various projects get ignored for months on end. Worst offender was six months without even a response. |
src/Testing/InteractsWithMail.php
Outdated
| public function getMessagesFor(array $emails) | ||
| { | ||
| return $this->getMessages()->filter(function (Message $message) use ($emails) { | ||
| foreach ($emails as $email) { |
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.
For readability's sake, maybe consider:
return collect($emails)->contains(function ($email) use ($message) {
return $message->hasRecipient($email);
}
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 like it.
|
@mcordingley Thanks again for your patience, and to reiterate @mattstauffer's comments, we really appreciate your contribution! Overall this is close! I made a readability suggestion and I'd like to see tests for the new methods. |
src/Testing/InteractsWithMail.php
Outdated
| * @param array $emails | ||
| * @return MailThiefCollection | ||
| */ | ||
| public function getMessagesFor(array $emails) |
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.
If this intended to be used with singular and multiple emails being passed in; consider removing the typehint and add the following:
if (! is_array($emails)) {
$emails = [$emails];
}This allows you to rewrite line 55 with return $this->getMessagesFor($email)->last();.
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.
Alternatively, I think you could also do:
$emails = (array) $emails;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.
Makes sense. I generally like using as strict of type hints as possible, which means not having arguments that could be different types. But, I see how this would be much nicer from a user perspective to take in both strings and arrays. Updating the code to match now.
|
I have some time coming up soon. I'll see what I can do. |
|
Tests added. These changes should be good to go, now. |
|
👌🏼 Thank you! This is a great addition. |
|
Whoo! Thanks! |
I find myself in situations where other messages may have been sent after the one that I'm interested in making an assertion about. I can continue to have these locally, but they should be of more general use to others.
In particular, this should help with #53. The assertion methods may easily be rewritten to take advantage of these methods to become more general in which email gets matched.