From 22c41bff9ef0ea137ad1c11c11a51af7c81bc3d8 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Sun, 3 Mar 2013 19:15:29 +0000 Subject: [PATCH] * added method to get all parameters from the mink configuration * added method for setting a single parameter (this is useful for instance if you want to change the base_url context specific) --- .../MinkExtension/Context/RawMinkContext.php | 28 +++++++++++++++++-- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/src/Behat/MinkExtension/Context/RawMinkContext.php b/src/Behat/MinkExtension/Context/RawMinkContext.php index 6c1324a..612e97b 100644 --- a/src/Behat/MinkExtension/Context/RawMinkContext.php +++ b/src/Behat/MinkExtension/Context/RawMinkContext.php @@ -47,6 +47,16 @@ class RawMinkContext extends BehatContext implements MinkAwareInterface return $this->mink; } + /** + * Returns the parameters provided for Mink. + * + * @return array + */ + public function getMinkParameters() + { + return $this->minkParameters; + } + /** * Sets parameters provided for Mink. * @@ -69,6 +79,18 @@ class RawMinkContext extends BehatContext implements MinkAwareInterface 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. * @@ -111,14 +133,14 @@ class RawMinkContext extends BehatContext implements MinkAwareInterface /** * 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 * __.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());