0

I have a simple Scenario.

  • Given Bob logs in
  • And Alice logs in
  • Bob edits Article 1 and Saves it.
  • Alice edits Article 1 and saves but should see that Bob already did changes.
  • Alice should reload -> Alice sees changes ...

Honorable mentions : How to authenticate once in Behat environment and How to simulate two users.

My problem is that I have to Authenticate users in different sessions but the kernel always returns same session name/id. What I don't know is how can I authenticate users in sessions named according to the Mink Session name?

stevenll
  • 1,025
  • 12
  • 29

1 Answers1

1

You can try to use mink functionality and create a few sessions inside behat environment.

So, from the very beginning you have one default session:

$this->getSession(); 

And you can register new session with exact driver.

New instance of needed driver. f.e. GoutteDriver.

$goutteDriver = new GoutteDriver();
$sess = new \Behat\Mink\Session($goutteDriver);
$this->getMink()->registerSession('newSession', $sess);

And then use it in your steps:

$this->getSession('newSession')->getPage();

But the new session won't has any params from your behat.yml. So take care about that. You can get all the params from

$this->getMinkParameters();
Igor Lantushenko
  • 1,771
  • 10
  • 19
  • I have already tried this, but when I try to Authenticate users they are assigned to PHPSSID and not FOO for example. – stevenll Feb 23 '16 at 07:40
  • 1
    So, you are using Symfony2 session by default, right? and so you are creating new mink session with symfony2 driver? If its doesn't help - then you need to play around with $this->getContainer()->get('session'); which has lots of get and set methods. And I'll try to investigate and write you back. – Igor Lantushenko Feb 23 '16 at 08:37