Skip to content

Commit 60d92cd

Browse files
committed
Merge branch '6.4' into 7.0
* 6.4: [DI] Add note about testing service locators tip to not follow redirects when testing mailer
2 parents f74f79c + 2b715e4 commit 60d92cd

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

mailer.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1807,6 +1807,13 @@ the :class:`Symfony\\Bundle\\FrameworkBundle\\Test\\MailerAssertionsTrait`::
18071807
}
18081808
}
18091809

1810+
.. tip::
1811+
1812+
If your controller returns a redirect response after sending the email, make
1813+
sure to have your client *not* follow redirects. The kernel is rebooted after
1814+
following the redirection and the message will be lost from the mailer event
1815+
handler.
1816+
18101817
.. _`Amazon SES`: https://github.com/symfony/symfony/blob/{version}/src/Symfony/Component/Mailer/Bridge/Amazon/README.md
18111818
.. _`App Password`: https://support.google.com/accounts/answer/185833
18121819
.. _`Brevo`: https://github.com/symfony/symfony/blob/{version}/src/Symfony/Component/Mailer/Bridge/Brevo/README.md

service_container/service_subscribers_locators.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,6 +1004,15 @@ To unit test a service subscriber, you can create a fake container::
10041004
$serviceSubscriber = new MyService($container);
10051005
// ...
10061006

1007+
.. note::
1008+
1009+
When defining the service locator like this, beware that the
1010+
:method:`Symfony\\Contracts\\Service\\ServiceLocatorTrait::getProvidedServices`
1011+
of your container will use the return type of the closures as the values of the
1012+
returned array. If no return type is defined, the value will be ``?``. If you
1013+
want the values to reflect the classes of your services, the return type has
1014+
to be set on your closures.
1015+
10071016
Another alternative is to mock it using ``PHPUnit``::
10081017

10091018
use Psr\Container\ContainerInterface;

0 commit comments

Comments
 (0)