Skip to content

Commit 6f0527c

Browse files
committed
minor symfony#7115 Better explain the most common problems when testing emails (javiereguiluz)
This PR was squashed before being merged into the 2.7 branch (closes symfony#7115). Discussion ---------- Better explain the most common problems when testing emails Testing emails is simple but in the past I've suffered lots of problems related to this. In fact, a few minutes ago I fixed a long standing wrong test thanks to this comment about page redirections and collectors: symfony/symfony#20282 (comment) I propose to create a new mini section to better explain the problems that you may face when testing emails. Commits ------- c2e0608 Better explain the most common problems when testing emails
2 parents 0d5968f + c2e0608 commit 6f0527c

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

email/testing.rst

+18-4
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,6 @@ Start with an easy controller action that sends an email::
2626
return $this->render(...);
2727
}
2828

29-
.. note::
30-
31-
Don't forget to enable the profiler as explained in :doc:`/testing/profiling`.
32-
3329
In your functional test, use the ``swiftmailer`` collector on the profiler
3430
to get information about the messages sent on the previous request::
3531

@@ -67,4 +63,22 @@ to get information about the messages sent on the previous request::
6763
}
6864
}
6965

66+
Troubleshooting
67+
---------------
68+
69+
Problem: The collector object is ``null``
70+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
71+
72+
The email collector is only available when the profiler is enabled and collects
73+
information, as explained in :doc:`/testing/profiling`.
74+
75+
Problem: The collector doesn't contain the email
76+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
77+
78+
If a redirection is performed after sending the email (for example when you send
79+
an email after a form is processed and before redirecting to another page), make
80+
sure that the test client doesn't follow the redirects, as explained in
81+
:doc:`/testing`. Otherwise, the collector will contain the information of the
82+
redirected page and the email won't be accessible.
83+
7084
.. _`Swift Mailer`: http://swiftmailer.org/

0 commit comments

Comments
 (0)