mirror of
https://github.com/Oreolek/ifhub.club.git
synced 2024-07-05 07:54:24 +03:00
Added feature for run custom script
This commit is contained in:
parent
6eb3b959f5
commit
2d00f87d28
|
@ -25,6 +25,7 @@ class BaseFeatureContext extends BehatContext
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
|
$this->sDirRoot = dirname(realpath((dirname(__FILE__)) . "/../../../"));
|
||||||
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
|
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -242,4 +243,20 @@ class BaseFeatureContext extends BehatContext
|
||||||
$fixturePath = realpath((dirname(__FILE__)) . "/../../../../");
|
$fixturePath = realpath((dirname(__FILE__)) . "/../../../../");
|
||||||
$this->getMinkContext()->attachFileToField($path, $fixturePath . $fileName);
|
$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());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue