I use "liip/functional-test-bundle": "~1.8",
and "symfony/symfony": "~3.4",
and for my functional test I want set some data in session,but after set data in action, with the same key, I had null. Mytest class extends from extends WebTestCase
this is how I set data in test method
$session = $this->container->get('session');
$session->set('test', 2);
$this->getClient()->request(
Request::METHOD_GET,
$routing
);
config_test.yml
framework:
test: ~
session:
storage_id: session.storage.mock_file
name: "MOCKSESSID"
profiler:
collect: false
and in action
public function getEntityAction()
{
$test = $this->get('session')->get('test');
variable $test
equal null
How to set some data in session in functional test ?
when debugging, before request
session = {Symfony\Component\HttpFoundation\Session\Session} [5]
storage = {Symfony\Component\HttpFoundation\Session\Storage\MockFileSessionStorage} [8]
savePath = "/tmp"
id = "d5d7233a843594e94c42b6a0e5a14a86c2518fb5f0a6478732841547b3e93fd6"
name = "MOCKSESSID"
started = true
closed = false
data = {array} [3]
_sf2_attributes = {array} [1]
test = 2
and in action
$y = {Symfony\Component\HttpFoundation\Session\Session} [5]
storage ={Symfony\Component\HttpFoundation\Session\Storage\MockFileSessionStorage} [8]
savePath = "/home/ivan/hosts/fix/var/cache/test/sessions"
id = "5ade2581b9764"
name = "MOCKSESSID"
started = true
closed = false
data = {array} [3]
_sf2_attributes = {array} [1]
_security_main = "authuser data"
I don't understand why id and savePath different ?