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

Functional tests for sending emails (via both Swiftmailer and Symfony Mailer) #150

Merged
merged 8 commits into from
Jun 22, 2022

Conversation

Zales0123
Copy link
Member

Q A
Bug fix? no
New feature? no
BC breaks? no
Deprecations? no
Related tickets
License MIT

Until now, there are no real functional tests in the bundle. I believe we need to finally change it and preferably do it before the next minor release 🚀

Therefore, this PR provides some basic tests that check the content of sent emails (both with Swiftmailer and Symfony Mailer). The most important changes:

  • multiple test environments (test, test_with_swiftmailer, test_with_symfony_mailer and test_no_mailer) for easier CI setup
  • MessagesProvider service, based on the EmailChecker from Sylius
  • FileTransport for Symfony Mailer in the test environment, as it does not provide any spool messages functionality (at least I didn't find one 🖖)

More tests -> better 🎉

@Zales0123 Zales0123 added Enhancement Minor issues and PRs improving the current solutions (optimizations, typo fixes, etc.). DX labels Jun 20, 2022
@Zales0123 Zales0123 requested a review from a team as a code owner June 20, 2022 23:14
@Zales0123 Zales0123 force-pushed the test-sent-emails-ver-1 branch 4 times, most recently from 8dfcb68 to cfec094 Compare June 21, 2022 05:55
Copy link
Member

@lchrusciel lchrusciel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added comas adding a little bit of noise to the whole PR

.github/workflows/build.yml Show resolved Hide resolved
src/Bundle/test/src/Mailer/FileTransport.php Outdated Show resolved Hide resolved

protected function setUp(): void
{
self::bootKernel(['environment' => 'test_with_swiftmailer']);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as we are forcing given envs in these tests, what will happen in test env (both adapters are turned on). Can we have a test for both of them enabled, but with not default adapter set?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If no default adapter is set, then the swiftmailer adapter would be used (so it would be the same test like this one 💃). We can think about extending this test suite, but maybe it can be done in a separate PR?

@Zales0123
Copy link
Member Author

added comas adding a little bit of noise to the whole PR

It was needed to make the build green 💃

@lchrusciel lchrusciel merged commit 7aa1e0f into Sylius:master Jun 22, 2022
@Zales0123 Zales0123 deleted the test-sent-emails-ver-1 branch June 22, 2022 13:54
lchrusciel added a commit that referenced this pull request Jun 23, 2022
…les0123)

This PR was merged into the 1.7-dev branch.

Discussion
----------

| Q               | A
| --------------- | -----
| Bug fix?        | no
| New feature?    | no
| BC breaks?      | no
| Deprecations?   | no
| Related tickets |  mentioned in #150 (comment)
| License         | MIT

Commits
-------

75e74e7 Add test for Swiftmailer adapter as the default one
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DX Enhancement Minor issues and PRs improving the current solutions (optimizations, typo fixes, etc.).
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants