내가 이전 메소드 호출 (및 인수)에 따라 다른 값을 반환 Atoum와 데이터베이스 ($ DB를) 모의을 설계하려고와 방법의 일련의 비웃음.atoum
을 :$this->calling($db)->select = function($table, array $bind, $boolOperator = "AND") use ($permissionClientMapper, $db, $permissionsClientRaw){
if($table === $permissionClientMapper->getTableName()){
$this->calling($db)->fetchAll = function() use ($bind, $permissionsClientRaw){
if(array_key_exists('type_service', $bind) && array_key_exists('id_service', $bind) && $bind['type_service'] === 'mutu' && $bind['id_service'] === 4012){
return EXPECTED_RETURN_VALUE;
}
return null;
};
}
};
내가 (인수를) 호출 할 때 EXECTED_RETURN_VALUE
를 반환하는 코드를 제외시켰다 것 : 나는 PHP 5.6과 Atoum 3.2 여기
을 사용하고
내가 뭘하려
1/ $db->select() -> This method is called as expected
2/ $db->fetchAll() -> This one is never called
나는 Atoum 설명서에이의 예를 찾을 수 없습니다.
는사람이 연속 메소드 호출을 조롱하는 올바른 방법입니다 확인 할 수 ?
은 또한 폐쇄$this->calling($db)->select = function($table, array $bind, $boolOperator = "AND") use ($permissionClientMapper, &$db, $permissionsClientRaw){
if($table === $permissionClientMapper->getTableName()){
$this->calling($db)->fetchAll = function() use ($bind, $permissionsClientRaw){
if(array_key_exists('type_service', $bind) && array_key_exists('id_service', $bind) && $bind['type_service'] === 'mutu' && $bind['id_service'] === 4012){
return EXPECTED_RETURN_VALUE;
}
return null;
};
}
};
의 데이터베이스에 대한 참조를 사용하려고하지만이 중 하나가 작동하지 않습니다.
편집 : 한 가지 해결 방법은 아마 올바른 인수와 함께 불렀다 확인하기 위해 모의를 테스트하기 위해 다음 각 호에 대해 다른 값을 반환 할 atoum 호출 순서를 사용하는 것입니다.
많은 도움을 주셔서 감사합니다. 태그가 존재하지 않는 것 같고 작성하기에 충분한 담당자가 없어서 atoum 질문에 태그를 달 수 없습니다 ... – Ceyfiroth