/** * Configures default Mink session before each scenario. * Configuration is based on provided scenario tags: * * `@javascript` tagged scenarios will get `javascript_session` as default session * `@mink:CUSTOM_NAME tagged scenarios will get `CUSTOM_NAME` as default session * Other scenarios get `default_session` as default session * * `@insulated` tag will cause Mink to stop current sessions before scenario * instead of just soft-resetting them * * @param ScenarioLikeTested $event * * @throws ProcessingException when the @javascript tag is used without a javascript session */ public function prepareDefaultMinkSession(ScenarioLikeTested $event) { $scenario = $event->getScenario(); $feature = $event->getFeature(); $session = null; foreach (array_merge($feature->getTags(), $scenario->getTags()) as $tag) { if ('javascript' === $tag) { $session = $this->getJavascriptSession($event->getSuite()); } elseif (preg_match('/^mink\\:(.+)/', $tag, $matches)) { $session = $matches[1]; } } if (null === $session) { $session = $this->getDefaultSession($event->getSuite()); } if ($scenario->hasTag('insulated') || $feature->hasTag('insulated')) { $this->mink->stopSessions(); } else { $this->mink->resetSessions(); } $this->mink->setDefaultSessionName($session); }