아마도 내가 잘못하고 있습니다.모델 테스트 케이스에서 모의를 만드는 방법
모델 (Antibody)의 beforeSave 메소드를 테스트하고 싶습니다. 이 메소드의 일부는 연관된 모델 (Species)에서 메소드를 호출합니다. 종 모델을 조롱하고 싶지만 어떻게 찾지는 않습니까?
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