added MinkDictionary trait
This commit is contained in:
@@ -4,7 +4,8 @@ namespace Behat\MinkExtension\Context;
|
||||
|
||||
use Behat\Gherkin\Node\TableNode;
|
||||
|
||||
use Behat\Behat\Context\TranslatedContextInterface;
|
||||
use Behat\Behat\Context\TranslatedContextInterface,
|
||||
Behat\Behat\Event\ScenarioEvent;
|
||||
|
||||
/*
|
||||
* This file is part of the Behat\MinkExtension.
|
||||
@@ -22,6 +23,31 @@ use Behat\Behat\Context\TranslatedContextInterface;
|
||||
*/
|
||||
class MinkContext extends RawMinkContext implements TranslatedContextInterface
|
||||
{
|
||||
/**
|
||||
* @BeforeScenario
|
||||
*/
|
||||
public function prepareMinkSessions($event)
|
||||
{
|
||||
$scenario = $event instanceof ScenarioEvent ? $event->getScenario() : $event->getOutline();
|
||||
$session = $this->getMinkParameter('default_session');
|
||||
|
||||
foreach ($scenario->getTags() as $tag) {
|
||||
if ('javascript' === $tag) {
|
||||
$session = $this->getMinkParameter('javascript_session');
|
||||
} elseif (preg_match('/^mink\:(.+)/', $tag, $matches)) {
|
||||
$session = $matches[1];
|
||||
}
|
||||
}
|
||||
|
||||
if ($scenario->hasTag('insulated')) {
|
||||
$this->getMink()->stopSessions();
|
||||
} else {
|
||||
$this->getMink()->resetSessions();
|
||||
}
|
||||
|
||||
$this->getMink()->setDefaultSessionName($session);
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens specified page.
|
||||
*
|
||||
@@ -165,8 +191,8 @@ class MinkContext extends RawMinkContext implements TranslatedContextInterface
|
||||
{
|
||||
$field = $this->fixStepArgument($field);
|
||||
|
||||
if (isset($this->minkParameters['files_path']) && $this->minkParameters['files_path']) {
|
||||
$path = $this->minkParameters['files_path'].DIRECTORY_SEPARATOR.$path;
|
||||
if ($this->getMinkParameter('files_path')) {
|
||||
$path = $this->getMinkParameter('files_path').DIRECTORY_SEPARATOR.$path;
|
||||
}
|
||||
|
||||
$this->getSession()->getPage()->attachFileToField($field, $path);
|
||||
@@ -392,13 +418,13 @@ class MinkContext extends RawMinkContext implements TranslatedContextInterface
|
||||
*/
|
||||
public function showLastResponse()
|
||||
{
|
||||
if (null === $this->minkParameters['show_cmd']) {
|
||||
if (null === $this->getMinkParameter('show_cmd')) {
|
||||
throw new \RuntimeException('Set "show_cmd" parameter in behat.yml to be able to open page in browser (ex.: "show_cmd: firefox %s")');
|
||||
}
|
||||
|
||||
$filename = rtrim($this->minkParameters['show_tmp_dir'], DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.uniqid().'.html';
|
||||
$filename = rtrim($this->getMinkParameter('show_tmp_dir'), DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.uniqid().'.html';
|
||||
file_put_contents($filename, $this->getSession()->getPage()->getContent());
|
||||
system(sprintf($this->minkParameters['show_cmd'], escapeshellarg($filename)));
|
||||
system(sprintf($this->getMinkParameter('show_cmd'), escapeshellarg($filename)));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -407,6 +433,16 @@ class MinkContext extends RawMinkContext implements TranslatedContextInterface
|
||||
* @return array
|
||||
*/
|
||||
public function getTranslationResources()
|
||||
{
|
||||
return $this->getMinkTranslationResources();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns list of definition translation resources paths for this dictionary.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getMinkTranslationResources()
|
||||
{
|
||||
return glob(__DIR__.'/../../../../i18n/*.xliff');
|
||||
}
|
||||
@@ -421,7 +457,7 @@ class MinkContext extends RawMinkContext implements TranslatedContextInterface
|
||||
*/
|
||||
protected function locatePath($path)
|
||||
{
|
||||
$startUrl = rtrim($this->minkParameters['base_url'], '/') . '/';
|
||||
$startUrl = rtrim($this->getMinkParameter('base_url'), '/') . '/';
|
||||
|
||||
return 0 !== strpos($path, 'http') ? $startUrl . ltrim($path, '/') : $path;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user