@@ -622,22 +622,19 @@ This allows you to create all types of requests you can think of:
622622Multiple Requests in One Test
623623.............................
624624
625- After you send one request, subsequent ones will make the client reboot
626- the kernel, recreating the container from scratch.
627- This ensures that requests are "isolated" using "new" service objects.
628- However, this can cause some unexpected behaviors. For example, the
629- security token will be cleared, Doctrine entities will be "detached"…
630-
631- Calling the client's
632- :method: `Symfony\\ Bundle\\ FrameworkBundle\\ KernelBrowser::disableReboot `
633- method is the first step to work around this, as this will reset the kernel
634- instead of rebooting it. Now, resetting the kernel will call the ``reset() ``
635- method of every ``kernel.reset `` tagged service, which will **also ** clear
636- the security token, detach entities and so on.
637-
638- As such, the next step is to create a
639- :doc: `compiler pass </service_container/compiler_passes >` to remove the
640- ``kernel.reset `` tag from these services in your test environment::
625+ After making a request, subsequent requests will make the client reboot the kernel.
626+ This recreates the container from scratch to ensures that requests are isolated
627+ and use new service objects each time. This behavior can have some unexpected
628+ consequences: for example, the security token will be cleared, Doctrine entities
629+ will be detached, etc.
630+
631+ First, you can call the client's :method: `Symfony\\ Bundle\\ FrameworkBundle\\ KernelBrowser::disableReboot `
632+ method to reset the kernel instead of rebooting it. In practice, Symfony
633+ will call the ``reset() `` method of every service tagged with ``kernel.reset ``.
634+ However, this will **also ** clear the security token, detach Doctrine entities, etc.
635+
636+ In order to solve this issue, create a :doc: `compiler pass </service_container/compiler_passes >`
637+ to remove the ``kernel.reset `` tag from some services in your test environment::
641638
642639 // src/Kernel.php
643640 namespace App;
@@ -651,7 +648,7 @@ As such, the next step is to create a
651648 {
652649 use MicroKernelTrait;
653650
654- // …
651+ // ...
655652
656653 protected function build(ContainerBuilder $container): void
657654 {
@@ -662,10 +659,10 @@ As such, the next step is to create a
662659 // prevents the security token to be cleared
663660 $container->getDefinition('security.token_storage')->clearTag('kernel.reset');
664661
665- // prevents entities to be detached
662+ // prevents Doctrine entities to be detached
666663 $container->getDefinition('doctrine')->clearTag('kernel.reset');
667664
668- // …
665+ // ...
669666 }
670667 });
671668 }
0 commit comments