-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
c470c19 to
989654b
Compare
d8011a5 to
b4a8647
Compare
b4a8647 to
4be5343
Compare
|
Bumping this, as that would IMO be a great addition to the framework. Preparing the request with some session data before the request is emitted can be very useful to mock previous user interactions in multi-step operations. |
4be5343 to
2bf5391
Compare
|
I added a PR in the documentation : symfony/symfony-docs#21352 |
b2e1cc1 to
a4ebe76
Compare
| $session = $this->getSession(); | ||
| if (!$session instanceof SessionInterface) { |
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.
| $session = $this->getSession(); | |
| if (!$session instanceof SessionInterface) { | |
| if (!$session = $this->getSession()) { |
| $session->set('foo', 'bar'); | ||
| $session->save(); | ||
|
|
||
| // prove remembered name from programmatically prepared session |
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.
| // prove remembered name from programmatically prepared session | |
| // prove remembered name from programatically prepared session |
| * Deprecate `Symfony\Bundle\FrameworkBundle\Console\Application::add()` in favor of `Symfony\Bundle\FrameworkBundle\Console\Application::addCommand()` | ||
| * Add `assertEmailAddressNotContains()` to the `MailerAssertionsTrait` | ||
| * Add `framework.type_info.aliases` option | ||
| * Add `KernelBrowser::getSession()` method |
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.
| * Add `KernelBrowser::getSession()` method | |
| * Add `KernelBrowser::getSession()` |
a4ebe76 to
a8f045f
Compare
|
Thank you @cyve. |
Hello,
I propose to add a
getSession()method to theKernelBrowserclass 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 😄