**Symfony version(s) affected**: 5.3 **Description** <!-- A clear and concise description of the problem. --> Generating a CSRF token in a test and check if it is valid doesn't work. > Test ```php $client = self::createClient(); $token = self::getContainer()->get('security.csrf.token_manager')->getToken('id')->getValue(); $client->request('POST', '/test', ['token' => $token]); self::assertSame('valid', $client->getResponse()->getContent()); ``` > Controller ```php /** * @Route("/test") */ public function __invoke(Request $request): Response { $tokenValid = $this->isCsrfTokenValid('id', $request->request->get('token')); return new Response($tokenValid ? 'valid' : 'invalid'); } ``` **How to reproduce** <!-- Code and/or config needed to reproduce the problem. If it's a complex bug, create a "bug reproducer" as explained in: https://symfony.com/doc/current/contributing/code/reproducer.html --> [Reproducer](https://github.com/YaFou/symfony-csrf-test) **Possible Solution** <!--- Optional: only if you have suggestions on a fix/reason for the bug --> I will search one and open a PR if needed **Additional context** <!-- Optional: any other context about the problem: log messages, screenshots, etc. --> Is related to #41046