Behat/CommonContexts — Issue #8: RedirectContext resets session
Author: schoren
Created: 2011-11-24 14:33:52+00:00
State: open

My controller requires to have an active user session to work. I'm using RedirectContext to test emails. this is the feature:

Background:
Given I am logged in as "user" with password "pass

Scenario: Update a regular Users
...
When I do not follow redirects
And I press "Update"
Then email with subject "Subject" should have been sent to "email@example.com"
And I should be redirected to "/users/"

In /users/ the first line gets the logged user:

public function indexAction(){
$this->get('security.context')->getToken()->getUser()->getId()
...
}

This is the output of the test:

...
Then email with subject "Subject" should have been sent to "email@example.com"
PHP Fatal error: Call to a member function getId() on a non-object in UsersController.php on line 28