Skip to content
This repository has been archived by the owner on Mar 20, 2024. It is now read-only.

Commit

Permalink
Merge pull request #69 from ICANS/master
Browse files Browse the repository at this point in the history
Better access to mink configuration parameters
  • Loading branch information
everzet committed Mar 12, 2013
2 parents cf22123 + ffaa38a commit 07014c6
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 3 deletions.
22 changes: 22 additions & 0 deletions src/Behat/MinkExtension/Context/MinkDictionary.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,16 @@ public function getMink()
return $this->mink;
}

/**
* Returns the parameters provided for Mink.
*
* @return array
*/
public function getMinkParameters()
{
return $this->minkParameters;
}

/**
* Sets parameters provided for Mink.
*
Expand All @@ -68,6 +78,18 @@ public function getMinkParameter($name)
return isset($this->minkParameters[$name]) ? $this->minkParameters[$name] : null;
}

/**
* Applies the given parameter to the Mink configuration. Consider that all parameters get reset for each
* feature context.
*
* @param string $name The key of the parameter
* @param string $value The value of the parameter
*/
public function setMinkParameter($name, $value)
{
$this->minkParameters[$name] = $value;
}

/**
* Returns Mink session.
*
Expand Down
28 changes: 25 additions & 3 deletions src/Behat/MinkExtension/Context/RawMinkContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@ public function getMink()
return $this->mink;
}

/**
* Returns the parameters provided for Mink.
*
* @return array
*/
public function getMinkParameters()
{
return $this->minkParameters;
}

/**
* Sets parameters provided for Mink.
*
Expand All @@ -69,6 +79,18 @@ public function getMinkParameter($name)
return isset($this->minkParameters[$name]) ? $this->minkParameters[$name] : null;
}

/**
* Applies the given parameter to the Mink configuration. Consider that all parameters get reset for each
* feature context.
*
* @param string $name The key of the parameter
* @param string $value The value of the parameter
*/
public function setMinkParameter($name, $value)
{
$this->minkParameters[$name] = $value;
}

/**
* Returns Mink session.
*
Expand Down Expand Up @@ -111,14 +133,14 @@ public function locatePath($path)
/**
* Save a screenshot of the current window to the file system.
*
* @param string $filename Desired filename, defaults to
* @param string $filename Desired filename, defaults to
* <browser_name>_<ISO 8601 date>_<randomId>.png
* @param string $filepath Desired filepath, defaults to
* @param string $filepath Desired filepath, defaults to
* upload_tmp_dir, falls back to sys_get_temp_dir()
*/
public function saveScreenshot($filename = null, $filepath = null)
{
// Under Cygwin, uniqid with more_entropy must be set to true.
// Under Cygwin, uniqid with more_entropy must be set to true.
// No effect in other environments.
$filename = $filename ?: sprintf('%s_%s_%s.%s', $this->getMinkParameter('browser_name'), date('c'), uniqid('', true), 'png');
$filepath = $filepath ? $filepath : (ini_get('upload_tmp_dir') ? ini_get('upload_tmp_dir') : sys_get_temp_dir());
Expand Down

0 comments on commit 07014c6

Please sign in to comment.