0
我正在爲僅包含兩個字段的簡單模型編寫一些單元測試:question_id和title。在非可填寫字段上工作的批量指派
我給自己定的模型可填寫陣列只包括標題:
protected $fillable = array('title');
我也創建了以下的單元測試:
/**
* @expectedException Illuminate\Database\Eloquent\MassAssignmentException
*/
public function testAnswerQuestionIdCanNotBeMassAssigned()
{
$params = ['question_id' => 1, 'title' => 'something'];
$answer = new Answer($params);
}
但是,不會引發任何異常,導致測試失敗。
我在這裏錯過了什麼嗎?
任何意見讚賞。
謝謝。