public function testSetDefaultSessionName() { $this->assertNull($this->mink->getDefaultSessionName()); $session = $this->getSessionMock(); $this->mink->registerSession('session_name', $session); $this->mink->setDefaultSessionName('session_name'); $this->assertEquals('session_name', $this->mink->getDefaultSessionName()); $this->setExpectedException('InvalidArgumentException'); $this->mink->setDefaultSessionName('not_registered'); }
public function enableGiffy($event) { if ($this->hasGiffyTag($event) || $this->mink->getDefaultSessionName() === static::GIFFY_TAG) { $this->giffyEnabled = true; $this->mink->setDefaultSessionName('giffy'); $this->mink->getSession()->getDriver()->resetCounter(); if ($this->useScenarioFolder) { if ('Scenario' === $event->getNode()->getNodeType()) { $this->path = str_replace(' ', '_', $event->getScenario()->getTitle()); } $this->mink->getSession()->getDriver()->setScenarioPath($this->path); } } }
/** * @Then /^I click (?:on )?"([^"]+)" in mail$/ */ public function clickInMail($text) { $message = $this->getCurrentMessage(); if ($message->hasPart('text/html')) { $links = $this->getCrawler($message)->filter('a')->each(function ($link) { return array('href' => $link->attr('href'), 'text' => $link->text()); }); } else { throw new \RuntimeException(sprintf('Unable to click in mail')); } $href = null; foreach ($links as $link) { if (false !== strpos($link['text'], $text)) { $href = $link['href']; break; } } if (null === $href) { throw new \RuntimeException(sprintf('Unable to find link "%s" in those links: "%s".', $text, implode('", "', array_map(function ($link) { return $link['text']; }, $links)))); } return $this->mink->getSession($this->mink->getDefaultSessionName())->visit($href); }
/** * @param string|null $name * * @return boolean */ private function hasEligibleMinkSession($name = null) { $name = $name ?: $this->mink->getDefaultSessionName(); return $this->mink->hasSession($name) && $this->mink->isSessionStarted($name); }