You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm experimenting an issue with WebTestCase.
When I try to create a Client through WebTestCase::createClient, it returns me an instance of FrameworkBundle\Client.
FrameworkBundle\Client inherits from HttpKernel\Client, which override its inherited method filterRequest from BrowserKit\Client to remap the BrowserKit\Request into a better supportable HttpKernel\Request, which allows to include Session.
Everything seems fine, until you trigger the $client->request.
If any code relies on Session through $request->getSession, it is always null because it never gets injected into this Request.
Even though it's a broken patch, I would like to point you something.
By manually updating the FrameworkBundle\Client in method filterRequest and injecting the session manually, this issue gets fixed.
Commits
-------
3ad01c0 Update src/Symfony/Bundle/FrameworkBundle/EventListener/TestSessionListener.php
Discussion
----------
Fix broken web test cases with session already started
This PR fixes the issues highlighted in PR #4445 and #3741 by not overriding the session id if the session is already started.
---------------------------------------------------------------------------
by travisbot at 2012-05-29T19:06:33Z
This pull request [passes](http://travis-ci.org/symfony/symfony/builds/1468970) (merged 3ad01c0 into adf07f1).
---------------------------------------------------------------------------
by stloyd at 2012-05-29T19:07:54Z
Look at #2040. It's quite old, but there is at least some "reason" =)
---------------------------------------------------------------------------
by guilhermeblanco at 2012-05-29T20:57:27Z
@stloyd it seems to me that doing a session_id() (and now as $session->setId()) is still wrong.
The right should be a regeneration of the id then, which would still make my code pass. The problem is that setId method checks for a possible regeneration/double attribution, which prevents an already started session (from a WebTestCase) to live peacefully with the TestSessionListener, because it will always try to set an id.
So either we allow to regenerate ids or this code is not only useless for 2.1, but actually broken.
---------------------------------------------------------------------------
by drak at 2012-05-30T02:42:47Z
@guilhermeblanco - When I was doing the session refactoring I wanted to make exactly the patch this PR now but I didnt because I wast sure if there were reasons I was unaware of. @fabpot - I would merge this PR if it fixes the related tickets.
Hi,
I'm experimenting an issue with WebTestCase.
When I try to create a Client through WebTestCase::createClient, it returns me an instance of FrameworkBundle\Client.
FrameworkBundle\Client inherits from HttpKernel\Client, which override its inherited method filterRequest from BrowserKit\Client to remap the BrowserKit\Request into a better supportable HttpKernel\Request, which allows to include Session.
Everything seems fine, until you trigger the $client->request.
If any code relies on Session through $request->getSession, it is always null because it never gets injected into this Request.
Even though it's a broken patch, I would like to point you something.
By manually updating the FrameworkBundle\Client in method filterRequest and injecting the session manually, this issue gets fixed.
Attached you have a stack trace that I came from:
The text was updated successfully, but these errors were encountered: