get('doctrine')->getManager(); } /** * Cree un client authentifie via /login_check. La configuration du projet * pose le JWT dans un cookie HTTP-only `BEARER` (cf. lexik_jwt_authentication.yaml) * et retire le token du body de reponse ; le client BrowserKit persiste * automatiquement le cookie pour les requetes suivantes. */ protected function authenticatedClient(string $username, string $password): Client { $client = self::createClient(); $response = $client->request('POST', '/login_check', [ 'headers' => ['Content-Type' => 'application/json'], 'json' => ['username' => $username, 'password' => $password], ]); self::assertContains( $response->getStatusCode(), [200, 204], 'Login failed for '.$username.': '.$response->getStatusCode(), ); return $client; } }