Skip to content

Commit 2b715e4

Browse files
committed
Merge branch '6.3' into 6.4
* 6.3: [DI] Add note about testing service locators tip to not follow redirects when testing mailer
2 parents ddaaab4 + 9dd74ea commit 2b715e4

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
@@ -1901,6 +1901,13 @@ the :class:`Symfony\\Bundle\\FrameworkBundle\\Test\\MailerAssertionsTrait`::
19011901
}
19021902
}
19031903

1904+
.. tip::
1905+
1906+
If your controller returns a redirect response after sending the email, make
1907+
sure to have your client *not* follow redirects. The kernel is rebooted after
1908+
following the redirection and the message will be lost from the mailer event
1909+
handler.
1910+
19041911
.. _`Amazon SES`: https://github.com/symfony/symfony/blob/{version}/src/Symfony/Component/Mailer/Bridge/Amazon/README.md
19051912
.. _`App Password`: https://support.google.com/accounts/answer/185833
19061913
.. _`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
@@ -1024,6 +1024,15 @@ To unit test a service subscriber, you can create a fake container::
10241024
$serviceSubscriber = new MyService($container);
10251025
// ...
10261026

1027+
.. note::
1028+
1029+
When defining the service locator like this, beware that the
1030+
:method:`Symfony\\Contracts\\Service\\ServiceLocatorTrait::getProvidedServices`
1031+
of your container will use the return type of the closures as the values of the
1032+
returned array. If no return type is defined, the value will be ``?``. If you
1033+
want the values to reflect the classes of your services, the return type has
1034+
to be set on your closures.
1035+
10271036
Another alternative is to mock it using ``PHPUnit``::
10281037

10291038
use Psr\Container\ContainerInterface;

0 commit comments

Comments
 (0)