[FrameworkBundle] Add login() and logout() to WebTestCase #35644
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Followup of #28065
As a side-note, the two added
protectedmethods are supposed to be overriden by the developer if needed.getLoginToken()might be overriden if the user wants to use a token different than theUsernamePasswordToken, like aPostAuthenticationGuardTokenor any other kind of token that is available in its security config (like Oauth, SymfonyConnect, etc.). Someone might also use aPreAuthenticatedTokenand use theAuthenticationManagerto->authenticate()it and retrieve the result.authenticateToken()might be overriden in cases where setting a cookie has no effect, like when authentication is stateless or based on internal systems (when creating JWT tokens and use internal secrets to do so, or other cases I can't imagine).The
login()method returns theTokenInterfacein case the user might need it for further use, such as directly retrieving the logged inUserobject for instance, in order to make more assertions if the current functional tests is doing actions on the User.