php - How can I persist data with Symfony2's session service during a functional test? -
i'm writing functional test action uses symfony2's session service fetch data. in test class's setup
method, call $this->get('session')->set('foo', 'bar');
. if output session data (using print_r($this->get('session')->all());
) either in setup
or in actual test method, foo => bar
. if try outputting session data action being tested, empty array. know why happening, , how can prevent it?
i should note if call $_session['foo'] = 'bar'
within setup()
data persisted , can access action - problem seems local symfony2's session service.
firstly try using client's container (i'm assuming you're using webtestcase):
$client = static::createclient(); $container = $client->getcontainer();
if still doesn't work try saving session:
$session = $container->get('session'); $session->set('foo', 'bar'); $session->save();
i didn't try in functional tests that's how works in behat steps.
Comments
Post a Comment