* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ /** * Mink steps dictionary for Behat BDD tool. * * @author Konstantin Kudryashov */ trait MinkDictionary { private $mink; private $minkParameters; /** * Sets Mink instance. * * @param Mink $mink Mink session manager */ public function setMink(Mink $mink) { $this->mink = $mink; } /** * Returns Mink instance. * * @return Mink */ public function getMink() { return $this->mink; } /** * Sets parameters provided for Mink. * * @param array $parameters */ public function setMinkParameters(array $parameters) { $this->minkParameters = $parameters; } /** * Returns specific mink parameter. * * @param string $name * * @return mixed */ public function getMinkParameter($name) { return isset($this->minkParameters[$name]) ? $this->minkParameters[$name] : null; } /** * Returns Mink session. * * @param string|null $name name of the session OR active session will be used * * @return Session */ public function getSession($name = null) { return $this->getMink()->getSession($name); } /** * Returns Mink session assertion tool. * * @param string|null $name name of the session OR active session will be used * * @return WebAssert */ public function assertSession($name = null) { return $this->getMink()->assertSession($name); } /** * Opens homepage. * * @Given /^(?:|I )am on (?:|the )homepage$/ * @When /^(?:|I )go to (?:|the )homepage$/ */ public function iAmOnHomepage() { $this->getSession()->visit($this->locatePath('/')); } /** * Opens specified page. * * @Given /^(?:|I )am on "(?P[^"]+)"$/ * @When /^(?:|I )go to "(?P[^"]+)"$/ */ public function visit($page) { $this->getSession()->visit($this->locatePath($page)); } /** * Reloads current page. * * @When /^(?:|I )reload the page$/ */ public function reload() { $this->getSession()->reload(); } /** * Moves backward one page in history. * * @When /^(?:|I )move backward one page$/ */ public function back() { $this->getSession()->back(); } /** * Moves forward one page in history * * @When /^(?:|I )move forward one page$/ */ public function forward() { $this->getSession()->forward(); } /** * Presses button with specified id|name|title|alt|value. * * @When /^(?:|I )press "(?P