Search code examples
phpdrupal-8mink

Mink does not switch back sessions?


$driver = clone $this->mink->getSession()->getDriver();
$driver->reset();
$this->mink->registerSession('new', new Session($driver));
$this->mink->setDefaultSessionName('new');
// Do things.

// Switch back to the original.
$this->mink->setDefaultSessionName('default');

Well, it didn't switch back, my passing test became a failing one. As you can see the session name originally was default. (This is not Drupal specific at all so it doesn't really belong on drupal SE.)


Solution

  • Don't use $this->mink->getSession()->getDriver()

    Use new driver with:

    $session = new Session(new GoutteDriver()); $this->getMink()->registerSession('new', $session);