Skip to content

Add __clone to Session. - #368

Merged
everzet merged 1 commit into
minkphp:developfrom
metaltoad:clone_session
Aug 12, 2013
Merged

everzet merged 1 commit into
minkphp:developfrom
metaltoad:clone_session

Conversation

@ctrahey

@ctrahey ctrahey commented Aug 10, 2013

Copy link
Copy Markdown
Contributor

Cloning a Session now creates a new driver & uniqueId, so that a
cloned session is a truly seperate but very similar browsing context.

Cloning a Session now creates a new driver & uniqueId, so that a
cloned session is a truly seperate but very similar browsing context.
@ctrahey

ctrahey commented Aug 10, 2013

Copy link
Copy Markdown
Contributor Author

For visibility into why I'm looking for this functionality, here is a step-definition using this (and Selenium2Driver PR70) that allows a Scenario to include multiple "users" (called 'personas' in my lexicon, but that's arbitrary) to start to test real-time multi-user features (like commenting + notifications, etc.).

/**
 * @Given /^I adopt the persona (.*)$/
 */
public function changePersona($name) {
  $mink = $this->getMink();
  if(!$mink->hasSession($name)) {
    $newSession = clone $this->getSession();
    $mink->registerSession($name, $newSession);
  }
  $mink->setDefaultSessionName($name);
}

And then the idea is to have scenarios like this:

Given I adopt the persona "Chris Trahey"
# log into site as a known identity...
Given I adopt the persona "Nate"
# log into site ...
# find the user Chris Trahey
# perform some action that should create a notification for Chris Trahey
Given I adopt the persona "Chris Trahey"
Then I should see a notification
And I should see "Nate"

With these PRs and my step-definition above, this creates 2 instances of the browser, each with a different session/user. This is highly empowering for social sites!!

@ftassi

ftassi commented Aug 10, 2013

Copy link
Copy Markdown

👍

everzet added a commit that referenced this pull request Aug 12, 2013
@everzet
everzet merged commit 2c08941 into minkphp:develop Aug 12, 2013
@everzet

everzet commented Aug 12, 2013

Copy link
Copy Markdown
Contributor

Merged, thanks!

@ctrahey

ctrahey commented Aug 12, 2013

Copy link
Copy Markdown
Contributor Author

Thanks!

@stof

stof commented Jan 14, 2014

Copy link
Copy Markdown
Member

We are currently discussing about reverting this before releasing 1.6.x, because it creates several issues (the browsing context is not really separate). See #445 for the discussion

stof added a commit to stof/Mink that referenced this pull request Jan 19, 2014
Cloning a Session would require making sure that all drivers all
cloneable, which would then require that all dependencies of these drivers
maintaining a state are cloneable as well. But this is not the case in the
existing drivers.
Thus, cloning the session would require checking that the object graph is
cloned in a consistent way (i.e. all references to the driver are
referencing a single clone for instance). The changes started for Mink 2.0
to have a cleaner architecture are making it really hard to ensure this.
So the decision was to revert this change before creating a stable release
including it.
Reverts minkphp#368
Closes minkphp#445
stof added a commit to stof/Mink that referenced this pull request Jan 20, 2014
Cloning a Session would require making sure that all drivers all
cloneable, which would then require that all dependencies of these drivers
maintaining a state are cloneable as well. But this is not the case in the
existing drivers.
Thus, cloning the session would require checking that the object graph is
cloned in a consistent way (i.e. all references to the driver are
referencing a single clone for instance). The changes started for Mink 2.0
to have a cleaner architecture are making it really hard to ensure this.
So the decision was to revert this change before creating a stable release
including it.
Reverts minkphp#368
Closes minkphp#445
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants