Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.6k
[FrameworkBundle] Prepare session in functionnal tests#61110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:7.4
Are you sure you want to change the base?
Conversation
$session = $client->getSession(); | ||
$session->set('name', 'drak'); | ||
$session->save(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I would expect the following behavior
$session = $client->getSession(); $session->set('name', 'drak'); $session->save(); $session = $client->getSession(); $session->set('foo', 'bar'); $session->save(); $crawler = $client->request('GET', '/session'); $this->assertStringContainsString('Welcome back drak, nice to meet you.', $crawler->text());
meaning we're not resetting the session when callingget
.
Could you add it to the test ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Sure, done.
Hello,
I propose to add a
getSession()
method to theKernelBrowser
class to be able to prepare the session before sending a HTTP request in a functionnal test. It could be used to preset CSRF tokens, A/B testing data, user preferences, or any stateful information required for the test.I also propose to use
getSession()
in theloginUser()
method. Then, the session could be preset either before or after the login, without risking to be overwritten.In this example, the session will contain :
Thanks in advance for your feedbacks 😄