-
Notifications
You must be signed in to change notification settings - Fork 24
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
Update MailerAssertionsTrait.php: Adding Mailpit #204
base: main
Are you sure you want to change the base?
Conversation
I will add a link to Mailpit, as soon as Codeception/codeception.github.com#880 is merged.
* If your app performs an HTTP redirect after sending the email, you need to suppress it using [stopFollowingRedirects()](#stopFollowingRedirects) first. | ||
* | ||
* Limitation: | ||
* If your mail is sent in a Symfony console command and you start that command in your test with [$I->runShellCommand()](https://codeception.com/docs/modules/Cli#runShellCommand), |
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 clarify if this problem is also present in runSymfonyConsoleCommand, because when reading it seems to be exclusive of runShellCommand.
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'm not sure if I tried. But the mail assertions are working by looking at the web debug toolbar, aren't they?
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 didn't try runSymfonyConsoleCommand()
. Is there a way to pipe input to the command?
Right now, I'm doing:
$I->runShellCommand('printf "foobar" | php bin/console app:my_command --env=test');
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.
@ThomasLandauer yes, you can use the third parameter $consoleInputs
for that. So the equivalent to the above would be
$I->runSymfonyConsoleCommand('app:my_command', ['--env' => 'test'], ['foobar']);
* Limitation: | ||
* If your mail is sent in a Symfony console command and you start that command in your test with [$I->runShellCommand()](https://codeception.com/docs/modules/Cli#runShellCommand), | ||
* Codeception will not notice it. | ||
* As a more professional alternative, we recommend Mailpit, wchich also lets you test the content of the mail. |
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.
is not clear why it is more 'professional'.
Please explain what Mailpit is and how it works as an alternative to what within Codeception exactly, in what specific scenario you are going to recommend its use and how to integrate it into the functional testing workflow with this module.
by the way, there is a tiny typo in 'wchich'.
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.
Trying to get rid of the "Pending" badge at some of my comments...
EDIT: Looks like they (see below) weren't actually published till right now...
* If your app performs an HTTP redirect after sending the email, you need to suppress it using [stopFollowingRedirects()](#stopFollowingRedirects) first. | ||
* | ||
* Limitation: | ||
* If your mail is sent in a Symfony console command and you start that command in your test with [$I->runShellCommand()](https://codeception.com/docs/modules/Cli#runShellCommand), |
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'm not sure if I tried. But the mail assertions are working by looking at the web debug toolbar, aren't they?
* Limitation: | ||
* If your mail is sent in a Symfony console command and you start that command in your test with [$I->runShellCommand()](https://codeception.com/docs/modules/Cli#runShellCommand), | ||
* Codeception will not notice it. | ||
* As a more professional alternative, we recommend Mailpit, wchich also lets you test the content of the mail. |
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 merge Codeception/codeception.github.com#880 first, so I can add a link to it here. I don't think adding all features of Mailpit here is a good idea, cause nobody will ever update that :-)
IMO the main advantage is that you can assert the mail's content. And sooner or later most people probably want a mailcatching solution anyway (not just for testing, but also for development), so I'm figuring it's a good idea to tell them early...
* If your app performs an HTTP redirect after sending the email, you need to suppress it using [stopFollowingRedirects()](#stopFollowingRedirects) first. | ||
* | ||
* Limitation: | ||
* If your mail is sent in a Symfony console command and you start that command in your test with [$I->runShellCommand()](https://codeception.com/docs/modules/Cli#runShellCommand), |
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 didn't try runSymfonyConsoleCommand()
. Is there a way to pipe input to the command?
Right now, I'm doing:
$I->runShellCommand('printf "foobar" | php bin/console app:my_command --env=test');
Looks like I cannot link to Mailpit's entry at https://codeception.com/addons directly? |
I will add a link to Mailpit, as soon as Codeception/codeception.github.com#880 is merged.