也许我做错了。如何在模型测试用例中创建模拟
我想测试模型(Antibody)的beforeSave方法。该方法的一部分在关联模型(物种)上调用方法。我想嘲笑物种模型,但没有找到如何。
是否有可能或者我正在做一些违背MVC模式的事情,从而试图做一些我不应该做的事情?
class Antibody extends AppModel {
public function beforeSave() {
// some processing ...
// retreive species_id based on the input
$this->data['Antibody']['species_id']
= isset($this->data['Species']['name'])
? $this->Species->getIdByName($this->data['Species']['name'])
: null;
return true;
}
}
谢谢你,那正是我一直在寻找的东西 – kaklon