【发布时间】:2016-10-21 13:50:26
【问题描述】:
我想测试一个调用 API 的 Shell。 Shell 有一个函数可以为受保护的 var protected $_credential = []; 设置值
class ImportShell extends AppShell
{
protected $_credential = [];
public function sales() {
$credential = $this->Credential->find('first', [
'conditions' => [
'Credential.id' => $this->args[0]
]
]);
$this->_credential = $credential;
}
}
它使用$this->args 中的值来查找表条目并将结果写入$_credential
当我这样使用 $_credential 时,如何在我的测试中访问/更改它?
$ImportShell = $this->getMockBuilder('ImportShell')
->setMethods(array('find'))
->getMock();
$ImportShell->sales();
我如何访问/更改$this->args?
【问题讨论】:
标签: cakephp mocking phpunit cakephp-2.6