-
-
Notifications
You must be signed in to change notification settings - Fork 20
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
How to access Session variable #149
Comments
hello @cooldude77 by "session", do you mean "http session"? Browser does not deal with http session. And the method |
Hey @nikophil , Sorry for not explaining it fully. I wish to test how controller logic behave when I set a session variable ( for eg. a filled cart in a web shop or an empty cart). Here I would like to set the session variable which I access in controller using RequestStack getRequest() method in my controller method and then getting the session from it. Based on values in session, controller performs a logic. I understand that the browser does not have session because it is handled by Mink. Will that be the same session as I explained above and can I manipulate it somewhere in test case ? Thanks. |
currently, browser does not provide a way to manipulate the session. Maybe this could be a nice addition to this lib? ping @kbond For now, maybe you could use this trick: symfony/symfony#45662 (comment) |
Yes, this would be a nice addition. You can currently access the "cookie jar": $browser->use(CookieJar $cookies) {
// ...
}) I use it successfully to expire the current session: $browser->use(function(CookieJar $cookieJar) {
$cookieJar->expire('MOCKSESSID');
}) It would be nice if we could do the following: $browser->use(SessionInterface $session) {
// ...
}) |
Maybe you can create correct session variables "one step before". This is integration tests... For example CartControllerTest
|
Hi,
For testing purposes , I need to access session and set a value to it .
The class Browser has marked session as protected . I could not find in documentation any reference to session in any method
Thanks
The text was updated successfully, but these errors were encountered: