1
0
Fork 0
mirror of https://github.com/Oreolek/ifhub.club.git synced 2024-07-03 06:55:03 +03:00

Added feature for run custom script

This commit is contained in:
vatseek 2012-12-25 10:49:58 +02:00
parent 6eb3b959f5
commit 2d00f87d28

View file

@ -25,6 +25,7 @@ class BaseFeatureContext extends BehatContext
public function __construct()
{
$this->sDirRoot = dirname(realpath((dirname(__FILE__)) . "/../../../"));
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
}
@ -242,4 +243,20 @@ class BaseFeatureContext extends BehatContext
$fixturePath = realpath((dirname(__FILE__)) . "/../../../../");
$this->getMinkContext()->attachFileToField($path, $fixturePath . $fileName);
}
/**
* @Then /^run script "([^"]*)" and result should contain "([^"]*)"$/
*/
public function runScript($scriptPath, $regex)
{
if (!file_exists($this->sDirRoot . $scriptPath)) {
throw new ExpectationException('Script file not found', $this->getMinkContext()->getSession());
}
$response = shell_exec($this->sDirRoot . $scriptPath);
if (!preg_match($regex, $response)) {
throw new ExpectationException('Invalid script response', $this->getMinkContext()->getSession());
}
}
}