我已经编写了一个自定义offeredTreatments
组件。
我想针对下一种情况编写单元测试:
我写了下面的测试。但是我认为这是在输入中模拟文件的错误方法。
/**
* @param $clinicId
* @param $packId
* @return array
* @throws NotFoundHttpException
*/
public function actionPackOfferedTreatments($clinicId, $packId)
{
$clinicId = (int)$clinicId;
$packId = (int)$packId;
// Find model of the clinic
$model = $this->findModel($clinicId);
// pack offeredTreatments:
$packOfferedTreatmentDataProvider = new ActiveDataProvider([
'query' => $model->getOfferedTreatments()
->innerJoin('pack_offeredTreatment', false)
->where(['pack_offeredTreatment.pack_id' => $packId]),
'pagination' => false,
'sort' => [
'defaultOrder' => [
'order' => SORT_ASC
]
]
]);
Yii::$app->response->format = Response::FORMAT_JSON;
return $packOfferedTreatmentDataProvider->getModels();
}