Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Laravel module email assertions #22

Open
janhenkgerritsen opened this issue Jan 26, 2016 · 10 comments
Open

Laravel module email assertions #22

janhenkgerritsen opened this issue Jan 26, 2016 · 10 comments
Assignees
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@janhenkgerritsen
Copy link
Contributor

Add email assertions to Laravel 5 module.

Idea for implementation came from https://laracasts.com/series/phpunit-testing-in-laravel/episodes/12. Will work with all default mail transports in Laravel, they all have the beforeSendPerformed method.

Have to think about a good API for these assertions though.

@janhenkgerritsen janhenkgerritsen self-assigned this Jan 26, 2016
@DavertMik
Copy link
Member

We have seeEmailIsSent in Symfony2 module but it doesn't perform any checks on type of email messages. Just verifies that something was sent...

@janhenkgerritsen
Copy link
Contributor Author

I could just provide assertions for the last email that was sent, things like seeEmailIsSent, seeEmailIsSentTo, seeEmailIsSentFrom, seeEmailIsSentWithSubject, etc. But what if multiple emails were sent?

One option is to just loop through all emails that were sent and check if one of those satisfies the assertion.

Another option is to just add a method grabEmails and let users handle those cases themselves.

In the Laracast video Jeffrey adds a second optional parameter for the message object to the assertion methods, but if we do that the assertions should probably have other names.

Any preferences or other ideas?

@DavertMik
Copy link
Member

My preferable syntax will be:

seeEmailIsSent(array $params = null, $num = 1);

so to be used as:

$I->seeEmailIsSent();
$I->seeEmailIsSent(['from' => '[email protected]'], 2);
$I->seeEmailIsSent(['subject' => 'XXX', 'from' => 'yyyy']);

@janhenkgerritsen
Copy link
Contributor Author

Ok, that look's good to me too. I don't know when I have time to implement it yet though.

@DavertMik
Copy link
Member

I don't know when I have time to implement it yet though.

Yep, that's always an issue. Maybe someone who accidentally finds oneself here will have a chance to implement it =)

@grahamsutton
Copy link

Accidentally found myself here and I am considering implementing this. Is there any documentation on the inner workings of Codeception's email support?

@janhenkgerritsen I can help out if you're still interested in implementing this.

@Naktibalda
Copy link
Member

There is no such thing as "Codeception email support", this functionality is module specific.

@janhenkgerritsen
Copy link
Contributor Author

It would be great if you implement this, because I don't really have the time to do this myself. So if you come up with a nice solution it will definitely get merged :)

@grahamsutton
Copy link

@janhenkgerritsen Sounds good! I will start working on it now.

@edno
Copy link
Contributor

edno commented Apr 25, 2019

@janhenkgerritsen, @grahamsutton - any progress on implementing email assertions? If not, then I'll be happy to try to push something this weekend.

@Naktibalda Naktibalda transferred this issue from Codeception/Codeception Jan 17, 2021
@TavoNiievez TavoNiievez added enhancement New feature or request help wanted Extra attention is needed labels Jan 19, 2021
@TavoNiievez TavoNiievez changed the title Laravel 5 module email assertions Laravel module email assertions Jan 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

6 participants