【发布时间】:2015-09-02 07:38:26
【问题描述】:
在 Codeception 2.1 中有一个新函数 current(),它有助于获取当前的测试环境:$scenario->current('env')
我用的是1.8版,没有这个功能。所以,我试图手动将方法 current() 添加到 Scenario 类,但它没有帮助:
protected $env = array();
protected $currents = array();
public function __construct(\Codeception\TestCase $test, $currents = array())
{
$this->test = $test;
$this->currents = $currents;
}
public function env($env)
{
if (!is_array($env)) {
$this->env[] = $env;
return;
}
foreach ($env as $e) {
$this->env($e);
}
}
public function current($key) {
if (!isset($this->currents[$key])) {
echo $this->currents[$key];
throw new TestRuntime("Current $key is not set in this scenario");
}
return $this->currents[$key];
}
【问题讨论】:
标签: php environment codeception