Skip to content
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

Add values to the session array #383

Open
markvdlaan93 opened this issue Jan 18, 2018 · 1 comment
Open

Add values to the session array #383

markvdlaan93 opened this issue Jan 18, 2018 · 1 comment
Labels

Comments

@markvdlaan93
Copy link

I'm having a controller which reads an integer from the session array in this manner:

if ($session->has('administration')) { $id = $session->get('entity_id'); return $this->getDoctrine()->getRepository('AppBundle:SomeEntity')->find($id); }

Currently I'm writing tests for this controller action but I can't find how to inject this integer in the sessions array. I tried the following:

$this->client = $this->makeClient(true); $this->client->getContainer()->set('session.storage.options.entity_id', 12);

I also tried the following:
$this->client = $this->makeClient(true); $session = new Session(new MockFileSessionStorage()); $session->set('administration', 12); $this->client->getContainer()->set('session', $session);

This, however doesn't work and seems to just ignore the value. Therefore, my question is how to store values in the session array in a functional test environment?

@alexislefebvre
Copy link
Collaborator

I don't have any solution but I'm wondering, how do users set the session? It should be easier to perform the same action that the user do, so it would set the data into the session before you use it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants