Updated the code for latest changes done in Behat

This commit is contained in:
Christophe Coevoet
2014-01-05 00:48:09 +01:00
parent 2c521b68ad
commit 8f5332371a
7 changed files with 30 additions and 35 deletions

View File

@@ -40,20 +40,29 @@ class MinkAwareInitializer implements ContextInitializer
}
/**
* Checks if initializer supports provided context.
* Initializes provided context.
*
* @param Context $context
*/
public function initializeContext(Context $context)
{
if (!$context instanceof MinkAwareContext && !$this->usesMinkDictionary($context)) {
return;
}
$context->setMink($this->mink);
$context->setMinkParameters($this->parameters);
}
/**
* Checks whether the context uses the MinkDictionary trait.
*
* @param Context $context
*
* @return Boolean
*/
public function supportsContext(Context $context)
private function usesMinkDictionary(Context $context)
{
// if context/subcontext implements MinkAwareContext
if ($context instanceof MinkAwareContext) {
return true;
}
// if context/subcontext uses MinkDictionary trait
$refl = new \ReflectionObject($context);
if (method_exists($refl, 'getTraitNames')) {
if (in_array('Behat\\MinkExtension\\Context\\MinkDictionary', $refl->getTraitNames())) {
@@ -63,15 +72,4 @@ class MinkAwareInitializer implements ContextInitializer
return false;
}
/**
* Initializes provided context.
*
* @param Context $context
*/
public function initializeContext(Context $context)
{
$context->setMink($this->mink);
$context->setMinkParameters($this->parameters);
}
}

View File

@@ -131,10 +131,10 @@ class RawMinkContext implements MinkAwareContext
/**
* Save a screenshot of the current window to the file system.
*
* @param string $filename Desired filename, defaults to
* <browser_name>_<ISO 8601 date>_<randomId>.png
* @param string $filepath Desired filepath, defaults to
* upload_tmp_dir, falls back to sys_get_temp_dir()
* @param string $filename Desired filename, defaults to
* <browser_name>_<ISO 8601 date>_<randomId>.png
* @param string $filepath Desired filepath, defaults to
* upload_tmp_dir, falls back to sys_get_temp_dir()
*/
public function saveScreenshot($filename = null, $filepath = null)
{