php - Symfony 5.1 to 5.2 unit testing do not authenticate via guard authenticator

I 'm working with Symfony 5.1 using the firewall and a guard authenticator;
secured_area:
pattern: ^/
stateless: true
provider: chain_provider
guard:
authenticators:
- App\<pathToAuthenticator>
entry_point: App\<pathToAuthenticator>
All was working fine with 5.1.
I've recently upgrade to Symfony 5.2 and almost all working fine except Unit tests.
When i do a step by step debugging, it's not stepping into theAuthenticator
anymore like it was the case previously (in 5.1).
Any parameter missing in my configuration ? Default parameter have change ?
Answer
Solution:
Eventually, i 've found the pb, and the solution, in my test do :
self::$_client->request(
'GET',
'/items',
array(),
array(),
array('HTTP_Accept' => 'application/json', 'CONTENT_TYPE' => 'application/json'),
json_encode($payload)
);
And i have a request matcher that filter on JSON request :
class JsonRequestMatcher implements RequestMatcherInterface
{
public function matches(Request $request)
{
$format = $request->getPreferredFormat();
return $format === "json";
}
}
For a reason i have not determined, when the header send 'HTTP_Accept' $format value in the request matcher is "html" and the request is not processed ... then it crash futher on.
When i change 'HTTP_Accept' to 'HTTP_ACCEPT', (yes, just upper case the header !) it works, and the value for $format is the one expected (ie : "json"). Thanks to Cerad for his support and for some commands i just don't know was existing in Symfony ;-)
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: warning: undefined array key
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.